-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.ts
More file actions
64 lines (55 loc) · 1.78 KB
/
tests.ts
File metadata and controls
64 lines (55 loc) · 1.78 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { VM, True, False, N_1, N_3, N_5, N_15, Line } from './vm';
type _ = '';
//#region Counter /////////////////////////////////////////////////////////////
type Counter = VM<[
['push', N_1], // 1
['printHead', _], // 2
['eq', N_15], // 3
['ifNZero', Line<7>], // 4
['inc', _], // 5
['jump', Line<2>], // 6
['stop', _] // 7
]>;
interface TestCounter {
expected: {
stdOut: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"]
}
actual: TestCounter['expected']
}
interface TestCounter {
actual: Counter
}
//#endregion Counter //////////////////////////////////////////////////////////
//#region FizzBuzz ////////////////////////////////////////////////////////////
type FizzBuzz = VM<[
['push', N_1], // 1
['push', False], // 2
['peek', _], // 3
['mod', N_3], // 4
['ifNZero', Line<8>], // 5
['replace', True], // 6
['print', 'fizz'], // 7
['peek', _], // 8
['mod', N_5], // 9
['ifNZero', Line<13>], // 10
['replace', True], // 11
['print', 'buzz'], // 12
['ifNZero', Line<15>], // 13
['printHead', _], // 14
['eq', N_15], // 15
['ifNZero', Line<19>], // 16
['inc', _], // 17
['jump', Line<2>], // 18
['pop', _], // 19
['stop', _] // 20
]>;
interface TestFizzBuzz {
expected: {
stdOut: ['1', '2', 'fizz', '4', 'buzz', 'fizz', '7', '8', 'fizz', 'buzz', '11', 'fizz', '13', '14', 'fizz', 'buzz']
}
actual: TestFizzBuzz['expected']
}
interface TestFizzBuzz {
actual: FizzBuzz
}
//#endregion FizzBuzz /////////////////////////////////////////////////////////