]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/stress/math-log-with-constants.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / math-log-with-constants.js
CommitLineData
ed1e77d3
A
1// Basic cases of Math.log() when the value passed are constants.
2
3// log(NaN).
4function logNaN() {
5 return Math.log(NaN);
6}
7noInline(logNaN);
8
9function testLogNaN() {
10 for (var i = 0; i < 10000; ++i) {
11 var result = logNaN();
12 if (!isNaN(result))
13 throw "logNaN() = " + result + ", expected NaN";
14 }
15}
16testLogNaN();
17
18
19// log(0).
20function logZero() {
21 return Math.log(0);
22}
23noInline(logZero);
24
25function testLogZero() {
26 for (var i = 0; i < 10000; ++i) {
27 var result = logZero();
28 if (result !== -Infinity)
29 throw "logZero() = " + result + ", expected -Infinity";
30 }
31}
32testLogZero();
33
34
35// log(1).
36function logOne() {
37 return Math.log(1);
38}
39noInline(logOne);
40
41function testLogOne() {
42 for (var i = 0; i < 10000; ++i) {
43 var result = logOne();
44 if (result !== 0)
45 throw "logOne(1) = " + result + ", expected 0";
46 }
47}
48testLogOne();
49
50
51// log(-1).
52function logMinusOne() {
53 return Math.log(-1);
54}
55noInline(logMinusOne);
56
57function testLogMinusOne() {
58 for (var i = 0; i < 10000; ++i) {
59 var result = logMinusOne();
60 if (!isNaN(result))
61 throw "logMinusOne() = " + result + ", expected NaN";
62 }
63}
64testLogMinusOne();
65
66
67// log(Infinity).
68function logInfinity() {
69 return Math.log(Infinity);
70}
71noInline(logInfinity);
72
73function testLogInfinity() {
74 for (var i = 0; i < 10000; ++i) {
75 var result = logInfinity();
76 if (result !== Infinity)
77 throw "logInfinity() = " + result + ", expected Infinity";
78 }
79}
80testLogInfinity();
81
82
83// log(-Infinity).
84function logMinusInfinity() {
85 return Math.log(-Infinity);
86}
87noInline(logMinusInfinity);
88
89function testLogMinusInfinity() {
90 for (var i = 0; i < 10000; ++i) {
91 var result = logMinusInfinity();
92 if (!isNaN(result))
93 throw "logMinusInfinity() = " + result + ", expected NaN";
94 }
95}
96testLogMinusInfinity();
97
98
99// log(integer).
100function logInteger() {
101 return Math.log(42);
102}
103noInline(logInteger);
104
105function testLogInteger() {
106 for (var i = 0; i < 10000; ++i) {
107 var result = logInteger();
108 if (result !== 3.7376696182833684)
109 throw "logInteger() = " + result + ", expected 3.7376696182833684";
110 }
111}
112testLogInteger();
113
114
115// log(double).
116function logDouble() {
117 return Math.log(Math.PI);
118}
119noInline(logDouble);
120
121function testLogDouble() {
122 for (var i = 0; i < 10000; ++i) {
123 var result = logDouble();
124 if (result !== 1.1447298858494002)
125 throw "logDouble() = " + result + ", expected 1.1447298858494002";
126 }
127}
128testLogDouble();