Lines Matching defs:ok

28 @EXPORT    = qw(&plan &ok &skip);
58 ok(0); # failure
59 ok(1); # success
61 ok(0); # ok, expected failure (see todo list, above)
62 ok(1); # surprise success!
64 ok(0,1); # failure: '0' ne '1'
65 ok('broke','fixed'); # failure: 'broke' ne 'fixed'
66 ok('fixed','fixed'); # success: 'fixed' eq 'fixed'
67 ok('fixed',qr/x/); # success: 'fixed' =~ qr/x/
69 ok(sub { 1+1 }, 2); # success: '2' eq '2'
70 ok(sub { 1+1 }, 3); # failure: '2' ne '3'
73 ok @list, 3, "\@list=".join(',',@list); #extra notes
74 ok 'segmentation fault', '/(?i)success/'; #regex match
78 $foo, $bar # arguments just like for ok(...)
82 $foo, $bar # arguments just like for ok(...)
101 This module defines three public functions, C<plan(...)>, C<ok(...)>,
127 This means all ok() and skip() calls.
220 Converts an C<ok> parameter to its value. Typically this just means
233 =item C<ok(...)>
235 ok(1 + 1 == 2);
236 ok($have, $expect);
237 ok($have, $expect, $diagnostics);
241 handles printing "C<ok>" or "C<not ok>", along with the
244 In its most basic usage, C<ok(...)> simply takes a single scalar
248 # Examples of ok(scalar)
250 ok( 1 + 1 == 2 ); # ok if 1 + 1 == 2
251 ok( $foo =~ /bar/ ); # ok if $foo contains 'bar'
252 ok( baz($x + $y) eq 'Armondo' ); # ok if baz($x + $y) returns
254 ok( @a == @b ); # ok if @a and @b are the same length
259 ok( @stuff ); # ok if @stuff has any elements
260 ok( !grep !defined $_, @stuff ); # ok if everything in @stuff is
268 ok( sub { # See whether sleep works at least passably
274 In its two-argument form, C<ok(I<arg1>,I<arg2>)> compares the two scalar
277 # Example of ok(scalar, scalar)
279 ok( "this", "that" ); # not ok, 'this' ne 'that'
284 ok 4, sub {
294 The above test passes two values to C<ok(arg1, arg2)> -- the first is
295 the number 4, and the second is a coderef. Before C<ok> compares them,
297 this parameter. Assuming that C<$bytecount> returns 4, C<ok> ends up
302 C<ok(I<arg1>,I<arg2>)> will perform a pattern
305 ok( 'JaffO', '/Jaff/' ); # ok, 'JaffO' =~ /Jaff/
306 ok( 'JaffO', qr/Jaff/ ); # ok, 'JaffO' =~ qr/Jaff/;
307 ok( 'JaffO', '/(?i)jaff/ ); # ok, 'JaffO' =~ /jaff/i;
310 C<ok(I<arg1>,I<arg2>, I<note>)>, where I<note> is a string value that
315 ok( grep($_ eq 'something unique', @stuff), 1,
321 style of C<ok()>. That is, if you try C<ok(I<arg1>, I<note>)>, then
322 C<Test> will interpret this as C<ok(I<arg1>, I<arg2>)>, and probably
331 # <<ok(...)'s special handling of subroutine references is an unfortunate
335 sub ok ($;$$) {
336 croak "ok: plan before you test!" if !$planned;
349 my $ok=0;
353 $ok = $result;
358 $ok = !defined $result;
360 $ok = 0;
362 $ok = $result =~ /$expected/;
366 $ok = $result =~ /$regex/;
368 $ok = $result eq $expected;
372 if ($todo and $ok) {
374 print $TESTOUT "ok $ntest # ($context)\n";
377 if (!$ok) {
378 print $TESTOUT "not ok $ntest\n";
381 print $TESTOUT "ok $ntest\n";
384 if (!$ok) {
438 $ok;
447 ok(1);
449 ok( args... );
452 ...except that the C<ok(1)> emits not just "C<ok I<testnum>>" but
453 actually "C<ok I<testnum> # I<skip_if_true_value>>".
455 The arguments after the I<skip_if_true> are what is fed to C<ok(...)> if
487 bothering to treat them like values to C<ok(...)>. But if
509 ok(1); # but it actually appends "# $unless_MSWin"
513 ok( sub { thing($foo) }, sub { thing($bar) } );
529 my $ok = "ok $ntest # skip";
530 $ok .= " $whyskip" if length $whyskip;
531 $ok .= "\n";
532 print $TESTOUT $ok;
537 # called like ok(), which is weird. I haven't decided what to do with
545 return &ok(@_);
577 exactly the same way as C<ok(...)> does.
622 C<ok(...)>'s special handing of strings which look like they might be
625 ok( $fileglob, '/path/to/some/*stuff/' );
630 ok( $fileglob eq '/path/to/some/*stuff/' );
634 C<ok(...)>'s use of string C<eq> can sometimes cause odd problems
639 ok( $foo, 1 ); # not ok, "1.0" ne 1
643 ok( $foo == 1 ); # ok "1.0" == 1
648 C<ok>'s prototype is C<($;$$)> (and, incidentally, C<skip>'s is
649 C<($;$$$)>). This means, for example, that you can do C<ok @foo, @bar>
651 thinking that C<ok @foo, @bar> means a comparison of the contents of two
653 so easy to make that mistake in reading C<ok @foo, @bar> that you might
654 want to be very explicit about it, and instead write C<ok scalar(@foo),
661 ok $thingy->can('some_method');
664 method is this...)", and then C<ok> sees a coderef and thinks you're
668 ok $thingy->can('some_method')->();
672 ok $thingy->can('some_method') && 1;
674 If the C<can> returns false, then that is passed to C<ok>. If it
676 $thingy->can('some_method') && 1 >> >> returns 1, which C<ok> sees as
703 ok foo($bar), baz($quux);
704 ok thing($whatever), baz($stuff);
705 ok blorp($quux, $whatever);
706 ok foo($barzbarz), thang($quux);
712 But be quite sure that C<ok> is called exactly as many times in the