3 # .include 'lib/Tapir/Base.pir'
4 # load_bytecode 'PGE.pbc'
5 # load_bytecode 'Dumper.pbc'
6 .include 'lib/Tapir/Parser.pir'
7 .include 'lib/Tapir/Stream.pir'
11 .include 'test_more.pir'
12 .local pmc tapir, klass
17 klass = newclass [ 'Tapir'; 'Parser' ]
21 test_parse_plan(tapir)
23 test_parse_tapstream_simple(tapir)
24 test_parse_tapstream_all_pass(tapir)
25 test_parse_tapstream_all_fail(tapir)
26 test_parse_tapstream_diagnostics(tapir)
32 $S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\n"
33 stream = tapir.'parse_tapstream'($S0)
34 $I0 = stream.'is_pass'()
35 is($I0,1,"is_pass correctly detects 2 passing tests")
37 $S0 = "1..3\nok 1 - i like cheese\nok 2 - foobar\nnot ok 3 - blammo!\n"
38 stream = tapir.'parse_tapstream'($S0)
39 $I0 = stream.'is_pass'()
40 is($I0,0,"is_pass correctly detected 1 failing test")
42 $S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\nok 3 - blammo!\n"
43 stream = tapir.'parse_tapstream'($S0)
44 $I0 = stream.'is_pass'()
45 is($I0,0,"is_pass correctly detects that too many tests have run")
47 $S0 = "1..4\nok 1 - i like cheese\nok 2 - foobar\nok 3 - blammo!\n"
48 stream = tapir.'parse_tapstream'($S0)
49 $I0 = stream.'is_pass'()
50 is($I0,0,"is_pass correctly detects that too few tests have run")
53 .sub test_parse_tapstream_diagnostics
56 $S0 = "1..2\nok 1 - i like cheese\nok 2 - foobar\n"
57 stream = tapir.'parse_tapstream'($S0)
58 $I0 = stream.'get_plan'()
59 is($I0,2,"parse_tapstream detects the plan correctly")
61 $I0 = stream.'get_pass'()
62 is($I0,2,"parse_tapstream detects a passing test with diag")
64 $I0 = stream.'get_fail'()
65 is($I0,0,"parse_tapstream detects no failing test")
67 $S0 = "1..2\nnot ok 1 - i like cheese\nnot ok 2 - foobar\n"
68 stream = tapir.'parse_tapstream'($S0)
69 $I0 = stream.'get_plan'()
70 is($I0,2,"parse_tapstream detects the plan correctly")
72 $I0 = stream.'get_pass'()
73 is($I0,0,"parse_tapstream detects no passing tests with diag")
75 $I0 = stream.'get_fail'()
76 is($I0,2,"parse_tapstream detects 2 failing tests with diag")
78 $I0 = stream.'total'()
79 is($I0,2,"parse_tapstream detected 2 tests in total")
82 .sub test_parse_tapstream_all_pass
85 $S0 = "1..2\nok 1\nok 2\n"
86 stream = tapir.'parse_tapstream'($S0)
88 $I0 = stream.'get_plan'()
89 is($I0,2,"parse_tapstream detects the plan correctly")
91 $I0 = stream.'get_pass'()
92 is($I0,2,"parse_tapstream detects a passing test")
94 $I0 = stream.'get_fail'()
95 is($I0,0,"parse_tapstream detects a failing test")
97 $I0 = stream.'get_todo'()
98 is($I0,0,"parse_tapstream detects no todo test")
100 $I0 = stream.'get_skip'()
101 is($I0,0,"parse_tapstream detects no skipped test")
103 $I0 = stream.'total'()
104 is($I0,2,"parse_tapstream detected 2 tests in total")
107 .sub test_parse_tapstream_all_fail
110 $S0 = "1..2\nnot ok 1\nnot ok 2\n"
111 stream = tapir.'parse_tapstream'($S0)
113 $I0 = stream.'get_plan'()
114 is($I0,2,"parse_tapstream detects the plan correctly")
116 $I0 = stream.'get_pass'()
117 is($I0,0,"parse_tapstream detects no passing tests")
119 $I0 = stream.'get_fail'()
120 is($I0,2,"parse_tapstream detects 2 failing tests")
122 $I0 = stream.'get_todo'()
123 is($I0,0,"parse_tapstream detects no todo test")
125 $I0 = stream.'get_skip'()
126 is($I0,0,"parse_tapstream detects no skipped test")
128 $I0 = stream.'total'()
129 is($I0,2,"parse_tapstream detected 2 tests in total")
132 .sub test_parse_tapstream_simple
135 $S0 = "1..2\nok 1\nnot ok 2\n"
136 stream = tapir.'parse_tapstream'($S0)
138 is($S1,"Tapir;Stream","parse_tapstream returns a Tapir;Stream object")
140 $I0 = stream.'get_plan'()
141 is($I0,2,"parse_tapstream detects the plan correctly")
143 $I0 = stream.'get_pass'()
144 is($I0,1,"parse_tapstream detects a passing test")
146 $I0 = stream.'get_fail'()
147 is($I0,1,"parse_tapstream detects a failing test")
149 $I0 = stream.'get_todo'()
150 is($I0,0,"parse_tapstream detects no todo test")
152 $I0 = stream.'get_skip'()
153 is($I0,0,"parse_tapstream detects no skipped test")
155 $I0 = stream.'total'()
156 is($I0,2,"parse_tapstream detected 2 tests in total")
163 $S0 = "1..5\nCauchy Residue Theorem!"
164 num_tests = tapir.'parse_plan'($S0)
165 is(num_tests,5,'parse_plan can parse a simple plan')
167 $S0 = "1..1\nCauchy Residue Theorem!"
168 num_tests = tapir.'parse_plan'($S0)
169 is(num_tests,1,'parse_plan can parse a single test plan')
171 $S0 = "1..0\nCauchy Residue Theorem!"
172 num_tests = tapir.'parse_plan'($S0)
173 is(num_tests,0,'parse_plan can parse a no-test plan')
181 # vim: expandtab shiftwidth=4 ft=pir: