@rivetkit/engine-runner 2.0.27 → 2.0.29-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,194 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- wrappingGteU16,
4
- wrappingGtU16,
5
- wrappingLteU16,
6
- wrappingLtU16,
7
- } from "../src/utils";
8
-
9
- describe("wrappingGtU16", () => {
10
- it("should return true when a > b in normal case", () => {
11
- expect(wrappingGtU16(100, 50)).toBe(true);
12
- expect(wrappingGtU16(1000, 999)).toBe(true);
13
- });
14
-
15
- it("should return false when a < b in normal case", () => {
16
- expect(wrappingGtU16(50, 100)).toBe(false);
17
- expect(wrappingGtU16(999, 1000)).toBe(false);
18
- });
19
-
20
- it("should return false when a == b", () => {
21
- expect(wrappingGtU16(100, 100)).toBe(false);
22
- expect(wrappingGtU16(0, 0)).toBe(false);
23
- expect(wrappingGtU16(65535, 65535)).toBe(false);
24
- });
25
-
26
- it("should handle wrapping around u16 max", () => {
27
- // When values wrap around, 1 is "greater than" 65535
28
- expect(wrappingGtU16(1, 65535)).toBe(true);
29
- expect(wrappingGtU16(100, 65500)).toBe(true);
30
- });
31
-
32
- it("should handle edge cases near u16 boundaries", () => {
33
- // 65535 is not greater than 0 (wrapped)
34
- expect(wrappingGtU16(65535, 0)).toBe(false);
35
- // But 0 is greater than 65535 if we consider wrapping
36
- expect(wrappingGtU16(0, 65535)).toBe(true);
37
- });
38
-
39
- it("should handle values at exactly half the range", () => {
40
- // U16_MAX / 2 = 32767.5, so values with distance <= 32767 return true
41
- const lessThanHalf = 32766;
42
- expect(wrappingGtU16(lessThanHalf, 0)).toBe(true);
43
- expect(wrappingGtU16(0, lessThanHalf)).toBe(false);
44
-
45
- // At distance 32767, still less than 32767.5, so comparison returns true
46
- const atHalfDistance = 32767;
47
- expect(wrappingGtU16(atHalfDistance, 0)).toBe(true);
48
- expect(wrappingGtU16(0, atHalfDistance)).toBe(false);
49
-
50
- // At distance 32768, greater than 32767.5, so comparison returns false
51
- const overHalfDistance = 32768;
52
- expect(wrappingGtU16(overHalfDistance, 0)).toBe(false);
53
- expect(wrappingGtU16(0, overHalfDistance)).toBe(false);
54
- });
55
- });
56
-
57
- describe("wrappingLtU16", () => {
58
- it("should return true when a < b in normal case", () => {
59
- expect(wrappingLtU16(50, 100)).toBe(true);
60
- expect(wrappingLtU16(999, 1000)).toBe(true);
61
- });
62
-
63
- it("should return false when a > b in normal case", () => {
64
- expect(wrappingLtU16(100, 50)).toBe(false);
65
- expect(wrappingLtU16(1000, 999)).toBe(false);
66
- });
67
-
68
- it("should return false when a == b", () => {
69
- expect(wrappingLtU16(100, 100)).toBe(false);
70
- expect(wrappingLtU16(0, 0)).toBe(false);
71
- expect(wrappingLtU16(65535, 65535)).toBe(false);
72
- });
73
-
74
- it("should handle wrapping around u16 max", () => {
75
- // When values wrap around, 65535 is "less than" 1
76
- expect(wrappingLtU16(65535, 1)).toBe(true);
77
- expect(wrappingLtU16(65500, 100)).toBe(true);
78
- });
79
-
80
- it("should handle edge cases near u16 boundaries", () => {
81
- // 0 is not less than 65535 (wrapped)
82
- expect(wrappingLtU16(0, 65535)).toBe(false);
83
- // But 65535 is less than 0 if we consider wrapping
84
- expect(wrappingLtU16(65535, 0)).toBe(true);
85
- });
86
-
87
- it("should handle values at exactly half the range", () => {
88
- // U16_MAX / 2 = 32767.5, so values with distance <= 32767 return true
89
- const lessThanHalf = 32766;
90
- expect(wrappingLtU16(0, lessThanHalf)).toBe(true);
91
- expect(wrappingLtU16(lessThanHalf, 0)).toBe(false);
92
-
93
- // At distance 32767, still less than 32767.5, so comparison returns true
94
- const atHalfDistance = 32767;
95
- expect(wrappingLtU16(0, atHalfDistance)).toBe(true);
96
- expect(wrappingLtU16(atHalfDistance, 0)).toBe(false);
97
-
98
- // At distance 32768, greater than 32767.5, so comparison returns false
99
- const overHalfDistance = 32768;
100
- expect(wrappingLtU16(0, overHalfDistance)).toBe(false);
101
- expect(wrappingLtU16(overHalfDistance, 0)).toBe(false);
102
- });
103
- });
104
-
105
- describe("wrappingGtU16 and wrappingLtU16 consistency", () => {
106
- it("should be inverse of each other for different values", () => {
107
- const testCases: [number, number][] = [
108
- [100, 200],
109
- [200, 100],
110
- [0, 65535],
111
- [65535, 0],
112
- [1, 65534],
113
- [32767, 32768],
114
- ];
115
-
116
- for (const [a, b] of testCases) {
117
- const gt = wrappingGtU16(a, b);
118
- const lt = wrappingLtU16(a, b);
119
- const eq = a === b;
120
-
121
- // For any pair, exactly one of gt, lt, or eq should be true
122
- expect(Number(gt) + Number(lt) + Number(eq)).toBe(1);
123
- }
124
- });
125
-
126
- it("should satisfy transitivity for sequential values", () => {
127
- // If we have sequential indices, a < b < c should hold
128
- const a = 100;
129
- const b = 101;
130
- const c = 102;
131
-
132
- expect(wrappingLtU16(a, b)).toBe(true);
133
- expect(wrappingLtU16(b, c)).toBe(true);
134
- expect(wrappingLtU16(a, c)).toBe(true);
135
- });
136
-
137
- it("should handle sequence across wrap boundary", () => {
138
- // Test a sequence that wraps: 65534, 65535, 0, 1
139
- const values = [65534, 65535, 0, 1];
140
-
141
- for (let i = 0; i < values.length - 1; i++) {
142
- expect(wrappingLtU16(values[i], values[i + 1])).toBe(true);
143
- expect(wrappingGtU16(values[i + 1], values[i])).toBe(true);
144
- }
145
- });
146
- });
147
-
148
- describe("wrappingGteU16", () => {
149
- it("should return true when a > b", () => {
150
- expect(wrappingGteU16(100, 50)).toBe(true);
151
- expect(wrappingGteU16(1000, 999)).toBe(true);
152
- });
153
-
154
- it("should return true when a == b", () => {
155
- expect(wrappingGteU16(100, 100)).toBe(true);
156
- expect(wrappingGteU16(0, 0)).toBe(true);
157
- expect(wrappingGteU16(65535, 65535)).toBe(true);
158
- });
159
-
160
- it("should return false when a < b", () => {
161
- expect(wrappingGteU16(50, 100)).toBe(false);
162
- expect(wrappingGteU16(999, 1000)).toBe(false);
163
- });
164
-
165
- it("should handle wrapping around u16 max", () => {
166
- expect(wrappingGteU16(1, 65535)).toBe(true);
167
- expect(wrappingGteU16(100, 65500)).toBe(true);
168
- expect(wrappingGteU16(0, 65535)).toBe(true);
169
- });
170
- });
171
-
172
- describe("wrappingLteU16", () => {
173
- it("should return true when a < b", () => {
174
- expect(wrappingLteU16(50, 100)).toBe(true);
175
- expect(wrappingLteU16(999, 1000)).toBe(true);
176
- });
177
-
178
- it("should return true when a == b", () => {
179
- expect(wrappingLteU16(100, 100)).toBe(true);
180
- expect(wrappingLteU16(0, 0)).toBe(true);
181
- expect(wrappingLteU16(65535, 65535)).toBe(true);
182
- });
183
-
184
- it("should return false when a > b", () => {
185
- expect(wrappingLteU16(100, 50)).toBe(false);
186
- expect(wrappingLteU16(1000, 999)).toBe(false);
187
- });
188
-
189
- it("should handle wrapping around u16 max", () => {
190
- expect(wrappingLteU16(65535, 1)).toBe(true);
191
- expect(wrappingLteU16(65500, 100)).toBe(true);
192
- expect(wrappingLteU16(65535, 0)).toBe(true);
193
- });
194
- });
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.base.json",
3
- "compilerOptions": {
4
- "types": ["node"],
5
- "paths": {
6
- "@/*": ["./src/*"]
7
- }
8
- },
9
- "include": ["src/**/*", "tests/**/*", "benches/**/*"],
10
- "exclude": ["node_modules"]
11
- }
package/tsup.config.ts DELETED
@@ -1,4 +0,0 @@
1
- import { defineConfig } from "tsup";
2
- import defaultConfig from "../../../../tsup.base.ts";
3
-
4
- export default defineConfig(defaultConfig);
package/turbo.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "$schema": "https://turbo.build/schema.json",
3
- "extends": ["//"]
4
- }
package/vitest.config.ts DELETED
@@ -1,16 +0,0 @@
1
- import { resolve } from "node:path";
2
- import { defineConfig } from "vitest/config";
3
- import defaultConfig from "../../../../vitest.base.ts";
4
-
5
- export default defineConfig({
6
- ...defaultConfig,
7
- resolve: {
8
- alias: {
9
- "@": resolve(__dirname, "./src"),
10
- },
11
- },
12
- test: {
13
- ...defaultConfig.test,
14
- include: ["tests/**/*.test.ts"],
15
- },
16
- });