root/1.8.3/tags/p6/test/testmath.pl

Revision 1167, 1.8 KB (checked in by shawnw, 13 months ago)

Merge devel into trunk for p6 release

Line 
1run tests:
2test('abs.1', $god, 'think abs(-1)', '1');
3test('abs.2', $god, 'think abs(-1.5)', '1.5');
4test('abs.3', $god, 'think abs(1)', '1');
5test('abs.4', $god, 'think abs(0)', '0');
6test('abs.5', $god, 'think abs(-0)', '0');
7test('abs.6', $god, 'think abs(99999999999)', '99999999999');
8test('abs.7', $god, 'think abs(-99999999999)', '99999999999');
9
10test('cos.1',$god, 'think cos(90,d)', '^-?0\s*$');
11test('cos.2',$god, 'think cos(pi(),r)', '^-1\s*$');
12test('cos.3',$god, 'think cos(pi())', '^-1\s*$');
13
14test('acos.1',$god, 'think acos(cos(90,d),d)', '^90\s*$');
15test('acos.2',$god, 'think acos(cos(1,r))', '^1\s*$');
16test('acos.3',$god, 'think acos(cos(1,r),r)', '^1\s*$');
17
18test('sin.1',$god, 'think sin(90,d)', '^1\s*$');
19test('sin.2',$god, 'think sin(pi(),r)', '^-?0\s*$');
20test('sin.3',$god, 'think sin(pi())', '^-?0\s*$');
21
22test('asin.1',$god, 'think asin(sin(90,d),d)', '^90\s*$');
23test('asin.2',$god, 'think asin(sin(1,r))', '^1\s*$');
24test('asin.3',$god, 'think asin(sin(1,r),r)', '^1\s*$');
25
26test('tan.1',$god, 'think tan(45,d)', '^1\s*$');
27test('tan.2',$god, 'think tan(pi(),r)', '^-?0\s*$');
28test('tan.3',$god, 'think tan(pi())', '^-?0\s*$');
29
30test('atan.1',$god, 'think atan(tan(45,d),d)', '^45\s*$');
31test('atan.2',$god, 'think atan(tan(1,r))', '^1\s*$');
32test('atan.3',$god, 'think atan(tan(1,r),r)', '^1\s*$');
33
34test('ctu.1',$god, 'think ctu(90,d,r)', '^1.570\d*\s*$');
35test('ctu.2',$god, 'think ctu(pi(),r,d)','^180(\.00\d*)?\s*$');
36
37test('sqrt.1', $god, 'think sqrt(4)', '2');
38test('sqrt.2', $god, 'think sqrt(-1)', '#-1 IMAGINARY NUMBER');
39
40test('root.1', $god, 'think root(4,2)', '2');
41test('root.2', $god, 'think root(-1,2)', '#-1 IMAGINARY NUMBER');
42test('root.3', $god, 'think root(27, 3)', '3');
43test('root.4', $god, 'think root(-27, 3)', '-3');
44$god->command('@config/set float_precision=10');
45test('root.5', $god, 'think root(125, 5)', '2.6265278044');
Note: See TracBrowser for help on using the browser.