xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/op/exp.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gate# $RCSfile: exp.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:50 $
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gateprint "1..6\n";
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gate# compile time evaluation
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate$s = sqrt(2);
10*0Sstevel@tonic-gateif (substr($s,0,5) eq '1.414') {print "ok 1\n";} else {print "not ok 1\n";}
11*0Sstevel@tonic-gate
12*0Sstevel@tonic-gate$s = exp(1);
13*0Sstevel@tonic-gateif (substr($s,0,7) eq '2.71828') {print "ok 2\n";} else {print "not ok 2\n";}
14*0Sstevel@tonic-gate
15*0Sstevel@tonic-gateif (exp(log(1)) == 1) {print "ok 3\n";} else {print "not ok 3\n";}
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gate# run time evaluation
18*0Sstevel@tonic-gate
19*0Sstevel@tonic-gate$x1 = 1;
20*0Sstevel@tonic-gate$x2 = 2;
21*0Sstevel@tonic-gate$s = sqrt($x2);
22*0Sstevel@tonic-gateif (substr($s,0,5) eq '1.414') {print "ok 4\n";} else {print "not ok 4\n";}
23*0Sstevel@tonic-gate
24*0Sstevel@tonic-gate$s = exp($x1);
25*0Sstevel@tonic-gateif (substr($s,0,7) eq '2.71828') {print "ok 5\n";} else {print "not ok 5\n";}
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gateif (exp(log($x1)) == 1) {print "ok 6\n";} else {print "not ok 6\n";}
28