@@ -121,15 +121,15 @@ project's base directory.
121
121
A typical test file looks something like this:
122
122
123
123
= begin code :skip-test
124
- use v6.c;
125
- use Test; # a Standard module included with Rakudo
126
- use lib 'lib';
124
+ use v6.c;
125
+ use Test; # a Standard module included with Rakudo
126
+ use lib 'lib';
127
127
128
- plan $num-tests;
128
+ plan $num-tests;
129
129
130
- # .... tests
130
+ # .... tests
131
131
132
- done-testing; # optional with 'plan'
132
+ done-testing; # optional with 'plan'
133
133
= end code
134
134
135
135
We ensure that we're using Perl 6, via the C < use v6.c > pragma, then we load
@@ -156,19 +156,19 @@ Tests can be run individually by specifying the test filename on the
156
156
command line:
157
157
158
158
= for code :lang<shell>
159
- $ perl6 t/test-filename.t
159
+ $ perl6 t/test-filename.t
160
160
161
161
Or via the L < prove|http://perldoc.perl.org/prove.html > command from Perl 5,
162
162
where C < perl6 > is specified as the executable that runs the tests:
163
163
164
164
= for code :lang<shell>
165
- $ prove --exec perl6 -r t
165
+ $ prove --exec perl6 -r t
166
166
167
167
To abort the test suite upon first failure, set the
168
168
C < PERL6_TEST_DIE_ON_FAIL > environmental variable:
169
169
170
170
= for code :lang<shell>
171
- $ PERL6_TEST_DIE_ON_FAIL=1 perl6 t/test-filename.t
171
+ $ PERL6_TEST_DIE_ON_FAIL=1 perl6 t/test-filename.t
172
172
173
173
The same variable can be used within the test file. Set it before loading
174
174
the C < Test > module:
@@ -404,7 +404,7 @@ and the test will fail if C<rel-diff> is higher than C<$rel-tol>.
404
404
= head3 Both Absolute and Relative Tolerance Specified
405
405
406
406
= for code :skip-test
407
- is-approx $value, $expected, :rel-tol<.5>, :abs-tol<10>;
407
+ is-approx $value, $expected, :rel-tol<.5>, :abs-tol<10>;
408
408
409
409
When both absolute and relative tolerances are specified, each will be
410
410
tested independently, and the C < is-approx > test will succeed only if both pass.
@@ -704,12 +704,12 @@ only one test will be marked TODO.
704
704
The result from the test code above will be something like:
705
705
706
706
= begin code :lang<TAP>
707
- not ok 1 - my-custom-pi# TODO not yet precise enough
707
+ not ok 1 - my-custom-pi# TODO not yet precise enough
708
708
709
- # Failed test 'my-custom-pi'
710
- # at test-todo.t line 7
711
- # expected: '3.14159265358979'
712
- # got: '3'
709
+ # Failed test 'my-custom-pi'
710
+ # at test-todo.t line 7
711
+ # expected: '3.14159265358979'
712
+ # got: '3'
713
713
= end code
714
714
715
715
Note that if you C < todo > a C < subtest > , all of the failing tests inside of it will be
@@ -770,9 +770,9 @@ If you already know the tests will fail, you can bail out of the test run
770
770
using C < bail-out() > :
771
771
772
772
= begin code
773
- my $has-db-connection;
774
- ...
775
- $has-db-connection or bail-out 'Must have database connection for testing';
773
+ my $has-db-connection;
774
+ ...
775
+ $has-db-connection or bail-out 'Must have database connection for testing';
776
776
= end code
777
777
778
778
The function aborts the current test run, signaling failure to the harness.
0 commit comments