xref: /openbsd-src/gnu/usr.bin/perl/os2/OS2/OS2-REXX/t/rx_varset.t (revision b39c515898423c8d899e35282f4b395f7cad3298)
1*b39c5158SmillertBEGIN {
2*b39c5158Smillert    chdir 't' if -d 't/lib';
3*b39c5158Smillert    @INC = '../lib' if -d 'lib';
4*b39c5158Smillert    require Config; import Config;
5*b39c5158Smillert    if (-d 'lib' and $Config{'extensions'} !~ /\bOS2(::|\/)REXX\b/) {
6*b39c5158Smillert	print "1..0\n";
7*b39c5158Smillert	exit 0;
8*b39c5158Smillert    }
9*b39c5158Smillert}
10*b39c5158Smillert
11*b39c5158Smillertuse OS2::REXX;
12*b39c5158Smillert
13*b39c5158Smillertprint "1..9\n";
14*b39c5158Smillert
15*b39c5158SmillertREXX_call {
16*b39c5158Smillert  OS2::REXX::_set("X" => sqrt(2)) and print "ok 1\n";
17*b39c5158Smillert  $x = OS2::REXX::_fetch("X") and print "ok 2\n";
18*b39c5158Smillert  if (abs($x - sqrt(2)) < 5e-15) {
19*b39c5158Smillert    print "ok 3\n";
20*b39c5158Smillert  } else {  print "not ok 3\n# sqrt(2) = @{[sqrt(2)]} != `$x'\n" }
21*b39c5158Smillert  OS2::REXX::_set("Y" => sqrt(3)) and print "ok 4\n";
22*b39c5158Smillert  $i = 0;
23*b39c5158Smillert  $n = 4;
24*b39c5158Smillert  while (($name, $value) = OS2::REXX::_next("")) {
25*b39c5158Smillert	$i++; $n++;
26*b39c5158Smillert	if ($i <= 2 and $name eq "Y" ) {
27*b39c5158Smillert	  if ($value eq sqrt(3)) {
28*b39c5158Smillert	    print "ok $n\n";
29*b39c5158Smillert	  } else {
30*b39c5158Smillert	    print "not ok $n\n# `$name' => `$value'\n" ;
31*b39c5158Smillert	  }
32*b39c5158Smillert	} elsif ($i <= 2 and $name eq "X") {
33*b39c5158Smillert	  print "ok $n\n" if $value eq sqrt(2);
34*b39c5158Smillert	} else { print "not ok 7\n# name `$name', value `$value'\n" }
35*b39c5158Smillert  }
36*b39c5158Smillert  print "ok 7\n" if $i == 2;
37*b39c5158Smillert  OS2::REXX::_drop("X") and print "ok 8\n";
38*b39c5158Smillert  $x = OS2::REXX::_fetch("X") or print "ok 9\n";
39*b39c5158Smillert};
40