/
01-parse_plan.t
executable file
·72 lines (50 loc) · 1.9 KB
/
01-parse_plan.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
#!/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(11)
# setup test data
klass = newclass [ 'Tapir'; 'Parser' ]
tapir = klass.'new'()
# run tests
test_parse_plan(tapir)
test_parse_invalid_plan(tapir)
.end
.sub test_parse_plan
.param pmc tapir
.local int num_tests
num_tests = tapir.'parse_plan'("1..5")
is(num_tests,5,'parse_plan can parse a simple plan')
num_tests = tapir.'parse_plan'("1..1")
is(num_tests,1,'parse_plan can parse a single test plan')
num_tests = tapir.'parse_plan'("1..0")
is(num_tests,0,'parse_plan can parse a no-test plan')
.end
.sub test_parse_invalid_plan
.param pmc tapir
.local int num_tests
# these are not valid and should cause an "invalid plan" error
num_tests = tapir.'parse_plan'("-42..0")
is(num_tests,-1,'parse_plan indicates an invalid plan for -42..0')
num_tests = tapir.'parse_plan'("-42..42")
is(num_tests,-1,'parse_plan indicates an invalid plan for -42..42')
num_tests = tapir.'parse_plan'("0..1")
is(num_tests,-1,'parse_plan indicates an invalid plan for 0..1')
num_tests = tapir.'parse_plan'("1...69")
is(num_tests,-1,'parse_plan indicates an invalid plan for 1...69')
num_tests = tapir.'parse_plan'("1..")
is(num_tests,-1,'parse_plan indicates an invalid plan for 1..')
num_tests = tapir.'parse_plan'("1.2..69")
is(num_tests,-1,'parse_plan indicates an invalid plan for 1.2..69')
num_tests = tapir.'parse_plan'("This is not even close to a valid plan!")
is(num_tests,-1,'parse_plan indicates an invalid plan for junk')
num_tests = tapir.'parse_plan'("....2")
is(num_tests,-1,'parse_plan indicates an invalid plan for ....2')
.end
# Local Variables:
# mode: pir
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4 ft=pir: