Debian Codegraph @

rhino/testsrc/tests/ecma/Math/15.8.2.17.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = '15.8.2.17.js';
7
8 /**
9 File Name: 15.8.2.17.js
10 ECMA Section: 15.8.2.17 Math.sqrt(x)
11 Description: return an approximation to the squareroot of the argument.
12 special cases:
13 - if x is NaN return NaN
14 - if x < 0 return NaN
15 - if x == 0 return 0
16 - if x == -0 return -0
17 - if x == Infinity return Infinity
18 Author: [email protected]
19 Date: 7 july 1997
20 */
21
22 var SECTION = "15.8.2.17";
23 var VERSION = "ECMA_1";
24 startTest();
25 var TITLE = "Math.sqrt(x)";
26
27 writeHeaderToLog( SECTION + " "+ TITLE);
28
29 new TestCase( SECTION,
30 "Math.sqrt.length",
31 1,
32 Math.sqrt.length );
33
34 new TestCase( SECTION,
35 "Math.sqrt()",
36 Number.NaN,
37 Math.sqrt() );
38
39 new TestCase( SECTION,
40 "Math.sqrt(void 0)",
41 Number.NaN,
42 Math.sqrt(void 0) );
43
44 new TestCase( SECTION,
45 "Math.sqrt(null)",
46 0,
47 Math.sqrt(null) );
48
49 new TestCase( SECTION,
50 "Math.sqrt(true)",
51 1,
52 Math.sqrt(1) );
53
54 new TestCase( SECTION,
55 "Math.sqrt(false)",
56 0,
57 Math.sqrt(false) );
58
59 new TestCase( SECTION,
60 "Math.sqrt('225')",
61 15,
62 Math.sqrt('225') );
63
64 new TestCase( SECTION,
65 "Math.sqrt(NaN)",
66 Number.NaN,
67 Math.sqrt(Number.NaN) );
68
69 new TestCase( SECTION,
70 "Math.sqrt(-Infinity)",
71 Number.NaN,
72 Math.sqrt(Number.NEGATIVE_INFINITY));
73
74 new TestCase( SECTION,
75 "Math.sqrt(-1)",
76 Number.NaN,
77 Math.sqrt(-1));
78
79 new TestCase( SECTION,
80 "Math.sqrt(-0.5)",
81 Number.NaN,
82 Math.sqrt(-0.5));
83
84 new TestCase( SECTION,
85 "Math.sqrt(0)",
86 0,
87 Math.sqrt(0));
88
89 new TestCase( SECTION,
90 "Math.sqrt(-0)",
91 -0,
92 Math.sqrt(-0));
93
94 new TestCase( SECTION,
95 "Infinity/Math.sqrt(-0)",
96 -Infinity,
97 Infinity/Math.sqrt(-0) );
98
99 new TestCase( SECTION,
100 "Math.sqrt(Infinity)",
101 Number.POSITIVE_INFINITY,
102 Math.sqrt(Number.POSITIVE_INFINITY));
103
104 new TestCase( SECTION,
105 "Math.sqrt(1)",
106 1,
107 Math.sqrt(1));
108
109 new TestCase( SECTION,
110 "Math.sqrt(2)",
111 Math.SQRT2,
112 Math.sqrt(2));
113
114 new TestCase( SECTION,
115 "Math.sqrt(0.5)",
116 Math.SQRT1_2,
117 Math.sqrt(0.5));
118
119 new TestCase( SECTION,
120 "Math.sqrt(4)",
121 2,
122 Math.sqrt(4));
123
124 new TestCase( SECTION,
125 "Math.sqrt(9)",
126 3,
127 Math.sqrt(9));
128
129 new TestCase( SECTION,
130 "Math.sqrt(16)",
131 4,
132 Math.sqrt(16));
133
134 new TestCase( SECTION,
135 "Math.sqrt(25)",
136 5,
137 Math.sqrt(25));
138
139 new TestCase( SECTION,
140 "Math.sqrt(36)",
141 6,
142 Math.sqrt(36));
143
144 new TestCase( SECTION,
145 "Math.sqrt(49)",
146 7,
147 Math.sqrt(49));
148
149 new TestCase( SECTION,
150 "Math.sqrt(64)",
151 8,
152 Math.sqrt(64));
153
154 new TestCase( SECTION,
155 "Math.sqrt(256)",
156 16,
157 Math.sqrt(256));
158
159 new TestCase( SECTION,
160 "Math.sqrt(10000)",
161 100,
162 Math.sqrt(10000));
163
164 new TestCase( SECTION,
165 "Math.sqrt(65536)",
166 256,
167 Math.sqrt(65536));
168
169 new TestCase( SECTION,
170 "Math.sqrt(0.09)",
171 0.3,
172 Math.sqrt(0.09));
173
174 new TestCase( SECTION,
175 "Math.sqrt(0.01)",
176 0.1,
177 Math.sqrt(0.01));
178
179 new TestCase( SECTION,
180 "Math.sqrt(0.00000001)",
181 0.0001,
182 Math.sqrt(0.00000001));
183
184 test();