-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmod_test.ts
49 lines (43 loc) · 1.09 KB
/
mod_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import type { BF } from "./mod.ts";
Deno.test("Compile-time tests", () => {});
const asserterLockSymbol = Symbol();
const asserterGenericLockSymbol1 = Symbol();
const asserterGenericLockSymbol2 = Symbol();
type AreEqualTypes<T, F> = [T] extends [F] ? [F] extends [T] ? true : false
: false;
type AssertEqualTypeLock<T, F> = true extends AreEqualTypes<T, F> ? []
: [typeof asserterLockSymbol];
function assertEqualTypes<
T = typeof asserterGenericLockSymbol1,
F = typeof asserterGenericLockSymbol2,
>(
..._asserterLock: AssertEqualTypeLock<T, F>
) {}
assertEqualTypes<
BF<{ program: "." }>,
[0]
>();
assertEqualTypes<
BF<{ program: "+++." }>,
[3]
>();
assertEqualTypes<
BF<{ program: ".+++.---." }>,
[0, 3, 0]
>();
assertEqualTypes<
BF<{ program: ".+.+.+.+.+." }>,
[0, 1, 2, 3, 4, 5]
>();
assertEqualTypes<
BF<{ program: ".>+.>+.>+.>+.>+." }>,
[0, 1, 1, 1, 1, 1]
>();
assertEqualTypes<
BF<{
program:
"++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.";
outputType: "ascii";
}>,
"Hello World!\n"
>();