21 # You have to do it this way or VMS will get confused.
22 printf "%s %d%s\n", $ok ? "ok" : "not ok",
24 defined $name ? " - $name" : '';
26 printf "# Failed test at line %d\n", (caller)[2] unless $ok;
34 # Test do &sub and proper @_ handling.
38 ok( $result eq 'value', ":$result: eq :value:" );
42 $result = do foo2(0,1,0);
43 ok( $result eq 'value', ":$result: eq :value:" );
46 $result = do{ ok 1; 'value';};
47 ok( $result eq 'value', ":$result: eq :value:" );
53 do blather("ayep","sho nuff");
54 @x = ("jeepers", "okydoke");
55 @y = ("uhhuh", "yeppers");
56 do blather(@x,"noofie",@y);
60 if (open(DO, ">$$.16")) {
61 print DO "ok(1, 'do in scalar context') if defined wantarray && not wantarray\n";
62 close DO or die "Could not close: $!";
65 my $a = do "$$.16"; die $@ if $@;
67 if (open(DO, ">$$.17")) {
68 print DO "ok(1, 'do in list context') if defined wantarray && wantarray\n";
69 close DO or die "Could not close: $!";
72 my @a = do "$$.17"; die $@ if $@;
74 if (open(DO, ">$$.18")) {
75 print DO "ok(1, 'do in void context') if not defined wantarray\n";
76 close DO or die "Could not close: $!";
79 do "$$.18"; die $@ if $@;
82 eval qq{ do qq(a file that does not exist); };
83 ok( !$@, "do on a non-existing file, first try" );
85 eval qq{ do uc qq(a file that does not exist); };
86 ok( !$@, "do on a non-existing file, second try" );
88 # 6 must be interpreted as a file name here
89 ok( (!defined do 6) && $!, "'do 6' : $!" );
92 push @t, ($u = (do {} . "This should be pushed."));
93 ok( $#t == 0, "empty do result value" );
96 1 while unlink("$$.16", "$$.17", "$$.18");