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
|
#!/usr/bin/perl
use Test::Inter;
$o = new Test::Inter;
print "The following tests should all succeed\n\n";
$o->ok();
$o->ok( 1 == 1 );
$o->ok( 1 == 1, "Basic test" );
$o->ok( 1 == 1, 1, "Basic test" );
$o->ok( 1 == 1, 2, "Basic test" );
sub func_false {
return 0;
}
sub func_true {
return 1;
}
sub func {
my($a,$b) = @_;
return $a == $b;
}
$o->ok( \&func_true );
$o->ok( \&func_true, "True test" );
$o->ok( \&func_true, 1, "True test" );
$o->ok( \&func_true, 2, "True test" );
$o->ok( \&func, [1,1]);
$o->ok( \&func, [1,1], "Func test" );
$o->ok( \&func, [1,1], 1, "Func test" );
$o->ok( \&func, [1,1], 2, "Func test" );
$o->ok( [ a,b ], [ a,b ], "List test" );
$o->ok( [ a,b ], [ a,c ], "List test (non-identical)" );
$o->ok( { a => 1, b => 2 }, { a => 1, b => 2 }, "Hash test" );
$o->ok( { a => 1, b => 2 }, { a => 1, b => 3 }, "Hash test (non-identical)" );
print "\nThe following tests should all fail\n\n";
$o->ok( 1 == 2 );
$o->ok( 1 == 2, "Basic test" );
$o->ok( 1 == 2, 1, "Basic test" );
$o->ok( \&func_false );
$o->ok( \&func_false, "False test" );
$o->ok( \&func_false, 1, "False test" );
$o->ok( \&func, [1,2]);
$o->ok( \&func, [1,2], "Func test" );
$o->ok( \&func, [1,2], 1, "Func test" );
$o->ok( [], [ a,b ], "List test" );
$o->ok( [undef], [ a,b ], "List test" );
$o->ok( { a => undef }, { a => 1 }, "Hash test" );
|