]>
Commit | Line | Data |
---|---|---|
ed1e77d3 A |
1 | //@ run("no-architecture-specific-optimizations", "--enableArchitectureSpecificOptimizations=false", *NO_CJIT_OPTIONS) |
2 | //@ run("no-architecture-specific-optimizations-ftl", "--enableArchitectureSpecificOptimizations=false", *FTL_OPTIONS) | |
3 | ||
4 | // Basic cases of Math.sqrt(). | |
5 | function sqrtOnInteger(radicand) { | |
6 | return Math.sqrt(radicand); | |
7 | } | |
8 | noInline(sqrtOnInteger); | |
9 | ||
10 | function testSquareRoot16() { | |
11 | for (var i = 0; i < 10000; ++i) { | |
12 | var result = sqrtOnInteger(16); | |
13 | if (result !== 4) | |
14 | throw "sqrtOnInteger(16) = " + result + ", expected 4"; | |
15 | } | |
16 | } | |
17 | testSquareRoot16(); | |
18 | ||
19 | var sqrtOnIntegerNegativeNumber = sqrtOnDouble(-4); | |
20 | if (!isNaN(sqrtOnIntegerNegativeNumber)) | |
21 | throw "sqrtOnDouble(-4) = " + sqrtOnIntegerNegativeNumber + ", expected NaN"; | |
22 | ||
23 | var sqrtOnIntegerFallback = sqrtOnInteger(Math.PI); | |
24 | if (sqrtOnIntegerFallback != 1.7724538509055159) | |
25 | throw "sqrtOnInteger(Math.PI) = " + sqrtOnIntegerFallback + ", expected 1.7724538509055159"; | |
26 | ||
27 | ||
28 | function sqrtOnDouble(radicand) { | |
29 | return Math.sqrt(radicand); | |
30 | } | |
31 | noInline(sqrtOnDouble); | |
32 | ||
33 | function testSquareRootDouble() { | |
34 | for (var i = 0; i < 10000; ++i) { | |
35 | var result = sqrtOnInteger(Math.LN2); | |
36 | if (result !== 0.8325546111576977) | |
37 | throw "sqrtOnInteger(Math.LN2) = " + result + ", expected 0.8325546111576977"; | |
38 | } | |
39 | } | |
40 | testSquareRootDouble(); | |
41 | ||
42 | var sqrtOnDoubleNegativeNumber = sqrtOnDouble(-Math.PI); | |
43 | if (!isNaN(sqrtOnDoubleNegativeNumber)) | |
44 | throw "sqrtOnDouble(-Math.PI) = " + sqrtOnDoubleNegativeNumber + ", expected NaN"; | |
45 | ||
46 | var sqrtOnDoubleFallback = sqrtOnDouble(4); | |
47 | if (sqrtOnDoubleFallback !== 2) | |
48 | throw "sqrtOnDouble(4) = " + sqrtOnDoubleFallback + ", expected 2"; |