]> begriffs open source - libtap/blob - t/tap.t
make tap work on freebsd
[libtap] / t / tap.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use Test::More tests => 9;
5 use Test::Differences;
6
7 my $x = $^O eq 'MSWin32' ? ".exe" : "";
8
9 eq_or_diff ~~`t/cmpok$x 2>&1`, <<'END', "cmp_ok";
10 1..9
11 not ok 1
12 #   Failed test at t/cmpok.c line 6.
13 #     420
14 #         >
15 #     666
16 not ok 2 - the number 23 is definitely 55
17 #   Failed test 'the number 23 is definitely 55'
18 #   at t/cmpok.c line 7.
19 #     23
20 #         ==
21 #     55
22 not ok 3
23 #   Failed test at t/cmpok.c line 8.
24 #     23
25 #         ==
26 #     55
27 ok 4
28 # unrecognized operator 'frob'
29 not ok 5
30 #   Failed test at t/cmpok.c line 10.
31 #     23
32 #         frob
33 #     55
34 ok 6
35 not ok 7
36 #   Failed test at t/cmpok.c line 12.
37 #     55
38 #         +
39 #     -55
40 ok 8
41 not ok 9
42 #   Failed test at t/cmpok.c line 14.
43 #     55
44 #         %
45 #     5
46 # Looks like you failed 6 tests of 9 run.
47 END
48
49 eq_or_diff ~~`t/diesok$x 2>&1`, <<'END', "dies_ok";
50 1..5
51 ok 1 - sanity
52 ok 2 - can't divide by zero
53 ok 3 - this is a perfectly fine statement
54 ok 4 - abort kills the program
55 ok 5 - supress output
56 END
57
58 eq_or_diff ~~`t/is$x 2>&1`, <<'END', "is";
59 1..18
60 not ok 1 - this is that
61 #   Failed test 'this is that'
62 #   at t/is.c line 6.
63 #          got: 'this'
64 #     expected: 'that'
65 ok 2 - this is this
66 not ok 3
67 #   Failed test at t/is.c line 8.
68 #          got: 'this'
69 #     expected: 'that'
70 ok 4
71 ok 5 - null is null
72 not ok 6 - null is this
73 #   Failed test 'null is this'
74 #   at t/is.c line 11.
75 #          got: '(null)'
76 #     expected: 'this'
77 not ok 7 - this is null
78 #   Failed test 'this is null'
79 #   at t/is.c line 12.
80 #          got: 'this'
81 #     expected: '(null)'
82 not ok 8
83 #   Failed test at t/is.c line 13.
84 #          got: 'foo
85 # foo
86 # foo'
87 #     expected: 'bar
88 # bar
89 # bar'
90 ok 9
91 ok 10 - this isnt that
92 not ok 11 - this isnt this
93 #   Failed test 'this isnt this'
94 #   at t/is.c line 16.
95 #          got: 'this'
96 #     expected: anything else
97 ok 12
98 not ok 13
99 #   Failed test at t/is.c line 18.
100 #          got: 'this'
101 #     expected: anything else
102 not ok 14 - null isnt null
103 #   Failed test 'null isnt null'
104 #   at t/is.c line 19.
105 #          got: '(null)'
106 #     expected: anything else
107 ok 15 - null isnt this
108 ok 16 - this isnt null
109 ok 17
110 not ok 18
111 #   Failed test at t/is.c line 23.
112 #          got: 'foo
113 # foo
114 # foo'
115 #     expected: anything else
116 # Looks like you failed 9 tests of 18 run.
117 END
118
119 eq_or_diff ~~`t/like$x 2>&1`, <<'END', "like";
120 1..3
121 ok 1 - strange ~~ /range/
122 ok 2 - strange !~~ /anger/
123 ok 3 - matches the regex
124 END
125
126 eq_or_diff ~~`t/notediag$x 2>&1`, <<'END', "note and diag";
127 # note no new line
128 # note new line
129 # diag no new line
130 # diag new line
131 END
132
133 eq_or_diff ~~`t/simple$x 2>&1`, <<'END', "simple";
134 1..24
135 ok 1
136 ok 2
137 ok 3
138 not ok 4
139 #   Failed test at t/simple.c line 9.
140 ok 5 - foo
141 ok 6 - bar
142 ok 7 - baz
143 ok 8 - quux
144 ok 9 - thud
145 ok 10 - wombat
146 ok 11 - blurgle
147 ok 12 - frob
148 not ok 13 - frobnicate
149 #   Failed test 'frobnicate'
150 #   at t/simple.c line 18.
151 ok 14 - eek
152 ok 15 - ook
153 ok 16 - frodo
154 ok 17 - bilbo
155 ok 18 - wubble
156 ok 19 - flarp
157 ok 20 - fnord
158 ok 21
159 not ok 22
160 #   Failed test at t/simple.c line 27.
161 ok 23 - good
162 not ok 24 - bad
163 #   Failed test 'bad'
164 #   at t/simple.c line 29.
165 # Looks like you failed 4 tests of 24 run.
166 END
167
168 eq_or_diff ~~`t/skip$x 2>&1`, <<'END', "skip";
169 1..8
170 ok 1 - quux
171 ok 2 - thud
172 ok 3 - wombat
173 ok 4 # skip need to be on windows
174 ok 5 - quux
175 ok 6 - thud
176 ok 7 - wombat
177 ok 8 # skip 
178 END
179
180 eq_or_diff ~~`t/synopsis$x 2>&1`, <<'END', "synopsis";
181 1..5
182 ok 1
183 not ok 2
184 #   Failed test at t/synopsis.c line 10.
185 #          got: 'fnord'
186 #     expected: 'eek'
187 ok 3 - foo <= 8732
188 ok 4 - is like
189 not ok 5 - foo is greater than ten
190 #   Failed test 'foo is greater than ten'
191 #   at t/synopsis.c line 13.
192 #     3
193 #         >=
194 #     10
195 # Looks like you failed 2 tests of 5 run.
196 END
197
198 eq_or_diff ~~`t/todo$x 2>&1`, <<'END', "todo";
199 1..6
200 not ok 1 - foo # TODO
201 #   Failed (TODO) test 'foo'
202 #   at t/todo.c line 7.
203 ok 2 - bar # TODO
204 ok 3 - baz # TODO
205 not ok 4 - quux # TODO im not ready
206 #   Failed (TODO) test 'quux'
207 #   at t/todo.c line 12.
208 ok 5 - thud # TODO im not ready
209 ok 6 - wombat # TODO im not ready
210 END
211