@as-pect/assembly 6.0.0 → 7.0.0
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.
- package/README.md +34 -34
- package/assembly/index.ts +24 -24
- package/assembly/internal/Actual.ts +20 -20
- package/assembly/internal/Expectation.ts +544 -481
- package/assembly/internal/Expected.ts +55 -55
- package/assembly/internal/Reflect.ts +698 -662
- package/assembly/internal/ReflectedValueType.ts +17 -17
- package/assembly/internal/Test.ts +81 -81
- package/assembly/internal/assert.ts +3 -3
- package/assembly/internal/call.ts +3 -3
- package/assembly/internal/comparison/toIncludeComparison.ts +67 -62
- package/assembly/internal/comparison/toIncludeEqualComparison.ts +91 -78
- package/assembly/internal/log.ts +19 -18
- package/assembly/internal/noOp.ts +3 -2
- package/package.json +17 -10
- package/types/as-pect.d.ts +733 -733
- package/types/as-pect.portable.d.ts +389 -389
- package/types/env.d.ts +1 -1
package/types/as-pect.d.ts
CHANGED
|
@@ -1,733 +1,733 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This function creates a test group in the test loader.
|
|
3
|
-
*
|
|
4
|
-
* @param {string} description - This is the name of the test group.
|
|
5
|
-
* @param {() => void} callback - A function that contains all of the closures for this test group.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* describe("my test suite", (): void => {
|
|
11
|
-
* // put your tests here
|
|
12
|
-
* });
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
declare function describe(description: string, callback: () => void): void;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This function creates a test inside the given test group. It must be placed inside a describe
|
|
19
|
-
* block.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
22
|
-
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* describe("the meaning of life", (): void => {
|
|
28
|
-
* it("should be 42", (): void => {
|
|
29
|
-
* // put your expectations here
|
|
30
|
-
* expect<i32>(29 + 13).toBe(42);
|
|
31
|
-
* });
|
|
32
|
-
* });
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
declare function it(description: string, callback: () => void): void;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A test that does not run, and is longhand equivalent to using todo function without a
|
|
39
|
-
* callback. This test does not get run and is reported like a todo.
|
|
40
|
-
*
|
|
41
|
-
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
42
|
-
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
43
|
-
*/
|
|
44
|
-
declare function xit(description: string, callback: () => void): void;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* A test that does not run, and is longhand equivalent to using todo function without a
|
|
48
|
-
* callback. This test does not get run and is reported like a todo.
|
|
49
|
-
*
|
|
50
|
-
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
51
|
-
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
52
|
-
*/
|
|
53
|
-
declare function xtest(description: string, callback: () => void): void;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* This function creates a test inside the given test group. It must be placed inside a describe
|
|
57
|
-
* block.
|
|
58
|
-
*
|
|
59
|
-
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
60
|
-
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* describe("the meaning of life", (): void => {
|
|
65
|
-
* test("the value should be 42", (): void => {
|
|
66
|
-
* // put your expectations here
|
|
67
|
-
* expect<i32>(29 + 13).toBe(42);
|
|
68
|
-
* });
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
declare function test(description: string, callback: () => void): void;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* This function creates a test that is expected to fail. This is useful to verify if a given
|
|
76
|
-
* behavior is expected to throw.
|
|
77
|
-
*
|
|
78
|
-
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
79
|
-
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
80
|
-
* @param {string?} message - A message that describes why the test should fail.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
*
|
|
84
|
-
* ```ts
|
|
85
|
-
* describe("the meaning of life", (): void => {
|
|
86
|
-
* throws("the value should be 42", (): void => {
|
|
87
|
-
* // put your expectations here
|
|
88
|
-
* expect<i32>(29 + 13).not.toBe(42);
|
|
89
|
-
* });
|
|
90
|
-
* });
|
|
91
|
-
* ```
|
|
92
|
-
*/
|
|
93
|
-
declare function throws(
|
|
94
|
-
description: string,
|
|
95
|
-
callback: () => void,
|
|
96
|
-
message?: string,
|
|
97
|
-
): void;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* This function creates a test that is expected to fail. This is useful to verify if a given
|
|
101
|
-
* behavior is expected to throw.
|
|
102
|
-
*
|
|
103
|
-
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
104
|
-
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
105
|
-
* @param {string?} message - A message that describes why the test should fail.
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
*
|
|
109
|
-
* ```ts
|
|
110
|
-
* describe("the meaning of life", (): void => {
|
|
111
|
-
* itThrows("when the value should be 42", (): void => {
|
|
112
|
-
* // put your expectations here
|
|
113
|
-
* expect<i32>(29 + 13).not.toBe(42);
|
|
114
|
-
* }, "The value is actually 42.");
|
|
115
|
-
* });
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
declare function itThrows(
|
|
119
|
-
description: string,
|
|
120
|
-
callback: () => void,
|
|
121
|
-
message?: string,
|
|
122
|
-
): void;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* This function creates a callback that is called before each individual test is run in this test
|
|
126
|
-
* group.
|
|
127
|
-
*
|
|
128
|
-
* @param {function} callback - The function to be run before each test in the current test group.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
*
|
|
132
|
-
* ```ts
|
|
133
|
-
* // create a global
|
|
134
|
-
* var cat: Cat = new Cat();
|
|
135
|
-
*
|
|
136
|
-
* describe("cats", (): void => {
|
|
137
|
-
* beforeEach((): void => {
|
|
138
|
-
* cat.meow(1); // meow once per test
|
|
139
|
-
* });
|
|
140
|
-
* });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
declare function beforeEach(callback: () => void): void;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* This function creates a callback that is called before the whole test group is run, and only
|
|
147
|
-
* once.
|
|
148
|
-
*
|
|
149
|
-
* @param {function} callback - The function to be run before each test in the current test group.
|
|
150
|
-
*
|
|
151
|
-
* @example
|
|
152
|
-
*
|
|
153
|
-
* ```ts
|
|
154
|
-
* // create a global
|
|
155
|
-
* var dog: Dog = null;
|
|
156
|
-
* describe("dogs", (): void => {
|
|
157
|
-
* beforeAll((): void => {
|
|
158
|
-
* dog = new Dog(); // create a single dog once before the tests start
|
|
159
|
-
* });
|
|
160
|
-
* });
|
|
161
|
-
* ```
|
|
162
|
-
*/
|
|
163
|
-
declare function beforeAll(callback: () => void): void;
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* This function creates a callback that is called after each individual test is run in this test
|
|
167
|
-
* group.
|
|
168
|
-
*
|
|
169
|
-
* @param {function} callback - The function to be run after each test in the current test group.
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
*
|
|
173
|
-
* ```ts
|
|
174
|
-
* // create a global
|
|
175
|
-
* var cat: Cat = new Cat();
|
|
176
|
-
*
|
|
177
|
-
* describe("cats", (): void => {
|
|
178
|
-
* afterEach((): void => {
|
|
179
|
-
* cat.sleep(12); // cats sleep a lot
|
|
180
|
-
* });
|
|
181
|
-
* });
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
declare function afterEach(callback: () => void): void;
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* This function creates a callback that is called after the whole test group is run, and only
|
|
188
|
-
* once.
|
|
189
|
-
*
|
|
190
|
-
* @param {function} callback - The function to be run after each test in the current test group.
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
*
|
|
194
|
-
* ```ts
|
|
195
|
-
* // create a global
|
|
196
|
-
* var dog: Dog = null;
|
|
197
|
-
* describe("dogs", (): void => {
|
|
198
|
-
* afterAll((): void => {
|
|
199
|
-
* memory.free(changetype<usize>(dog)); // free some memory
|
|
200
|
-
* });
|
|
201
|
-
* });
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
declare function afterAll(callback: () => void): void;
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Describes a value and returns an expectation to test the value.
|
|
208
|
-
*
|
|
209
|
-
* @type {T} - The expectation's type.
|
|
210
|
-
* @param {T} actual - The value being tested.
|
|
211
|
-
*
|
|
212
|
-
* @example
|
|
213
|
-
*
|
|
214
|
-
* ```ts
|
|
215
|
-
* expect<i32>(42).not.toBe(-1, "42 should not be -1");
|
|
216
|
-
* expect<i32>(19 + 23).toBe(42, "19 + 23 should equal 42");
|
|
217
|
-
* ```
|
|
218
|
-
*/
|
|
219
|
-
declare function expect<T>(actual: T | null): Expectation<T>;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Describes a void function and returns an expectation to test the function.
|
|
223
|
-
*
|
|
224
|
-
* @param {() => void} callback - The callback being tested.
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
*
|
|
228
|
-
* ```ts
|
|
229
|
-
* expectFn((): void => unreachable()).toThrow("unreachables do not throw");
|
|
230
|
-
* expectFn((): void => {
|
|
231
|
-
* cat.meow();
|
|
232
|
-
* }).not.toThrow("Uhoh, cats can't meow!");;
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
declare function expectFn(cb: () => void): Expectation<() => void>;
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Describes a test that needs to be written.
|
|
239
|
-
*
|
|
240
|
-
* @param {string} description - The description of the test that needs to be written.
|
|
241
|
-
*/
|
|
242
|
-
declare function todo(description: string): void;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Logs a single value to the logger, and is stringified. It works for references, values, and
|
|
246
|
-
* strings.
|
|
247
|
-
*
|
|
248
|
-
* @type {T} - The type to be logged.
|
|
249
|
-
* @param {T | null} value - The value to be logged.
|
|
250
|
-
*
|
|
251
|
-
* @example
|
|
252
|
-
*
|
|
253
|
-
* ```ts
|
|
254
|
-
* log<string>("This is a logged value.");
|
|
255
|
-
* log<i32>(42);
|
|
256
|
-
* log<Vec3>(new Vec(1, 2, 3));
|
|
257
|
-
* log<Vec3>(null);
|
|
258
|
-
* ```
|
|
259
|
-
*/
|
|
260
|
-
declare function log<T>(value: T | null): void;
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* An expectation for a value.
|
|
264
|
-
*/
|
|
265
|
-
// @ts-ignore
|
|
266
|
-
declare class Expectation<T> {
|
|
267
|
-
/**
|
|
268
|
-
* Create a new expectation.
|
|
269
|
-
*
|
|
270
|
-
* @param {T | null} actual - The actual value of the expectation.
|
|
271
|
-
*/
|
|
272
|
-
constructor(actual: T | null);
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* This expectation performs a strict equality on value types and reference types.
|
|
276
|
-
*
|
|
277
|
-
* @param {T | null} expected - The value to be compared.
|
|
278
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
*
|
|
282
|
-
* ```ts
|
|
283
|
-
* expect<i32>(42).not.toBe(-1, "42 should not be -1");
|
|
284
|
-
* expect<i32>(19 + 23).toBe(42, "19 + 23 should equal 42");
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
toBe(expected: T | null, message?: string): void;
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* This expectation performs a strict equality on value types and performs a memcompare on
|
|
291
|
-
* reference types. If the reference type `T` has reference types as properties, the comparison does
|
|
292
|
-
* not perform property traversal. It will only compare the pointer values in the memory block, and
|
|
293
|
-
* only compare `offsetof<T>()` bytes, regardless of the allocated block size.
|
|
294
|
-
*
|
|
295
|
-
* @param {T | null} expected - The value to be compared.
|
|
296
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
297
|
-
*
|
|
298
|
-
* @example
|
|
299
|
-
*
|
|
300
|
-
* ```ts
|
|
301
|
-
* expect<Vec3>(new Vec3(1, 2, 3)).toStrictEqual(new Vec(1, 2, 3), "Vectors of the same shape should be equal");
|
|
302
|
-
* ```
|
|
303
|
-
*/
|
|
304
|
-
toStrictEqual(expected: T | null, message?: string): void;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* This expectation performs a strict memory block equality based on the allocated block sizes.
|
|
308
|
-
*
|
|
309
|
-
* @param {T | null} expected - The value to be compared.
|
|
310
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
311
|
-
*
|
|
312
|
-
* @example
|
|
313
|
-
*
|
|
314
|
-
* ```ts
|
|
315
|
-
* expect<Vec3>(new Vec3(1, 2, 3)).toBlockEqual(new Vec(1, 2, 3), "Vectors of the same shape should be equal");
|
|
316
|
-
* ```
|
|
317
|
-
*/
|
|
318
|
-
toBlockEqual(expected: T | null, message?: string): void;
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* If the value is callable, it calls the function, and fails the expectation if it throws, or hits
|
|
322
|
-
* an unreachable().
|
|
323
|
-
*
|
|
324
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
*
|
|
328
|
-
* ```ts
|
|
329
|
-
* expectFn((): void => unreachable()).toThrow("unreachable() should throw.");
|
|
330
|
-
* expectFn((): void => {
|
|
331
|
-
* cat.sleep(100); // cats can sleep quite a lot
|
|
332
|
-
* }).not.toThrow("cats should sleep, not throw");
|
|
333
|
-
* ```
|
|
334
|
-
*/
|
|
335
|
-
toThrow(message?: string): void;
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* This expecation asserts that the value is truthy, like in javascript. If the value is a string,
|
|
339
|
-
* then strings of length 0 are not truthy.
|
|
340
|
-
*
|
|
341
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
342
|
-
*
|
|
343
|
-
* @example
|
|
344
|
-
*
|
|
345
|
-
* ```ts
|
|
346
|
-
* expect<bool>(true).toBeTruthy("true is truthy.");
|
|
347
|
-
* expect<i32>(1).toBeTruthy("numeric values that are not 0 are truthy.");
|
|
348
|
-
* expect<Vec3>(new Vec3(1, 2, 3)).toBeTruthy("reference types that aren't null are truthy.");
|
|
349
|
-
* expect<bool>(false).not.toBeTruthy("false is not truthy.");
|
|
350
|
-
* expect<i32>(0).not.toBeTruthy("0 is not truthy.");
|
|
351
|
-
* expect<Vec3>(null).not.toBeTruthy("null is not truthy.");
|
|
352
|
-
* ```
|
|
353
|
-
*/
|
|
354
|
-
toBeTruthy(message?: string): void;
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* This expectation tests the value to see if it is null. If the value is a value type, it is
|
|
358
|
-
* never null. If the value is a reference type, it performs a strict null comparison.
|
|
359
|
-
*
|
|
360
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
*
|
|
364
|
-
* ```ts
|
|
365
|
-
* expect<i32>(0).not.toBeNull("numbers are never null");
|
|
366
|
-
* expect<Vec3>(null).toBeNull("null reference types are null.");
|
|
367
|
-
* ```
|
|
368
|
-
*/
|
|
369
|
-
toBeNull(message?: string): void;
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* This expecation assert that the value is falsy, like in javascript. If the value is a string,
|
|
373
|
-
* then strings of length 0 are falsy.
|
|
374
|
-
*
|
|
375
|
-
* @param {string} message - The optional message that describes the expectation.
|
|
376
|
-
*
|
|
377
|
-
* @example
|
|
378
|
-
*
|
|
379
|
-
* ```ts
|
|
380
|
-
* expect<bool>(false).toBeFalsy("false is falsy.");
|
|
381
|
-
* expect<i32>(0).toBeFalsy("0 is falsy.");
|
|
382
|
-
* expect<Vec3>(null).toBeFalsy("null is falsy.");
|
|
383
|
-
* expect<bool>(true).not.toBeFalsy("true is not falsy.");
|
|
384
|
-
* expect<i32>(1).not.toBeFalsy("numeric values that are not 0 are not falsy.");
|
|
385
|
-
* expect<Vec3>(new Vec3(1, 2, 3)).not.toBeFalsy("reference types that aren't null are not falsy.");
|
|
386
|
-
* ```
|
|
387
|
-
*/
|
|
388
|
-
toBeFalsy(message?: string): void;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* This expectation asserts that the value is greater than the expected value. Since operators can
|
|
392
|
-
* be overloaded in assemblyscript, it's possible for this to work on reference types.
|
|
393
|
-
*
|
|
394
|
-
* @param {T | null} expected - The expected value that the actual value should be greater than.
|
|
395
|
-
* @param {string} message - The optional message that describes this expectation.
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
*
|
|
399
|
-
* ```ts
|
|
400
|
-
* expect<i32>(10).toBeGreaterThan(4);
|
|
401
|
-
* expect<i32>(12).not.toBeGreaterThan(42);
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
toBeGreaterThan(expected: T | null, message?: string): void;
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* This expectation asserts that the value is less than the expected value. Since operators can
|
|
408
|
-
* be overloaded in assemblyscript, it's possible for this to work on reference types.
|
|
409
|
-
*
|
|
410
|
-
* @param {T | null} value - The expected value that the actual value should be less than.
|
|
411
|
-
* @param {string} message - The optional message that describes this expectation.
|
|
412
|
-
*
|
|
413
|
-
* @example
|
|
414
|
-
*
|
|
415
|
-
* ```ts
|
|
416
|
-
* expect<i32>(10).not.toBeLessThan(4);
|
|
417
|
-
* expect<i32>(12).toBeLessThan(42);
|
|
418
|
-
* ```
|
|
419
|
-
*/
|
|
420
|
-
toBeLessThan(expected: T | null, message?: string): void;
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* This expectation asserts that the value is greater than or equal to the expected value. Since
|
|
424
|
-
* operators can be overloaded in assemblyscript, it's possible for this to work on reference
|
|
425
|
-
* types.
|
|
426
|
-
*
|
|
427
|
-
* @param {T | null} value - The expected value that the actual value should be greater than or
|
|
428
|
-
* equal to.
|
|
429
|
-
* @param {string} message - The optional message that describes this expectation.
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
*
|
|
433
|
-
* ```ts
|
|
434
|
-
* expect<i32>(42).toBeGreaterThanOrEqual(42);
|
|
435
|
-
* expect<i32>(10).toBeGreaterThanOrEqual(4);
|
|
436
|
-
* expect<i32>(12).not.toBeGreaterThanOrEqual(42);
|
|
437
|
-
* ```
|
|
438
|
-
*/
|
|
439
|
-
toBeGreaterThanOrEqual(expected: T | null, message?: string): void;
|
|
440
|
-
|
|
441
|
-
/**
|
|
442
|
-
* This expectation asserts that the value is less than or equal to the expected value. Since
|
|
443
|
-
* operators can be overloaded in assemblyscript, it's possible for this to work on reference
|
|
444
|
-
* types.
|
|
445
|
-
*
|
|
446
|
-
* @param {T | null} value - The expected value that the actual value should be less than or equal
|
|
447
|
-
* to.
|
|
448
|
-
* @param {string} message - The optional message that describes this expectation.
|
|
449
|
-
*
|
|
450
|
-
* @example
|
|
451
|
-
*
|
|
452
|
-
* ```ts
|
|
453
|
-
* expect<i32>(42).toBeLessThanOrEqual(42);
|
|
454
|
-
* expect<i32>(10).not.toBeLessThanOrEqual(4);
|
|
455
|
-
* expect<i32>(12).toBeLessThanOrEqual(42);
|
|
456
|
-
* ```
|
|
457
|
-
*/
|
|
458
|
-
toBeLessThanOrEqual(expected: T | null, message?: string): void;
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* This expectation asserts that the value is close to another value. Both numbers must be finite,
|
|
462
|
-
* and T must extend f64 or f32.
|
|
463
|
-
*
|
|
464
|
-
* @param {T extends f64 | f32} value - The expected value to be close to.
|
|
465
|
-
* @param {i32} decimalPlaces - The number of decimal places used to calculate epsilon. Default is
|
|
466
|
-
* 2.
|
|
467
|
-
* @param {string} message - The optional message that describes this expectation.
|
|
468
|
-
*
|
|
469
|
-
* @example
|
|
470
|
-
*
|
|
471
|
-
* ```ts
|
|
472
|
-
* expect<f64>(0.1 + 0.2).toBeCloseTo(0.3);
|
|
473
|
-
* ```
|
|
474
|
-
*/
|
|
475
|
-
toBeCloseTo(expected: T, decimalPlaces?: number, message?: string): void;
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* This function asserts the float type value is NaN.
|
|
479
|
-
*
|
|
480
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
481
|
-
*
|
|
482
|
-
* @example
|
|
483
|
-
*
|
|
484
|
-
* ```ts
|
|
485
|
-
* expect<f64>(NaN).toBeNaN();
|
|
486
|
-
* expect<f32>(42).not.toBeNaN();
|
|
487
|
-
* ```
|
|
488
|
-
*/
|
|
489
|
-
toBeNaN(message?: string): void;
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* This function asserts a float is finite.
|
|
493
|
-
*
|
|
494
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
495
|
-
* @example
|
|
496
|
-
*
|
|
497
|
-
* ```ts
|
|
498
|
-
* expect<f32>(42).toBeFinite();
|
|
499
|
-
* expect<f64>(Infinity).not.toBeFinite();
|
|
500
|
-
* ```
|
|
501
|
-
*/
|
|
502
|
-
toBeFinite(message?: string): void;
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* This method asserts the item has the expected length.
|
|
506
|
-
*
|
|
507
|
-
* @param {i32} expected - The expected length.
|
|
508
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
509
|
-
*
|
|
510
|
-
* ```ts
|
|
511
|
-
* expect<i32[]>([1, 2, 3]).toHaveLength(3);
|
|
512
|
-
* ```
|
|
513
|
-
*/
|
|
514
|
-
toHaveLength(expected: i32, message?: string): void;
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* This method asserts that a given T that extends `Array<U>` has a value/reference included.
|
|
518
|
-
*
|
|
519
|
-
* @param {valueof<T>} expected - The expected item to be included in the Array.
|
|
520
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
521
|
-
*
|
|
522
|
-
* @example
|
|
523
|
-
*
|
|
524
|
-
* ```ts
|
|
525
|
-
* expect<i32[]>([1, 2, 3]).toInclude(3);
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
// @ts-ignore: expected value should be known at compile time
|
|
529
|
-
toInclude<U extends valueof<T> | indexof<T>>(
|
|
530
|
-
expected: U,
|
|
531
|
-
message?: string,
|
|
532
|
-
): void;
|
|
533
|
-
|
|
534
|
-
/**
|
|
535
|
-
* This method asserts that a given T that extends `Array<U>` has a value/reference included.
|
|
536
|
-
*
|
|
537
|
-
* @param {valueof<T>} expected - The expected item to be included in the Array.
|
|
538
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
539
|
-
*
|
|
540
|
-
* @example
|
|
541
|
-
*
|
|
542
|
-
* ```ts
|
|
543
|
-
* expect<i32[]>([1, 2, 3]).toContain(3);
|
|
544
|
-
* ```
|
|
545
|
-
*/
|
|
546
|
-
// @ts-ignore: expected value should be known at compile time
|
|
547
|
-
toContain(expected: valueof<T>, message?: string): void;
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* This method asserts that a given T that extends `Array<U>` has a value/reference included and
|
|
551
|
-
* compared via memory.compare().
|
|
552
|
-
*
|
|
553
|
-
* @param {i32} expected - The expected item to be included in the Array.
|
|
554
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
555
|
-
*
|
|
556
|
-
* @example
|
|
557
|
-
* ```ts
|
|
558
|
-
* expect<Vec3[]>([new Vec3(1, 2, 3)]).toInclude(new Vec3(1, 2, 3));
|
|
559
|
-
* ```
|
|
560
|
-
*/
|
|
561
|
-
// @ts-ignore: expected value should be known at compile time
|
|
562
|
-
toIncludeEqual<U extends indexof<T> | valueof<T>>(
|
|
563
|
-
expected: U,
|
|
564
|
-
message?: string,
|
|
565
|
-
): void;
|
|
566
|
-
|
|
567
|
-
/**
|
|
568
|
-
* This method asserts that a given T that extends `Array<U>` has a value/reference included and
|
|
569
|
-
* compared via memory.compare().
|
|
570
|
-
*
|
|
571
|
-
* @param {i32} expected - The expected item to be included in the Array.
|
|
572
|
-
* @param {string} message - The optional message the describes this expectation.
|
|
573
|
-
*
|
|
574
|
-
* @example
|
|
575
|
-
* ```ts
|
|
576
|
-
* expect<Vec3[]>([new Vec3(1, 2, 3)]).toInclude(new Vec3(1, 2, 3));
|
|
577
|
-
* ```
|
|
578
|
-
*/
|
|
579
|
-
// @ts-ignore: expected value should be known at compile time
|
|
580
|
-
toContainEqual<U extends indexof<T> | valueof<T>>(
|
|
581
|
-
expected: U,
|
|
582
|
-
message?: string,
|
|
583
|
-
): void;
|
|
584
|
-
|
|
585
|
-
/**
|
|
586
|
-
* Match a snapshot with a given name for this test.
|
|
587
|
-
*
|
|
588
|
-
* @param {string | null} name - The snapshot name.
|
|
589
|
-
*/
|
|
590
|
-
toMatchSnapshot(name?: string | null): void;
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
* This computed property is chainable, and negates the existing expectation. It returns itself.
|
|
594
|
-
*
|
|
595
|
-
* @example
|
|
596
|
-
* ```ts
|
|
597
|
-
* expect<i32>(42).not.toBe(0, "42 is not 0");
|
|
598
|
-
*/
|
|
599
|
-
not: Expectation<T>;
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* The actual value of the expectation.
|
|
603
|
-
*/
|
|
604
|
-
actual: T | null;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* This is called to stop the debugger. e.g. `node --inspect-brk asp`.
|
|
609
|
-
*/
|
|
610
|
-
declare function debug(): void;
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* This class is static and contains private global values that contain metadata about the Actual
|
|
614
|
-
* value.
|
|
615
|
-
*
|
|
616
|
-
* @example
|
|
617
|
-
* ```ts
|
|
618
|
-
* Actual.report<string>("This is an expected string.");
|
|
619
|
-
* Actual.report<i32[]>([1, 2, 3]);
|
|
620
|
-
* Actual.report<u8>(42);
|
|
621
|
-
* ```
|
|
622
|
-
*/
|
|
623
|
-
declare class Actual {
|
|
624
|
-
/**
|
|
625
|
-
* This function performs reporting to javascript what the actual value of this expectation is.
|
|
626
|
-
*
|
|
627
|
-
* @param {T} actual - The actual value to be reported.
|
|
628
|
-
*/
|
|
629
|
-
public static report<T>(value: T): void;
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* Clear the actual value and release any private memory stored as a global.
|
|
633
|
-
*/
|
|
634
|
-
public static clear(): void;
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/**
|
|
638
|
-
* This class is static and contains private global values that contain metadata about the Expected
|
|
639
|
-
* value.
|
|
640
|
-
*
|
|
641
|
-
* @example
|
|
642
|
-
* ```ts
|
|
643
|
-
* Expected.report<string>("This is an expected string.");
|
|
644
|
-
* Expected.report<i32[]>([1, 2, 3]);
|
|
645
|
-
* Expected.report<u8>(42, i32(true)); // not 42
|
|
646
|
-
* ```
|
|
647
|
-
*/
|
|
648
|
-
declare class Expected {
|
|
649
|
-
/**
|
|
650
|
-
* This function performs reporting to javascript what the expected value of this expectation is.
|
|
651
|
-
* It notifies javascript if the expectation is negated.
|
|
652
|
-
*
|
|
653
|
-
* @param {T} value - The actual value to be reported.
|
|
654
|
-
* @param {i32} negated - An indicator if the expectation is negated. Pass `1` to negate the
|
|
655
|
-
* expectation. (default: 0)
|
|
656
|
-
*/
|
|
657
|
-
public static report<T>(value: T, negated?: i32): void;
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Report an expected truthy value to the host, and if the expectation is negated.
|
|
661
|
-
*
|
|
662
|
-
* @param {i32} negated - A value, 1 or 0 indicating if the expectation is negated.
|
|
663
|
-
*/
|
|
664
|
-
static reportTruthy(negated?: i32): void;
|
|
665
|
-
|
|
666
|
-
/**
|
|
667
|
-
* Report an expected falsy value to the host, and if the expectation is negated.
|
|
668
|
-
*
|
|
669
|
-
* @param {i32} negated - A value, 1 or 0 indicating if the expectation is negated.
|
|
670
|
-
*/
|
|
671
|
-
static reportFalsy(negated?: i32): void;
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* Report an expected finite value to the host, and if the expectation is negated.
|
|
675
|
-
*
|
|
676
|
-
* @param {i32} negated - A value, 1 or 0 indicating if the expectation is negated.
|
|
677
|
-
*/
|
|
678
|
-
static reportFinite(negated?: i32): void;
|
|
679
|
-
|
|
680
|
-
/**
|
|
681
|
-
* Report a snapshot of type T with a given name.
|
|
682
|
-
*
|
|
683
|
-
* @param {T} actual - The actual value.
|
|
684
|
-
* @param {string} name - The snapshot name.
|
|
685
|
-
*/
|
|
686
|
-
static reportSnapshot<T>(actual: T, name?: string | null): void;
|
|
687
|
-
|
|
688
|
-
/**
|
|
689
|
-
* Clear the expected value and release any private memory stored as a global.
|
|
690
|
-
*/
|
|
691
|
-
public static clear(): void;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* Reflection namespace for comparing references of a specific type.
|
|
696
|
-
*/
|
|
697
|
-
declare class Reflect {
|
|
698
|
-
/** A successful matching indicator. */
|
|
699
|
-
public static SUCCESSFUL_MATCH: i32;
|
|
700
|
-
/** An indicator that a matching operation has failed. */
|
|
701
|
-
public static FAILED_MATCH: i32;
|
|
702
|
-
/** A const to define when a matching operation should wait because a circular reference is currently resolving a match. */
|
|
703
|
-
public static DEFER_MATCH: i32;
|
|
704
|
-
|
|
705
|
-
/**
|
|
706
|
-
* Create a reflected value for inspection.
|
|
707
|
-
*
|
|
708
|
-
* @param {T} value - The value to be inspected.
|
|
709
|
-
* @param {Map<usize, i32>?} seen - A map of pointers to hostValues for caching purposes.
|
|
710
|
-
*/
|
|
711
|
-
public static toReflectedValue<T>(value: T, seen?: Map<usize, i32>): i32;
|
|
712
|
-
/**
|
|
713
|
-
* A method used for comparing two values or references to determine if they match each other.
|
|
714
|
-
*
|
|
715
|
-
* @param {T} left - One of the values being compared.
|
|
716
|
-
* @param {T} right - One of the values being compared.
|
|
717
|
-
* @param {usize[]} stack - Internal use only, used to prevent recursion.
|
|
718
|
-
* @param {usize[]} cache - Internal use only, used to prevent recursion.
|
|
719
|
-
*/
|
|
720
|
-
public static equals<T>(
|
|
721
|
-
left: T,
|
|
722
|
-
right: T,
|
|
723
|
-
stack?: usize[],
|
|
724
|
-
cache?: usize[],
|
|
725
|
-
): i32;
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* Attach a stack trace to a value.
|
|
729
|
-
*
|
|
730
|
-
* @param {i32} id - The reflected value to attach the current stack trace to.
|
|
731
|
-
*/
|
|
732
|
-
public static attachStackTrace(id: i32): void;
|
|
733
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* This function creates a test group in the test loader.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} description - This is the name of the test group.
|
|
5
|
+
* @param {() => void} callback - A function that contains all of the closures for this test group.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* describe("my test suite", (): void => {
|
|
11
|
+
* // put your tests here
|
|
12
|
+
* });
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare function describe(description: string, callback: () => void): void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function creates a test inside the given test group. It must be placed inside a describe
|
|
19
|
+
* block.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
22
|
+
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* describe("the meaning of life", (): void => {
|
|
28
|
+
* it("should be 42", (): void => {
|
|
29
|
+
* // put your expectations here
|
|
30
|
+
* expect<i32>(29 + 13).toBe(42);
|
|
31
|
+
* });
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function it(description: string, callback: () => void): void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A test that does not run, and is longhand equivalent to using todo function without a
|
|
39
|
+
* callback. This test does not get run and is reported like a todo.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
42
|
+
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
43
|
+
*/
|
|
44
|
+
declare function xit(description: string, callback: () => void): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A test that does not run, and is longhand equivalent to using todo function without a
|
|
48
|
+
* callback. This test does not get run and is reported like a todo.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
51
|
+
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
52
|
+
*/
|
|
53
|
+
declare function xtest(description: string, callback: () => void): void;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* This function creates a test inside the given test group. It must be placed inside a describe
|
|
57
|
+
* block.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
60
|
+
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* describe("the meaning of life", (): void => {
|
|
65
|
+
* test("the value should be 42", (): void => {
|
|
66
|
+
* // put your expectations here
|
|
67
|
+
* expect<i32>(29 + 13).toBe(42);
|
|
68
|
+
* });
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare function test(description: string, callback: () => void): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* This function creates a test that is expected to fail. This is useful to verify if a given
|
|
76
|
+
* behavior is expected to throw.
|
|
77
|
+
*
|
|
78
|
+
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
79
|
+
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
80
|
+
* @param {string?} message - A message that describes why the test should fail.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
*
|
|
84
|
+
* ```ts
|
|
85
|
+
* describe("the meaning of life", (): void => {
|
|
86
|
+
* throws("the value should be 42", (): void => {
|
|
87
|
+
* // put your expectations here
|
|
88
|
+
* expect<i32>(29 + 13).not.toBe(42);
|
|
89
|
+
* });
|
|
90
|
+
* });
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
declare function throws(
|
|
94
|
+
description: string,
|
|
95
|
+
callback: () => void,
|
|
96
|
+
message?: string,
|
|
97
|
+
): void;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* This function creates a test that is expected to fail. This is useful to verify if a given
|
|
101
|
+
* behavior is expected to throw.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} description - This is the name of the test, and should describe a behavior.
|
|
104
|
+
* @param {() => void} callback - A function that contains a set of expectations for this test.
|
|
105
|
+
* @param {string?} message - A message that describes why the test should fail.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
*
|
|
109
|
+
* ```ts
|
|
110
|
+
* describe("the meaning of life", (): void => {
|
|
111
|
+
* itThrows("when the value should be 42", (): void => {
|
|
112
|
+
* // put your expectations here
|
|
113
|
+
* expect<i32>(29 + 13).not.toBe(42);
|
|
114
|
+
* }, "The value is actually 42.");
|
|
115
|
+
* });
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
declare function itThrows(
|
|
119
|
+
description: string,
|
|
120
|
+
callback: () => void,
|
|
121
|
+
message?: string,
|
|
122
|
+
): void;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This function creates a callback that is called before each individual test is run in this test
|
|
126
|
+
* group.
|
|
127
|
+
*
|
|
128
|
+
* @param {function} callback - The function to be run before each test in the current test group.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
*
|
|
132
|
+
* ```ts
|
|
133
|
+
* // create a global
|
|
134
|
+
* var cat: Cat = new Cat();
|
|
135
|
+
*
|
|
136
|
+
* describe("cats", (): void => {
|
|
137
|
+
* beforeEach((): void => {
|
|
138
|
+
* cat.meow(1); // meow once per test
|
|
139
|
+
* });
|
|
140
|
+
* });
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
declare function beforeEach(callback: () => void): void;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* This function creates a callback that is called before the whole test group is run, and only
|
|
147
|
+
* once.
|
|
148
|
+
*
|
|
149
|
+
* @param {function} callback - The function to be run before each test in the current test group.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
*
|
|
153
|
+
* ```ts
|
|
154
|
+
* // create a global
|
|
155
|
+
* var dog: Dog = null;
|
|
156
|
+
* describe("dogs", (): void => {
|
|
157
|
+
* beforeAll((): void => {
|
|
158
|
+
* dog = new Dog(); // create a single dog once before the tests start
|
|
159
|
+
* });
|
|
160
|
+
* });
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
declare function beforeAll(callback: () => void): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* This function creates a callback that is called after each individual test is run in this test
|
|
167
|
+
* group.
|
|
168
|
+
*
|
|
169
|
+
* @param {function} callback - The function to be run after each test in the current test group.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* // create a global
|
|
175
|
+
* var cat: Cat = new Cat();
|
|
176
|
+
*
|
|
177
|
+
* describe("cats", (): void => {
|
|
178
|
+
* afterEach((): void => {
|
|
179
|
+
* cat.sleep(12); // cats sleep a lot
|
|
180
|
+
* });
|
|
181
|
+
* });
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
declare function afterEach(callback: () => void): void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* This function creates a callback that is called after the whole test group is run, and only
|
|
188
|
+
* once.
|
|
189
|
+
*
|
|
190
|
+
* @param {function} callback - The function to be run after each test in the current test group.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
*
|
|
194
|
+
* ```ts
|
|
195
|
+
* // create a global
|
|
196
|
+
* var dog: Dog = null;
|
|
197
|
+
* describe("dogs", (): void => {
|
|
198
|
+
* afterAll((): void => {
|
|
199
|
+
* memory.free(changetype<usize>(dog)); // free some memory
|
|
200
|
+
* });
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
declare function afterAll(callback: () => void): void;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Describes a value and returns an expectation to test the value.
|
|
208
|
+
*
|
|
209
|
+
* @type {T} - The expectation's type.
|
|
210
|
+
* @param {T} actual - The value being tested.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
*
|
|
214
|
+
* ```ts
|
|
215
|
+
* expect<i32>(42).not.toBe(-1, "42 should not be -1");
|
|
216
|
+
* expect<i32>(19 + 23).toBe(42, "19 + 23 should equal 42");
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
declare function expect<T>(actual: T | null): Expectation<T>;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Describes a void function and returns an expectation to test the function.
|
|
223
|
+
*
|
|
224
|
+
* @param {() => void} callback - The callback being tested.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
*
|
|
228
|
+
* ```ts
|
|
229
|
+
* expectFn((): void => unreachable()).toThrow("unreachables do not throw");
|
|
230
|
+
* expectFn((): void => {
|
|
231
|
+
* cat.meow();
|
|
232
|
+
* }).not.toThrow("Uhoh, cats can't meow!");;
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare function expectFn(cb: () => void): Expectation<() => void>;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Describes a test that needs to be written.
|
|
239
|
+
*
|
|
240
|
+
* @param {string} description - The description of the test that needs to be written.
|
|
241
|
+
*/
|
|
242
|
+
declare function todo(description: string): void;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Logs a single value to the logger, and is stringified. It works for references, values, and
|
|
246
|
+
* strings.
|
|
247
|
+
*
|
|
248
|
+
* @type {T} - The type to be logged.
|
|
249
|
+
* @param {T | null} value - The value to be logged.
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
*
|
|
253
|
+
* ```ts
|
|
254
|
+
* log<string>("This is a logged value.");
|
|
255
|
+
* log<i32>(42);
|
|
256
|
+
* log<Vec3>(new Vec(1, 2, 3));
|
|
257
|
+
* log<Vec3>(null);
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
declare function log<T>(value: T | null): void;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* An expectation for a value.
|
|
264
|
+
*/
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
declare class Expectation<T> {
|
|
267
|
+
/**
|
|
268
|
+
* Create a new expectation.
|
|
269
|
+
*
|
|
270
|
+
* @param {T | null} actual - The actual value of the expectation.
|
|
271
|
+
*/
|
|
272
|
+
constructor(actual: T | null);
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* This expectation performs a strict equality on value types and reference types.
|
|
276
|
+
*
|
|
277
|
+
* @param {T | null} expected - The value to be compared.
|
|
278
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
*
|
|
282
|
+
* ```ts
|
|
283
|
+
* expect<i32>(42).not.toBe(-1, "42 should not be -1");
|
|
284
|
+
* expect<i32>(19 + 23).toBe(42, "19 + 23 should equal 42");
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
toBe(expected: T | null, message?: string): void;
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* This expectation performs a strict equality on value types and performs a memcompare on
|
|
291
|
+
* reference types. If the reference type `T` has reference types as properties, the comparison does
|
|
292
|
+
* not perform property traversal. It will only compare the pointer values in the memory block, and
|
|
293
|
+
* only compare `offsetof<T>()` bytes, regardless of the allocated block size.
|
|
294
|
+
*
|
|
295
|
+
* @param {T | null} expected - The value to be compared.
|
|
296
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
*
|
|
300
|
+
* ```ts
|
|
301
|
+
* expect<Vec3>(new Vec3(1, 2, 3)).toStrictEqual(new Vec(1, 2, 3), "Vectors of the same shape should be equal");
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
304
|
+
toStrictEqual(expected: T | null, message?: string): void;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* This expectation performs a strict memory block equality based on the allocated block sizes.
|
|
308
|
+
*
|
|
309
|
+
* @param {T | null} expected - The value to be compared.
|
|
310
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
311
|
+
*
|
|
312
|
+
* @example
|
|
313
|
+
*
|
|
314
|
+
* ```ts
|
|
315
|
+
* expect<Vec3>(new Vec3(1, 2, 3)).toBlockEqual(new Vec(1, 2, 3), "Vectors of the same shape should be equal");
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
toBlockEqual(expected: T | null, message?: string): void;
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* If the value is callable, it calls the function, and fails the expectation if it throws, or hits
|
|
322
|
+
* an unreachable().
|
|
323
|
+
*
|
|
324
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
*
|
|
328
|
+
* ```ts
|
|
329
|
+
* expectFn((): void => unreachable()).toThrow("unreachable() should throw.");
|
|
330
|
+
* expectFn((): void => {
|
|
331
|
+
* cat.sleep(100); // cats can sleep quite a lot
|
|
332
|
+
* }).not.toThrow("cats should sleep, not throw");
|
|
333
|
+
* ```
|
|
334
|
+
*/
|
|
335
|
+
toThrow(message?: string): void;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* This expecation asserts that the value is truthy, like in javascript. If the value is a string,
|
|
339
|
+
* then strings of length 0 are not truthy.
|
|
340
|
+
*
|
|
341
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
*
|
|
345
|
+
* ```ts
|
|
346
|
+
* expect<bool>(true).toBeTruthy("true is truthy.");
|
|
347
|
+
* expect<i32>(1).toBeTruthy("numeric values that are not 0 are truthy.");
|
|
348
|
+
* expect<Vec3>(new Vec3(1, 2, 3)).toBeTruthy("reference types that aren't null are truthy.");
|
|
349
|
+
* expect<bool>(false).not.toBeTruthy("false is not truthy.");
|
|
350
|
+
* expect<i32>(0).not.toBeTruthy("0 is not truthy.");
|
|
351
|
+
* expect<Vec3>(null).not.toBeTruthy("null is not truthy.");
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
toBeTruthy(message?: string): void;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* This expectation tests the value to see if it is null. If the value is a value type, it is
|
|
358
|
+
* never null. If the value is a reference type, it performs a strict null comparison.
|
|
359
|
+
*
|
|
360
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
*
|
|
364
|
+
* ```ts
|
|
365
|
+
* expect<i32>(0).not.toBeNull("numbers are never null");
|
|
366
|
+
* expect<Vec3>(null).toBeNull("null reference types are null.");
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
toBeNull(message?: string): void;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* This expecation assert that the value is falsy, like in javascript. If the value is a string,
|
|
373
|
+
* then strings of length 0 are falsy.
|
|
374
|
+
*
|
|
375
|
+
* @param {string} message - The optional message that describes the expectation.
|
|
376
|
+
*
|
|
377
|
+
* @example
|
|
378
|
+
*
|
|
379
|
+
* ```ts
|
|
380
|
+
* expect<bool>(false).toBeFalsy("false is falsy.");
|
|
381
|
+
* expect<i32>(0).toBeFalsy("0 is falsy.");
|
|
382
|
+
* expect<Vec3>(null).toBeFalsy("null is falsy.");
|
|
383
|
+
* expect<bool>(true).not.toBeFalsy("true is not falsy.");
|
|
384
|
+
* expect<i32>(1).not.toBeFalsy("numeric values that are not 0 are not falsy.");
|
|
385
|
+
* expect<Vec3>(new Vec3(1, 2, 3)).not.toBeFalsy("reference types that aren't null are not falsy.");
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
toBeFalsy(message?: string): void;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* This expectation asserts that the value is greater than the expected value. Since operators can
|
|
392
|
+
* be overloaded in assemblyscript, it's possible for this to work on reference types.
|
|
393
|
+
*
|
|
394
|
+
* @param {T | null} expected - The expected value that the actual value should be greater than.
|
|
395
|
+
* @param {string} message - The optional message that describes this expectation.
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
*
|
|
399
|
+
* ```ts
|
|
400
|
+
* expect<i32>(10).toBeGreaterThan(4);
|
|
401
|
+
* expect<i32>(12).not.toBeGreaterThan(42);
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
toBeGreaterThan(expected: T | null, message?: string): void;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* This expectation asserts that the value is less than the expected value. Since operators can
|
|
408
|
+
* be overloaded in assemblyscript, it's possible for this to work on reference types.
|
|
409
|
+
*
|
|
410
|
+
* @param {T | null} value - The expected value that the actual value should be less than.
|
|
411
|
+
* @param {string} message - The optional message that describes this expectation.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
*
|
|
415
|
+
* ```ts
|
|
416
|
+
* expect<i32>(10).not.toBeLessThan(4);
|
|
417
|
+
* expect<i32>(12).toBeLessThan(42);
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
toBeLessThan(expected: T | null, message?: string): void;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* This expectation asserts that the value is greater than or equal to the expected value. Since
|
|
424
|
+
* operators can be overloaded in assemblyscript, it's possible for this to work on reference
|
|
425
|
+
* types.
|
|
426
|
+
*
|
|
427
|
+
* @param {T | null} value - The expected value that the actual value should be greater than or
|
|
428
|
+
* equal to.
|
|
429
|
+
* @param {string} message - The optional message that describes this expectation.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
*
|
|
433
|
+
* ```ts
|
|
434
|
+
* expect<i32>(42).toBeGreaterThanOrEqual(42);
|
|
435
|
+
* expect<i32>(10).toBeGreaterThanOrEqual(4);
|
|
436
|
+
* expect<i32>(12).not.toBeGreaterThanOrEqual(42);
|
|
437
|
+
* ```
|
|
438
|
+
*/
|
|
439
|
+
toBeGreaterThanOrEqual(expected: T | null, message?: string): void;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* This expectation asserts that the value is less than or equal to the expected value. Since
|
|
443
|
+
* operators can be overloaded in assemblyscript, it's possible for this to work on reference
|
|
444
|
+
* types.
|
|
445
|
+
*
|
|
446
|
+
* @param {T | null} value - The expected value that the actual value should be less than or equal
|
|
447
|
+
* to.
|
|
448
|
+
* @param {string} message - The optional message that describes this expectation.
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
*
|
|
452
|
+
* ```ts
|
|
453
|
+
* expect<i32>(42).toBeLessThanOrEqual(42);
|
|
454
|
+
* expect<i32>(10).not.toBeLessThanOrEqual(4);
|
|
455
|
+
* expect<i32>(12).toBeLessThanOrEqual(42);
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
toBeLessThanOrEqual(expected: T | null, message?: string): void;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* This expectation asserts that the value is close to another value. Both numbers must be finite,
|
|
462
|
+
* and T must extend f64 or f32.
|
|
463
|
+
*
|
|
464
|
+
* @param {T extends f64 | f32} value - The expected value to be close to.
|
|
465
|
+
* @param {i32} decimalPlaces - The number of decimal places used to calculate epsilon. Default is
|
|
466
|
+
* 2.
|
|
467
|
+
* @param {string} message - The optional message that describes this expectation.
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
*
|
|
471
|
+
* ```ts
|
|
472
|
+
* expect<f64>(0.1 + 0.2).toBeCloseTo(0.3);
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
toBeCloseTo(expected: T, decimalPlaces?: number, message?: string): void;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* This function asserts the float type value is NaN.
|
|
479
|
+
*
|
|
480
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
*
|
|
484
|
+
* ```ts
|
|
485
|
+
* expect<f64>(NaN).toBeNaN();
|
|
486
|
+
* expect<f32>(42).not.toBeNaN();
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
toBeNaN(message?: string): void;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* This function asserts a float is finite.
|
|
493
|
+
*
|
|
494
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
495
|
+
* @example
|
|
496
|
+
*
|
|
497
|
+
* ```ts
|
|
498
|
+
* expect<f32>(42).toBeFinite();
|
|
499
|
+
* expect<f64>(Infinity).not.toBeFinite();
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
toBeFinite(message?: string): void;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* This method asserts the item has the expected length.
|
|
506
|
+
*
|
|
507
|
+
* @param {i32} expected - The expected length.
|
|
508
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
509
|
+
*
|
|
510
|
+
* ```ts
|
|
511
|
+
* expect<i32[]>([1, 2, 3]).toHaveLength(3);
|
|
512
|
+
* ```
|
|
513
|
+
*/
|
|
514
|
+
toHaveLength(expected: i32, message?: string): void;
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* This method asserts that a given T that extends `Array<U>` has a value/reference included.
|
|
518
|
+
*
|
|
519
|
+
* @param {valueof<T>} expected - The expected item to be included in the Array.
|
|
520
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
*
|
|
524
|
+
* ```ts
|
|
525
|
+
* expect<i32[]>([1, 2, 3]).toInclude(3);
|
|
526
|
+
* ```
|
|
527
|
+
*/
|
|
528
|
+
// @ts-ignore: expected value should be known at compile time
|
|
529
|
+
toInclude<U extends valueof<T> | indexof<T>>(
|
|
530
|
+
expected: U,
|
|
531
|
+
message?: string,
|
|
532
|
+
): void;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* This method asserts that a given T that extends `Array<U>` has a value/reference included.
|
|
536
|
+
*
|
|
537
|
+
* @param {valueof<T>} expected - The expected item to be included in the Array.
|
|
538
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
*
|
|
542
|
+
* ```ts
|
|
543
|
+
* expect<i32[]>([1, 2, 3]).toContain(3);
|
|
544
|
+
* ```
|
|
545
|
+
*/
|
|
546
|
+
// @ts-ignore: expected value should be known at compile time
|
|
547
|
+
toContain(expected: valueof<T>, message?: string): void;
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* This method asserts that a given T that extends `Array<U>` has a value/reference included and
|
|
551
|
+
* compared via memory.compare().
|
|
552
|
+
*
|
|
553
|
+
* @param {i32} expected - The expected item to be included in the Array.
|
|
554
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* expect<Vec3[]>([new Vec3(1, 2, 3)]).toInclude(new Vec3(1, 2, 3));
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
// @ts-ignore: expected value should be known at compile time
|
|
562
|
+
toIncludeEqual<U extends indexof<T> | valueof<T>>(
|
|
563
|
+
expected: U,
|
|
564
|
+
message?: string,
|
|
565
|
+
): void;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* This method asserts that a given T that extends `Array<U>` has a value/reference included and
|
|
569
|
+
* compared via memory.compare().
|
|
570
|
+
*
|
|
571
|
+
* @param {i32} expected - The expected item to be included in the Array.
|
|
572
|
+
* @param {string} message - The optional message the describes this expectation.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```ts
|
|
576
|
+
* expect<Vec3[]>([new Vec3(1, 2, 3)]).toInclude(new Vec3(1, 2, 3));
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
// @ts-ignore: expected value should be known at compile time
|
|
580
|
+
toContainEqual<U extends indexof<T> | valueof<T>>(
|
|
581
|
+
expected: U,
|
|
582
|
+
message?: string,
|
|
583
|
+
): void;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Match a snapshot with a given name for this test.
|
|
587
|
+
*
|
|
588
|
+
* @param {string | null} name - The snapshot name.
|
|
589
|
+
*/
|
|
590
|
+
toMatchSnapshot(name?: string | null): void;
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* This computed property is chainable, and negates the existing expectation. It returns itself.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* ```ts
|
|
597
|
+
* expect<i32>(42).not.toBe(0, "42 is not 0");
|
|
598
|
+
*/
|
|
599
|
+
not: Expectation<T>;
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* The actual value of the expectation.
|
|
603
|
+
*/
|
|
604
|
+
actual: T | null;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* This is called to stop the debugger. e.g. `node --inspect-brk asp`.
|
|
609
|
+
*/
|
|
610
|
+
declare function debug(): void;
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* This class is static and contains private global values that contain metadata about the Actual
|
|
614
|
+
* value.
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```ts
|
|
618
|
+
* Actual.report<string>("This is an expected string.");
|
|
619
|
+
* Actual.report<i32[]>([1, 2, 3]);
|
|
620
|
+
* Actual.report<u8>(42);
|
|
621
|
+
* ```
|
|
622
|
+
*/
|
|
623
|
+
declare class Actual {
|
|
624
|
+
/**
|
|
625
|
+
* This function performs reporting to javascript what the actual value of this expectation is.
|
|
626
|
+
*
|
|
627
|
+
* @param {T} actual - The actual value to be reported.
|
|
628
|
+
*/
|
|
629
|
+
public static report<T>(value: T): void;
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* Clear the actual value and release any private memory stored as a global.
|
|
633
|
+
*/
|
|
634
|
+
public static clear(): void;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* This class is static and contains private global values that contain metadata about the Expected
|
|
639
|
+
* value.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```ts
|
|
643
|
+
* Expected.report<string>("This is an expected string.");
|
|
644
|
+
* Expected.report<i32[]>([1, 2, 3]);
|
|
645
|
+
* Expected.report<u8>(42, i32(true)); // not 42
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
declare class Expected {
|
|
649
|
+
/**
|
|
650
|
+
* This function performs reporting to javascript what the expected value of this expectation is.
|
|
651
|
+
* It notifies javascript if the expectation is negated.
|
|
652
|
+
*
|
|
653
|
+
* @param {T} value - The actual value to be reported.
|
|
654
|
+
* @param {i32} negated - An indicator if the expectation is negated. Pass `1` to negate the
|
|
655
|
+
* expectation. (default: 0)
|
|
656
|
+
*/
|
|
657
|
+
public static report<T>(value: T, negated?: i32): void;
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* Report an expected truthy value to the host, and if the expectation is negated.
|
|
661
|
+
*
|
|
662
|
+
* @param {i32} negated - A value, 1 or 0 indicating if the expectation is negated.
|
|
663
|
+
*/
|
|
664
|
+
static reportTruthy(negated?: i32): void;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* Report an expected falsy value to the host, and if the expectation is negated.
|
|
668
|
+
*
|
|
669
|
+
* @param {i32} negated - A value, 1 or 0 indicating if the expectation is negated.
|
|
670
|
+
*/
|
|
671
|
+
static reportFalsy(negated?: i32): void;
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Report an expected finite value to the host, and if the expectation is negated.
|
|
675
|
+
*
|
|
676
|
+
* @param {i32} negated - A value, 1 or 0 indicating if the expectation is negated.
|
|
677
|
+
*/
|
|
678
|
+
static reportFinite(negated?: i32): void;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Report a snapshot of type T with a given name.
|
|
682
|
+
*
|
|
683
|
+
* @param {T} actual - The actual value.
|
|
684
|
+
* @param {string} name - The snapshot name.
|
|
685
|
+
*/
|
|
686
|
+
static reportSnapshot<T>(actual: T, name?: string | null): void;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Clear the expected value and release any private memory stored as a global.
|
|
690
|
+
*/
|
|
691
|
+
public static clear(): void;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Reflection namespace for comparing references of a specific type.
|
|
696
|
+
*/
|
|
697
|
+
declare class Reflect {
|
|
698
|
+
/** A successful matching indicator. */
|
|
699
|
+
public static SUCCESSFUL_MATCH: i32;
|
|
700
|
+
/** An indicator that a matching operation has failed. */
|
|
701
|
+
public static FAILED_MATCH: i32;
|
|
702
|
+
/** A const to define when a matching operation should wait because a circular reference is currently resolving a match. */
|
|
703
|
+
public static DEFER_MATCH: i32;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Create a reflected value for inspection.
|
|
707
|
+
*
|
|
708
|
+
* @param {T} value - The value to be inspected.
|
|
709
|
+
* @param {Map<usize, i32>?} seen - A map of pointers to hostValues for caching purposes.
|
|
710
|
+
*/
|
|
711
|
+
public static toReflectedValue<T>(value: T, seen?: Map<usize, i32>): i32;
|
|
712
|
+
/**
|
|
713
|
+
* A method used for comparing two values or references to determine if they match each other.
|
|
714
|
+
*
|
|
715
|
+
* @param {T} left - One of the values being compared.
|
|
716
|
+
* @param {T} right - One of the values being compared.
|
|
717
|
+
* @param {usize[]} stack - Internal use only, used to prevent recursion.
|
|
718
|
+
* @param {usize[]} cache - Internal use only, used to prevent recursion.
|
|
719
|
+
*/
|
|
720
|
+
public static equals<T>(
|
|
721
|
+
left: T,
|
|
722
|
+
right: T,
|
|
723
|
+
stack?: usize[],
|
|
724
|
+
cache?: usize[],
|
|
725
|
+
): i32;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Attach a stack trace to a value.
|
|
729
|
+
*
|
|
730
|
+
* @param {i32} id - The reflected value to attach the current stack trace to.
|
|
731
|
+
*/
|
|
732
|
+
public static attachStackTrace(id: i32): void;
|
|
733
|
+
}
|