]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/math-sqrt-basics-disable-architecture-specific-optimizations.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / math-sqrt-basics-disable-architecture-specific-optimizations.js
CommitLineData
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().
5function sqrtOnInteger(radicand) {
6 return Math.sqrt(radicand);
7}
8noInline(sqrtOnInteger);
9
10function 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}
17testSquareRoot16();
18
19var sqrtOnIntegerNegativeNumber = sqrtOnDouble(-4);
20if (!isNaN(sqrtOnIntegerNegativeNumber))
21 throw "sqrtOnDouble(-4) = " + sqrtOnIntegerNegativeNumber + ", expected NaN";
22
23var sqrtOnIntegerFallback = sqrtOnInteger(Math.PI);
24if (sqrtOnIntegerFallback != 1.7724538509055159)
25 throw "sqrtOnInteger(Math.PI) = " + sqrtOnIntegerFallback + ", expected 1.7724538509055159";
26
27
28function sqrtOnDouble(radicand) {
29 return Math.sqrt(radicand);
30}
31noInline(sqrtOnDouble);
32
33function 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}
40testSquareRootDouble();
41
42var sqrtOnDoubleNegativeNumber = sqrtOnDouble(-Math.PI);
43if (!isNaN(sqrtOnDoubleNegativeNumber))
44 throw "sqrtOnDouble(-Math.PI) = " + sqrtOnDoubleNegativeNumber + ", expected NaN";
45
46var sqrtOnDoubleFallback = sqrtOnDouble(4);
47if (sqrtOnDoubleFallback !== 2)
48 throw "sqrtOnDouble(4) = " + sqrtOnDoubleFallback + ", expected 2";