-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathday13_tests.tal
132 lines (106 loc) · 2.5 KB
/
day13_tests.tal
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
~library/macros.tal
~library/devices.tal
( variables )
|0000
|0100 @program
T< "parse-dot-line: >T
S< 0a >S ;test-parse-dot-line JSR2 ( EXPECT 65535 65535 )
S< "6,10 0a 'A >S ;test-parse-dot-line JSR2 ( EXPECT 6 10 )
;get-byte-from-input JSR2 EMIT LF ( EXPECT A )
T< "parse-fold-line: >T
S< >S ;test-parse-fold-line JSR2 ( EXPECT 65535 0xff )
STKCHK
S< "fold 20 "along 20 "x=12 0a >S ;test-parse-fold-line JSR2 ( EXPECT 12 0x78 )
T< "parse-lines: >T
S< "6,10 0a
"5,14 0a
0a
"fold 20 "along 20 "x=1 0a
"fold 20 "along 20 "y=34 0a >S ;test-parse-lines JSR2
( EXPECT 6,10 5,14 n=2 )
( EXPECT x=1 y=34 )
T< "process-horizontal-fold: >T
S< "6,10 0a
"5,14 0a
"1,15 0a
0a
"fold 20 "along 20 "x=3 0a >S ;test-process-fold JSR2
( EXPECT 6,10 5,14 1,15 n=3 )
( EXPECT 0,10 1,14 1,15 n=3 )
T< "distinct-dots: >T
S< "1,2 0a
"3,4 0a
"1,2 0a
0a >S ;test-distinct-dots JSR2
( EXPECT 3,4 1,2 n=2 )
T< "process-vertical-fold: >T
S< "16,5 0a
"5,14 0a
"1,15 0a
0a
"fold 20 "along 20 "y=10 0a >S ;test-process-fold JSR2
( EXPECT 16,5 5,14 1,15 n=3 )
( EXPECT 16,5 5,6 1,5 n=3 )
T< "process-folds: >T
S< "16,5 0a
"5,14 0a
"1,15 0a
0a
"fold 20 "along 20 "x=9 0a
"fold 20 "along 20 "y=10 0a >S ;test-process-folds JSR2
( EXPECT 16,5 5,14 1,15 n=3 )
( EXPECT 2,5 5,14 1,15 n=3 )
( EXPECT 2,5 5,6 1,5 n=3 )
T< "👍 >T
BRK !
~day13_lib.tal
|f000
~library/test.tal
( s* -- )
@test-parse-dot-line
;make-get-byte JSR2 ;parse-dot-line JSR2
STH2 DBGSHORTDECn POP2 SP STH2r DBGSHORTDEC POP2
RTN
( s* -- )
@test-parse-fold-line
;make-get-byte JSR2 ;parse-fold-line JSR2
STH DBGSHORTDECn POP2 SP STHr DBGBYTE POP
RTN
( s* -- )
@test-parse-lines
;make-get-byte JSR2 ;parse-lines JSR2
;dump-dots JSR2
;dump-folds JSR2
RTN
( s* -- )
@test-process-fold
;make-get-byte JSR2 ;parse-lines JSR2
;dump-dots JSR2
;folds ;process-fold JSR2
;dump-dots JSR2
RTN
( s* -- )
@test-process-folds
;make-get-byte JSR2 ;parse-lines JSR2
;dump-dots JSR2
;dump-dots [ ;post-fold-hook STA2 ]
;process-folds JSR2
RTN
( s* -- )
@test-distinct-dots
;make-get-byte JSR2 ;parse-lines JSR2
;distinct-dots JSR2
;dump-dots JSR2
RTN
( s* -- get-byte )
@make-get-byte
;input STA2
;get-byte-from-input
RTN
( -- b )
@get-byte-from-input
[ ;input LDA2 ] LDA STH
[ ;input LDA2 ] INC2 [ ;input STA2 ]
STHr
RTN
@input $2