-
Notifications
You must be signed in to change notification settings - Fork 0
/
02-parse_tapstream.t
executable file
·271 lines (207 loc) · 7.52 KB
/
02-parse_tapstream.t
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#!/usr/bin/env parrot
.include 'lib/Tapir/Parser.pir'
.include 'lib/Tapir/Stream.pir'
.sub main :main
.include 'test_more.pir'
.local pmc tapir, klass
plan(52)
# setup test data
klass = newclass [ 'Tapir'; 'Parser' ]
tapir = klass.'new'()
# run tests
test_is_pass(tapir)
test_really_simple(tapir)
test_parse_tapstream_simple(tapir)
test_parse_tapstream_all_pass(tapir)
test_parse_tapstream_all_fail(tapir)
test_parse_tapstream_diagnostics(tapir)
test_parse_tapstream_too_many_passing_tests(tapir)
test_parse_tapstream_not_enough_tests(tapir)
test_parse_tapstream_todo(tapir)
.end
.sub test_parse_tapstream_todo
.param pmc tapir
.local pmc stream
.local string tap
tap = <<"TAP"
1..3
ok 1 - Class of Tapir::Parser is of the correct type
ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
not ok 3 # TODO make lots of money
TAP
stream = tapir.'parse_tapstream'(tap)
$I0 = stream.'get_plan'()
is($I0,3,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,2,"parse_tapstream detects 2 passing tests")
$I0 = stream.'get_fail'()
is($I0,0,"parse_tapstream detects no failing test")
$I0 = stream.'get_todo'()
is($I0,1,"parse_tapstream detects one todo test")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream detects no skipped test")
$I0 = stream.'total'()
is($I0,3,"parse_tapstream detected 3 tests in total")
$I0 = stream.'is_pass'()
is($I0,1,"parse_tapstream will pass a TAP stream with todo tests")
.end
.sub test_parse_tapstream_not_enough_tests
.param pmc tapir
.local pmc stream
.local string tap
tap = <<"TAP"
1..5
ok 1 - Class of Tapir::Parser is of the correct type
ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
TAP
stream = tapir.'parse_tapstream'(tap)
$I0 = stream.'get_plan'()
is($I0,5,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,2,"parse_tapstream detects 2 passing tests")
$I0 = stream.'get_fail'()
is($I0,0,"parse_tapstream detects a failing test")
$I0 = stream.'get_todo'()
is($I0,0,"parse_tapstream detects no todo test")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream detects no skipped test")
$I0 = stream.'total'()
is($I0,2,"parse_tapstream detected 2 tests in total")
$I0 = stream.'is_pass'()
is($I0,0,"parse_tapstream does not pass a TAP stream with not enough tests")
.end
.sub test_parse_tapstream_too_many_passing_tests
.param pmc tapir
.local pmc stream
.local string tap
tap = <<"TAP"
1..2
ok 1 - Class of Tapir::Parser is of the correct type
ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
ok 3
TAP
stream = tapir.'parse_tapstream'(tap)
$I0 = stream.'get_plan'()
is($I0,2,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,3,"parse_tapstream detects a passing test")
$I0 = stream.'get_fail'()
is($I0,0,"parse_tapstream detects a failing test")
$I0 = stream.'get_todo'()
is($I0,0,"parse_tapstream detects no todo test")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream detects no skipped test")
$I0 = stream.'total'()
is($I0,3,"parse_tapstream detected 2 tests in total")
$I0 = stream.'is_pass'()
is($I0,0,"parse_tapstream does not pass a TAP stream with too many tests")
.end
.sub test_is_pass
.param pmc tapir
.local pmc stream
$S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'is_pass'()
is($I0,1,"is_pass correctly detects 2 passing tests")
$S0 = "1..3\nok 1 - i like cheese\nok 2 - foobar\nnot ok 3 - blammo!\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'is_pass'()
is($I0,0,"is_pass correctly detected 1 failing test")
$S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\nok 3 - blammo!\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'is_pass'()
is($I0,0,"is_pass correctly detects that too many tests have run")
$S0 = "1..4\nok 1 - i like cheese\nok 2 - foobar\nok 3 - blammo!\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'is_pass'()
is($I0,0,"is_pass correctly detects that too few tests have run")
.end
.sub test_parse_tapstream_diagnostics
.param pmc tapir
.local pmc stream
$S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'get_plan'()
is($I0,2,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,2,"parse_tapstream detects a passing test with diag")
$I0 = stream.'get_fail'()
is($I0,0,"parse_tapstream detects no failing test")
$S0 = "1..2\nnot ok 1 - i like cheese\nnot ok 2 - foobar\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'get_plan'()
is($I0,2,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,0,"parse_tapstream detects no passing tests with diag")
$I0 = stream.'get_fail'()
is($I0,2,"parse_tapstream detects 2 failing tests with diag")
$I0 = stream.'total'()
is($I0,2,"parse_tapstream detected 2 tests in total")
.end
.sub test_parse_tapstream_all_pass
.param pmc tapir
.local pmc stream
$S0 = "1..2\nok 1\nok 2\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'get_plan'()
is($I0,2,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,2,"parse_tapstream detects a passing test")
$I0 = stream.'get_fail'()
is($I0,0,"parse_tapstream detects a failing test")
$I0 = stream.'get_todo'()
is($I0,0,"parse_tapstream detects no todo test")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream detects no skipped test")
$I0 = stream.'total'()
is($I0,2,"parse_tapstream detected 2 tests in total")
.end
.sub test_parse_tapstream_all_fail
.param pmc tapir
.local pmc stream
$S0 = "1..2\nnot ok 1\nnot ok 2\n"
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'get_plan'()
is($I0,2,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,0,"parse_tapstream detects no passing tests")
$I0 = stream.'get_fail'()
is($I0,2,"parse_tapstream detects 2 failing tests")
$I0 = stream.'get_todo'()
is($I0,0,"parse_tapstream detects no todo test")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream detects no skipped test")
$I0 = stream.'total'()
is($I0,2,"parse_tapstream detected 2 tests in total")
.end
.sub test_parse_tapstream_simple
.param pmc tapir
.local pmc stream
$S0 = "1..2\nok 1\nnot ok 2\n"
stream = tapir.'parse_tapstream'($S0)
$S1 = typeof stream
is($S1,"Tapir;Stream","parse_tapstream returns a Tapir;Stream object")
$I0 = stream.'get_plan'()
is($I0,2,"parse_tapstream detects the plan correctly")
$I0 = stream.'get_pass'()
is($I0,1,"parse_tapstream detects a passing test")
$I0 = stream.'get_fail'()
is($I0,1,"parse_tapstream detects a failing test")
$I0 = stream.'get_todo'()
is($I0,0,"parse_tapstream detects no todo test")
$I0 = stream.'get_skip'()
is($I0,0,"parse_tapstream detects no skipped test")
$I0 = stream.'total'()
is($I0,2,"parse_tapstream detected 2 tests in total")
.end
.sub test_really_simple
.param pmc tapir
.local pmc stream
$S0 = <<"TAP"
1..1
ok 1 - parse_tapstream does not pass a dead test
TAP
stream = tapir.'parse_tapstream'($S0)
$I0 = stream.'is_pass'()
is($I0,1,"a single passed test with diagnostic works")
.end