]> git.saurik.com Git - apple/javascriptcore.git/blob - tests/stress/math-log-with-constants.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / stress / math-log-with-constants.js
1 // Basic cases of Math.log() when the value passed are constants.
2
3 // log(NaN).
4 function logNaN() {
5 return Math.log(NaN);
6 }
7 noInline(logNaN);
8
9 function 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 }
16 testLogNaN();
17
18
19 // log(0).
20 function logZero() {
21 return Math.log(0);
22 }
23 noInline(logZero);
24
25 function 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 }
32 testLogZero();
33
34
35 // log(1).
36 function logOne() {
37 return Math.log(1);
38 }
39 noInline(logOne);
40
41 function 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 }
48 testLogOne();
49
50
51 // log(-1).
52 function logMinusOne() {
53 return Math.log(-1);
54 }
55 noInline(logMinusOne);
56
57 function 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 }
64 testLogMinusOne();
65
66
67 // log(Infinity).
68 function logInfinity() {
69 return Math.log(Infinity);
70 }
71 noInline(logInfinity);
72
73 function 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 }
80 testLogInfinity();
81
82
83 // log(-Infinity).
84 function logMinusInfinity() {
85 return Math.log(-Infinity);
86 }
87 noInline(logMinusInfinity);
88
89 function 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 }
96 testLogMinusInfinity();
97
98
99 // log(integer).
100 function logInteger() {
101 return Math.log(42);
102 }
103 noInline(logInteger);
104
105 function 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 }
112 testLogInteger();
113
114
115 // log(double).
116 function logDouble() {
117 return Math.log(Math.PI);
118 }
119 noInline(logDouble);
120
121 function 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 }
128 testLogDouble();