Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 159 lines (121 sloc) 4.001 kb
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
1 use v6;
2 use Test;
3 # plan *; # This does not test having a real plan.
4
5 pass( 'pass($desc)' );
6
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
7 my $ok1 = ok 1, 'ok with description';
8 ok $ok1, 'ok returns True';
9 my $ok2 = ok 1;
10 ok $ok2, 'ok returns True';
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
11
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
12 # NOT_TODO
13 # next is TODO only so our test script won't fail
14 # we are only testing the return value of &ok
15 todo( 'testing failure' );
16 my $ok3 = ok False, 'calling ok False';
17 nok $ok3, 'failure returns False';
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
18
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
19
20 my $nok1 = nok 0, 'nok with description';
21 ok $nok1, 'nok 0 returns True';
22 my $nok2 = nok 0;
23 ok $nok2, 'nok 0 returns True';
24
25 # NOT_TODO
26 todo( 'tesing nok True' );
27 my $nok3 = nok 1, 'nok 1 with description';
28 nok $nok3, 'nok 1 returns False';
29
30
31 my $is1 = is 1, 1, 'is with description';
32 ok $is1, 'is returns True';
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
33 is 1, 1;
34
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
35 # NOT_TODO
36 todo( 'failing is' );
37 my $is3 = is 1, 0, 'is 1, 0; with description';
38 nok $is3, 'is 1, 0; returns False';
39
40
41 my $isnt1 = isnt 1, 0, 'isnt with description';
42 ok $isnt1, 'isnt 1, 0; returns True';
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
43 isnt 1, 0;
44
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
45 # NOT_TODO
46 todo( 'testing isnt 1,1' );
47 my $isnt3 = isnt 1, 1, 'isnt 1,1, with description';
48 nok $isnt3, 'isnt 1, 1; returns False';
49
50
51 my $approx1 = is_approx 1, 1, 'is_approx with description';
52 ok $approx1, 'is_approx 1,1, returns True';
53 my $approx2 = is_approx 1, 1;
54 my $approx3 = is_approx 1, 1.000001, 'is_approx with small difference';
55 ok $approx3, 'is_approx 1,1.000001, returns True';
56
57 # NOT_TODO
58 todo( 'failing is_approx 1,2;');
59 my $approx4 = is_approx 1, 2, 'is_approx with small difference';
60 nok $approx4, 'is_approx 1, 2; fails and returns False';
61
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
62
63 todo( 'testing todo twice', 2 );
64 ok 0, 'this should fail, to test todo()';
65 ok 0, 'this should also fail, to test todo()';
66 ok 1, 'passing test (todo is done)';
67
68 todo( 'todo with no count' );
69 ok 0, 'todo with no count covers one test';
70 ok 1, 'passing test (not todo)';
71
72 skip( 'skip with reason' );
73 skip;
12dfa0d @tadzik Fix tests of Test.pm to use the right order of arguments.
tadzik authored
74 skip( 'skip with count and reason', 2 );
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
75
76 # skip_rest();
77
78 diag( 'diag works, FYI' );
79
80 todo( 'testing flunk', 1 );
81 flunk( 'flunk' );
82
83 {
84 my $x = 3;
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
85 my $isa1 = isa_ok( $x, Int, 'isa_ok with message' );
86 ok $isa1, 'isa_ok returns True';
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
87 isa_ok( $x, Int );
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
88
89 # NOT_TODO
90 todo( 'failing isa_ok returns False' );
91 my $isa2 = isa_ok( 'abc', Int );
92 nok $isa2, 'Failing isa_ok returns False';
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
93 }
94
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
95 my $dies_ok1 = dies_ok { skip( 2, 'reason' ) },
12dfa0d @tadzik Fix tests of Test.pm to use the right order of arguments.
tadzik authored
96 'skip() dies when given the arguments in the wrong order';
4e07a76 @szabgab change most of the Test.pm functions to return their truth value and …
szabgab authored
97 ok $dies_ok1, 'dies_ok returns True';
98
99 # NOT_TODO
100 todo( 'failing dies_ok returns False' );
101 my $dies_ok2 = dies_ok { 1 }, 'dies_ok {1}';
102 nok $dies_ok2, 'dies_ok returns False if code did not die';
12dfa0d @tadzik Fix tests of Test.pm to use the right order of arguments.
tadzik authored
103
61807a6 @szabgab enable some commented out sanity test
szabgab authored
104 dies_ok { die }, 'dies_ok';
105 dies_ok { die };
106
792c782 @szabgab fix the rest of the Test functions to return their truth and test them
szabgab authored
107 my $lives_ok1 = lives_ok { 1 }, 'lives_ok';
108 ok $lives_ok1, 'lives_ok returns True';
61807a6 @szabgab enable some commented out sanity test
szabgab authored
109 lives_ok { 1 };
110
792c782 @szabgab fix the rest of the Test functions to return their truth and test them
szabgab authored
111 # NOT_TODO
112 todo( 'failing lives_ok returns False' );
113 my $lives_ok2 = lives_ok { die }, 'lives_ok { die }';
114 nok $lives_ok2, 'failing lives_ok returns False';
115
116 my $ed_ok1 = eval_dies_ok 'die', 'eval_dies_ok';
117 ok $ed_ok1, 'eavl_dies_ok returns True';
61807a6 @szabgab enable some commented out sanity test
szabgab authored
118 eval_dies_ok 'die';
119
792c782 @szabgab fix the rest of the Test functions to return their truth and test them
szabgab authored
120 # NOT_TODO
121 todo( 'eval_dies_ok 1 returns False' );
122 my $ed_ok2 = eval_dies_ok '1', 'eval_dies_ok 1 fails';
123 nok $ed_ok2, 'eval_dies_ok 1 returns False';
124
125 my $el_ok1 = eval_lives_ok '1', 'eval_lives_ok';
126 ok $el_ok1, 'eval_lives_ok 1 returns True';
61807a6 @szabgab enable some commented out sanity test
szabgab authored
127 eval_lives_ok '1';
128
792c782 @szabgab fix the rest of the Test functions to return their truth and test them
szabgab authored
129 # NOT_TODO
130 todo( 'failing eval_lives_ok returns False' );
131 my $el_ok2 = eval_lives_ok 'die', 'lives_ok { die }';
132 nok $el_ok2, 'failing eval_lives_ok returns False';
133
61807a6 @szabgab enable some commented out sanity test
szabgab authored
134 {
135 my $deeply = {
136 list => (1, 2),
137 hash => { a => 1, b => 2 },
138 str => 'hello',
139 num => 1.2,
140 int => 33,
141 pair => :a(3),
142 # undef => undef,
143 bool => Bool::True,
144 array => [3, 4],
145 };
792c782 @szabgab fix the rest of the Test functions to return their truth and test them
szabgab authored
146 my $is_deeply = is_deeply $deeply, $deeply, 'is_deeply';
147 ok $is_deeply, 'is_deeply returns True';
61807a6 @szabgab enable some commented out sanity test
szabgab authored
148 is_deeply $deeply, $deeply;
149 }
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
150
792c782 @szabgab fix the rest of the Test functions to return their truth and test them
szabgab authored
151 # NOT_TODO
152 todo( 'failing is_deeply returns False' );
153 my $is_deeply = is_deeply {a => 1}, {}, 'is_deeply with exta key fails';
154 nok $is_deeply, 'failing is_deeply returns False';
155
d3688bb @moritz a forgotten done_testing. quihw++
moritz authored
156 done;
0256b44 @pmichaud Basic sanity tests for Test.pm .
pmichaud authored
157
158 # vim: ft=perl6
Something went wrong with that request. Please try again.