5 .include 'test_more.pir'
6 .local pmc tapir, klass
7 load_bytecode 'lib/Tapir/Parser.pbc'
8 load_bytecode 'lib/Tapir/Stream.pbc'
13 klass = newclass [ 'Tapir'; 'Parser' ]
18 test_really_simple(tapir)
19 test_parse_tapstream_simple(tapir)
20 test_parse_tapstream_all_pass(tapir)
21 test_parse_tapstream_all_fail(tapir)
22 test_parse_tapstream_diagnostics(tapir)
23 test_parse_tapstream_too_many_passing_tests(tapir)
24 test_parse_tapstream_not_enough_tests(tapir)
25 test_parse_tapstream_todo(tapir)
26 test_parse_tapstream_skip(tapir)
27 test_parse_tapstream_bail(tapir)
28 test_parse_tapstream_correct_number_of_failed(tapir)
32 .sub test_parse_tapstream_correct_number_of_failed
48 # Looks like you failed 2 tests of 3
50 stream = tapir.'parse_tapstream'(tap)
52 $I0 = stream.'get_plan'()
53 is($I0,3,"parse_tapstream detects the plan correctly")
55 $I0 = stream.'get_pass'()
56 is($I0,1,"parse_tapstream detects 1 passing test")
58 $I0 = stream.'get_fail'()
59 is($I0,2,"parse_tapstream detects 2 failing tests")
61 $I0 = stream.'get_todo'()
62 is($I0,0,"parse_tapstream detects no todo tests")
64 $I0 = stream.'get_skip'()
65 is($I0,0,"parse_tapstream detects two skipped test")
67 $I0 = stream.'total'()
68 is($I0,3,"parse_tapstream detected 3 tests in total")
70 $I0 = stream.'is_pass'()
71 is($I0,0,"parse_tapstream fails this")
74 .sub test_parse_tapstream_bail
80 ok 1 - Testing some stuff
82 ok 2 - This test is never run
84 stream = tapir.'parse_tapstream'(tap)
85 $I0 = stream.'get_pass'()
86 is($I0,1,'parse_tapstream bails out properly')
88 $I0 = stream.'get_fail'()
89 is($I0,0,'parse_tapstream gets the right number of fails when bailing')
92 .sub test_parse_tapstream_skip
98 ok 1 - Testing some stuff
99 ok 2 # skip some great reason
100 ok 3 # SKIP another great reason
102 stream = tapir.'parse_tapstream'(tap)
104 $I0 = stream.'get_plan'()
105 is($I0,3,"parse_tapstream detects the plan correctly")
107 $I0 = stream.'get_pass'()
108 is($I0,1,"parse_tapstream detects 1 passing test")
110 $I0 = stream.'get_fail'()
111 is($I0,0,"parse_tapstream detects no failing test")
113 $I0 = stream.'get_todo'()
114 is($I0,0,"parse_tapstream detects no todo tests")
116 $I0 = stream.'get_skip'()
117 is($I0,2,"parse_tapstream detects two skipped test")
119 $I0 = stream.'total'()
120 is($I0,3,"parse_tapstream detected 3 tests in total")
122 $I0 = stream.'is_pass'()
123 is($I0,1,"parse_tapstream will pass a TAP stream with todo tests")
127 .sub test_parse_tapstream_todo
133 ok 1 - Class of Tapir::Parser is of the correct type
134 ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
135 not ok 3 # TODO make lots of money
137 stream = tapir.'parse_tapstream'(tap)
139 $I0 = stream.'get_plan'()
140 is($I0,3,"parse_tapstream detects the plan correctly")
142 $I0 = stream.'get_pass'()
143 is($I0,2,"parse_tapstream detects 2 passing tests")
145 $I0 = stream.'get_fail'()
146 is($I0,0,"parse_tapstream detects no failing test")
148 $I0 = stream.'get_todo'()
149 is($I0,1,"parse_tapstream detects one todo test")
151 $I0 = stream.'get_skip'()
152 is($I0,0,"parse_tapstream detects no skipped test")
154 $I0 = stream.'total'()
155 is($I0,3,"parse_tapstream detected 3 tests in total")
157 $I0 = stream.'is_pass'()
158 is($I0,1,"parse_tapstream will pass a TAP stream with todo tests")
162 .sub test_parse_tapstream_not_enough_tests
168 ok 1 - Class of Tapir::Parser is of the correct type
169 ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
171 stream = tapir.'parse_tapstream'(tap)
173 $I0 = stream.'get_plan'()
174 is($I0,5,"parse_tapstream detects the plan correctly")
176 $I0 = stream.'get_pass'()
177 is($I0,2,"parse_tapstream detects 2 passing tests")
179 $I0 = stream.'get_fail'()
180 is($I0,0,"parse_tapstream detects a failing test")
182 $I0 = stream.'get_todo'()
183 is($I0,0,"parse_tapstream detects no todo test")
185 $I0 = stream.'get_skip'()
186 is($I0,0,"parse_tapstream detects no skipped test")
188 $I0 = stream.'total'()
189 is($I0,2,"parse_tapstream detected 2 tests in total")
191 $I0 = stream.'is_pass'()
192 is($I0,0,"parse_tapstream does not pass a TAP stream with not enough tests")
195 .sub test_parse_tapstream_too_many_passing_tests
201 ok 1 - Class of Tapir::Parser is of the correct type
202 ok 2 - new returns a Tapir::Parser object isa Tapir;Parser
205 stream = tapir.'parse_tapstream'(tap)
207 $I0 = stream.'get_plan'()
208 is($I0,2,"parse_tapstream detects the plan correctly")
210 $I0 = stream.'get_pass'()
211 is($I0,3,"parse_tapstream detects a passing test")
213 $I0 = stream.'get_fail'()
214 is($I0,0,"parse_tapstream detects a failing test")
216 $I0 = stream.'get_todo'()
217 is($I0,0,"parse_tapstream detects no todo test")
219 $I0 = stream.'get_skip'()
220 is($I0,0,"parse_tapstream detects no skipped test")
222 $I0 = stream.'total'()
223 is($I0,3,"parse_tapstream detected 2 tests in total")
225 $I0 = stream.'is_pass'()
226 is($I0,0,"parse_tapstream does not pass a TAP stream with too many tests")
232 $S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\n"
233 stream = tapir.'parse_tapstream'($S0)
234 $I0 = stream.'is_pass'()
235 is($I0,1,"is_pass correctly detects 2 passing tests")
237 $S0 = "1..3\nok 1 - i like cheese\nok 2 - foobar\nnot ok 3 - blammo!\n"
238 stream = tapir.'parse_tapstream'($S0)
239 $I0 = stream.'is_pass'()
240 is($I0,0,"is_pass correctly detected 1 failing test")
242 $S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\nok 3 - blammo!\n"
243 stream = tapir.'parse_tapstream'($S0)
244 $I0 = stream.'is_pass'()
245 is($I0,0,"is_pass correctly detects that too many tests have run")
247 $S0 = "1..4\nok 1 - i like cheese\nok 2 - foobar\nok 3 - blammo!\n"
248 stream = tapir.'parse_tapstream'($S0)
249 $I0 = stream.'is_pass'()
250 is($I0,0,"is_pass correctly detects that too few tests have run")
253 .sub test_parse_tapstream_diagnostics
256 $S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\n"
257 stream = tapir.'parse_tapstream'($S0)
258 $I0 = stream.'get_plan'()
259 is($I0,2,"parse_tapstream detects the plan correctly")
261 $I0 = stream.'get_pass'()
262 is($I0,2,"parse_tapstream detects a passing test with diag")
264 $I0 = stream.'get_fail'()
265 is($I0,0,"parse_tapstream detects no failing test")
267 $S0 = "1..2\nnot ok 1 - i like cheese\nnot ok 2 - foobar\n"
268 stream = tapir.'parse_tapstream'($S0)
269 $I0 = stream.'get_plan'()
270 is($I0,2,"parse_tapstream detects the plan correctly")
272 $I0 = stream.'get_pass'()
273 is($I0,0,"parse_tapstream detects no passing tests with diag")
275 $I0 = stream.'get_fail'()
276 is($I0,2,"parse_tapstream detects 2 failing tests with diag")
278 $I0 = stream.'total'()
279 is($I0,2,"parse_tapstream detected 2 tests in total")
282 .sub test_parse_tapstream_all_pass
285 $S0 = "1..2\nok 1\nok 2\n"
286 stream = tapir.'parse_tapstream'($S0)
288 $I0 = stream.'get_plan'()
289 is($I0,2,"parse_tapstream detects the plan correctly")
291 $I0 = stream.'get_pass'()
292 is($I0,2,"parse_tapstream detects a passing test")
294 $I0 = stream.'get_fail'()
295 is($I0,0,"parse_tapstream detects a failing test")
297 $I0 = stream.'get_todo'()
298 is($I0,0,"parse_tapstream detects no todo test")
300 $I0 = stream.'get_skip'()
301 is($I0,0,"parse_tapstream detects no skipped test")
303 $I0 = stream.'total'()
304 is($I0,2,"parse_tapstream detected 2 tests in total")
307 .sub test_parse_tapstream_all_fail
310 $S0 = "1..2\nnot ok 1\nnot ok 2\n"
311 stream = tapir.'parse_tapstream'($S0)
313 $I0 = stream.'get_plan'()
314 is($I0,2,"parse_tapstream detects the plan correctly")
316 $I0 = stream.'get_pass'()
317 is($I0,0,"parse_tapstream detects no passing tests")
319 $I0 = stream.'get_fail'()
320 is($I0,2,"parse_tapstream detects 2 failing tests")
322 $I0 = stream.'get_todo'()
323 is($I0,0,"parse_tapstream detects no todo test")
325 $I0 = stream.'get_skip'()
326 is($I0,0,"parse_tapstream detects no skipped test")
328 $I0 = stream.'total'()
329 is($I0,2,"parse_tapstream detected 2 tests in total")
332 .sub test_parse_tapstream_simple
335 $S0 = "1..2\nok 1\nnot ok 2\n"
336 stream = tapir.'parse_tapstream'($S0)
338 is($S1,"Tapir;Stream","parse_tapstream returns a Tapir;Stream object")
340 $I0 = stream.'get_plan'()
341 is($I0,2,"parse_tapstream detects the plan correctly")
343 $I0 = stream.'get_pass'()
344 is($I0,1,"parse_tapstream detects a passing test")
346 $I0 = stream.'get_fail'()
347 is($I0,1,"parse_tapstream detects a failing test")
349 $I0 = stream.'get_todo'()
350 is($I0,0,"parse_tapstream detects no todo test")
352 $I0 = stream.'get_skip'()
353 is($I0,0,"parse_tapstream detects no skipped test")
355 $I0 = stream.'total'()
356 is($I0,2,"parse_tapstream detected 2 tests in total")
359 .sub test_really_simple
364 ok 1 - parse_tapstream does not pass a dead test
366 stream = tapir.'parse_tapstream'($S0)
367 $I0 = stream.'is_pass'()
368 is($I0,1,"a single passed test with diagnostic works")