1 # driver.pm - common test driver code
6 *CORE::GLOBAL::syswrite =
7 sub($$$;$) { my( $h, $b, $s, $o ) = @_; CORE::syswrite $h, $b, $s, $o} ;
8 # sub(*\$$;$) { my( $h, $b, $s, $o ) = @_; CORE::syswrite $h, $b, $s, $o } ;
10 *CORE::GLOBAL::sysread =
11 sub($$$;$) { my( $h, $b, $s, $o ) = @_; CORE::sysread $h, $b, $s, $o } ;
12 # sub(*\$$;$) { my( $h, $b, $s, $o ) = @_; CORE::sysread $h, $b, $s, $o } ;
14 *CORE::GLOBAL::rename =
15 sub($$) { my( $old, $new ) = @_; CORE::rename $old, $new } ;
17 *CORE::GLOBAL::sysopen =
18 sub($$$;$) { my( $h, $n, $m, $p ) = @_; CORE::sysopen $h, $n, $m, $p } ;
19 # sub(*$$;$) { my( $h, $n, $m, $p ) = @_; CORE::sysopen $h, $n, $m, $p } ;
28 # plan for one expected ok() call per test
30 plan( tests => scalar @{$tests} ) ;
32 # loop over all the tests
34 foreach my $test ( @{$tests} ) {
38 if ( $test->{skip} ) {
39 ok( 1, "SKIPPING $test->{name}" ) ;
43 my $override = $test->{override} ;
45 # run any setup sub before this test. this can is used to modify the
46 # object for this test or create test files and data.
48 if( my $pretest = $test->{pretest} ) {
53 if( my $sub = $test->{sub} ) {
55 my $args = $test->{args} ;
58 local *{"CORE::GLOBAL::$override"} = sub {}
61 $test->{result} = eval { $sub->( @{$args} ) } ;
65 # if we had an error and expected it, we pass this test
67 if ( $test->{error} &&
68 $@ =~ /$test->{error}/ ) {
73 print "unexpected error: $@\n" ;
79 if( my $posttest = $test->{posttest} ) {
84 ok( $test->{ok}, $test->{name} ) if exists $test->{ok} ;
85 is( $test->{result}, $test->{expected}, $test->{name} ) if
86 exists $test->{expected} ;