Commit | Line | Data |
760ac839 |
1 | BEGIN { |
2 | chdir 't' if -d 't/lib'; |
3 | @INC = '../lib' if -d 'lib'; |
4 | require Config; import Config; |
bbad3607 |
5 | if (-d 'lib' and $Config{'extensions'} !~ /\bOS2(::|\/)REXX\b/) { |
760ac839 |
6 | print "1..0\n"; |
7 | exit 0; |
8 | } |
9 | } |
10 | |
5ba48348 |
11 | use OS2::REXX qw(:DEFAULT register); |
760ac839 |
12 | |
13 | $| = 1; # Otherwise data from REXX may come first |
14 | |
5ba48348 |
15 | print "1..16\n"; |
760ac839 |
16 | |
17 | $n = 1; |
18 | sub do_me { |
19 | print "ok $n\n"; |
20 | "OK"; |
21 | } |
22 | |
23 | @res = REXX_call(\&do_me); |
24 | print "ok 2\n"; |
25 | @res == 1 ? print "ok 3\n" : print "not ok 3\n"; |
26 | $res[0] eq "OK" ? print "ok 4\n" : print "not ok 4\n# `$res[0]'\n"; |
27 | |
28 | # Try again |
29 | $n = 5; |
30 | @res = REXX_call(\&do_me); |
31 | print "ok 6\n"; |
32 | @res == 1 ? print "ok 7\n" : print "not ok 7\n"; |
33 | $res[0] eq "OK" ? print "ok 8\n" : print "not ok 8\n# `$res[0]'\n"; |
34 | |
35 | REXX_call { print "ok 9\n" }; |
36 | REXX_eval 'say "ok 10"'; |
37 | # Try again |
38 | REXX_eval 'say "ok 11"'; |
39 | print "ok 12\n" if REXX_eval("return 2 + 3") eq 5; |
40 | REXX_eval_with 'say myfunc()', myfunc => sub {"ok 13"}; |
5ba48348 |
41 | REXX_eval_with "call myout 'ok' 14", myout => sub {print shift, "\n"}; |
42 | REXX_eval_with "say 'ok 'myfunc(3,5)", myfunc => sub {shift() * shift()}; |
43 | |
44 | sub MYFUNC1 {shift} |
45 | sub MYFUNC2 {3 * shift} |
46 | REXX_eval_with "call myfunc |
47 | say 'ok 'myfunc1(1)myfunc2(2)", |
48 | myfunc => sub { register qw(myfunc1 myfunc2) }; |