OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 (function TestStdlibConstants() { | 7 (function TestStdlibConstants() { |
8 function Module(stdlib) { | 8 function Module(stdlib) { |
9 "use asm"; | 9 "use asm"; |
10 | 10 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 y = +y; | 76 y = +y; |
77 var t = 0.0; | 77 var t = 0.0; |
78 t = x - y; | 78 t = x - y; |
79 if (t < 0.0) { | 79 if (t < 0.0) { |
80 t = t * -1.0; | 80 t = t * -1.0; |
81 } | 81 } |
82 return (t < 1.0e-13) | 0; | 82 return (t < 1.0e-13) | 0; |
83 } | 83 } |
84 | 84 |
85 function caller() { | 85 function caller() { |
86 if (!deltaEqual(StdlibMathSqrt(123.0), 11.090536506409418)) return 0; | 86 if (!(deltaEqual(+StdlibMathSqrt(123.0), 11.090536506409418)|0)) return 0; |
87 if (StdlibMathSqrt(fround(256.0)) != fround(16.0)) return 0; | 87 if (fround(StdlibMathSqrt(fround(256.0))) != fround(16.0)) return 0; |
88 if (StdlibMathCeil(123.7) != 124.0) return 0; | 88 if (+StdlibMathCeil(123.7) != 124.0) return 0; |
89 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0; | 89 if (fround(StdlibMathCeil(fround(123.7))) != fround(124.0)) return 0; |
90 if (StdlibMathFloor(123.7) != 123.0) return 0; | 90 if (+StdlibMathFloor(123.7) != 123.0) return 0; |
91 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0; | 91 if (fround(StdlibMathFloor(fround(123.7))) != fround(123.0)) return 0; |
92 if (StdlibMathAbs(-123.0) != 123.0) return 0; | 92 if (+StdlibMathAbs(-123.0) != 123.0) return 0; |
93 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0; | 93 if (fround(StdlibMathAbs(fround(-123.0))) != fround(123.0)) return 0; |
94 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0; | 94 if (+StdlibMathMin(123.4, 1236.4) != 123.4) return 0; |
95 if (StdlibMathMin(fround(123.4), | 95 if (fround(StdlibMathMin(fround(123.4), |
96 fround(1236.4)) != fround(123.4)) return 0; | 96 fround(1236.4))) != fround(123.4)) return 0; |
97 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0; | 97 if (+StdlibMathMax(123.4, 1236.4) != 1236.4) return 0; |
98 if (StdlibMathMax(fround(123.4), fround(1236.4)) | 98 if (fround(StdlibMathMax(fround(123.4), fround(1236.4))) |
99 != fround(1236.4)) return 0; | 99 != fround(1236.4)) return 0; |
100 | 100 |
101 if (!deltaEqual(StdlibMathAcos(0.1), 1.4706289056333368)) return 0; | 101 if (!(deltaEqual(+StdlibMathAcos(0.1), 1.4706289056333368)|0)) return 0; |
102 if (!deltaEqual(StdlibMathAsin(0.2), 0.2013579207903308)) return 0; | 102 if (!(deltaEqual(+StdlibMathAsin(0.2), 0.2013579207903308)|0)) return 0; |
103 if (!deltaEqual(StdlibMathAtan(0.2), 0.19739555984988078)) return 0; | 103 if (!(deltaEqual(+StdlibMathAtan(0.2), 0.19739555984988078)|0)) return 0; |
104 if (!deltaEqual(StdlibMathCos(0.2), 0.9800665778412416)) return 0; | 104 if (!(deltaEqual(+StdlibMathCos(0.2), 0.9800665778412416)|0)) return 0; |
105 if (!deltaEqual(StdlibMathSin(0.2), 0.19866933079506122)) return 0; | 105 if (!(deltaEqual(+StdlibMathSin(0.2), 0.19866933079506122)|0)) return 0; |
106 if (!deltaEqual(StdlibMathTan(0.2), 0.20271003550867250)) return 0; | 106 if (!(deltaEqual(+StdlibMathTan(0.2), 0.20271003550867250)|0)) return 0; |
107 if (!deltaEqual(StdlibMathExp(0.2), 1.2214027581601699)) return 0; | 107 if (!(deltaEqual(+StdlibMathExp(0.2), 1.2214027581601699)|0)) return 0; |
108 if (!deltaEqual(StdlibMathLog(0.2), -1.6094379124341003)) return 0; | 108 if (!(deltaEqual(+StdlibMathLog(0.2), -1.6094379124341003)|0)) return 0; |
109 | 109 |
110 if (StdlibMathImul(6, 7) != 42) return 0; | 110 if ((StdlibMathImul(6, 7)|0) != 42) return 0; |
111 if (!deltaEqual(StdlibMathAtan2(6.0, 7.0), 0.7086262721276703)) return 0; | 111 if (!(deltaEqual(+StdlibMathAtan2(6.0, 7.0), 0.7086262721276703)|0)) |
112 if (StdlibMathPow(6.0, 7.0) != 279936.0) return 0; | 112 return 0; |
| 113 if (+StdlibMathPow(6.0, 7.0) != 279936.0) return 0; |
113 | 114 |
114 return 1; | 115 return 1; |
115 } | 116 } |
116 | 117 |
117 return {caller:caller}; | 118 return {caller:caller}; |
118 } | 119 } |
119 | 120 |
120 var m = Wasm.instantiateModuleFromAsm(Module.toString()); | 121 var m = Wasm.instantiateModuleFromAsm(Module.toString()); |
121 assertEquals(1, m.caller()); | 122 assertEquals(1, m.caller()); |
122 })(); | 123 })(); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 if (!compare(expected, actual)) { | 350 if (!compare(expected, actual)) { |
350 print(expected + ' !== ' + actual + ' for ' + name + | 351 print(expected + ' !== ' + actual + ' for ' + name + |
351 ' with input ' + val0 + ' ' + val1); | 352 ' with input ' + val0 + ' ' + val1); |
352 assertTrue(false); | 353 assertTrue(false); |
353 } | 354 } |
354 } | 355 } |
355 } | 356 } |
356 } | 357 } |
357 } | 358 } |
358 })(); | 359 })(); |
OLD | NEW |