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 RunThreeWayTest(asmfunc, expect) { | 7 function RunThreeWayTest(asmfunc, expect) { |
8 var asm_source = asmfunc.toString(); | 8 var asm_source = asmfunc.toString(); |
9 var nonasm_source = asm_source.replace(new RegExp("use asm"), ""); | 9 var nonasm_source = asm_source.replace(new RegExp("use asm"), ""); |
10 var stdlib = {Math: Math}; | 10 var stdlib = {Math: Math}; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 assertEquals(256, module.f256()); | 102 assertEquals(256, module.f256()); |
103 assertEquals(1000, module.f1000()); | 103 assertEquals(1000, module.f1000()); |
104 assertEquals(2000000, module.f2000000()); | 104 assertEquals(2000000, module.f2000000()); |
105 assertEquals(2147483647, module.fmax()); | 105 assertEquals(2147483647, module.fmax()); |
106 }); | 106 }); |
107 | 107 |
108 function LargeUnsignedLiterals() { | 108 function LargeUnsignedLiterals() { |
109 "use asm"; | 109 "use asm"; |
110 function a() { | 110 function a() { |
111 var x = 2147483648; | 111 var x = 2147483648; |
112 return +x; | 112 return +(x >>> 0); |
113 } | 113 } |
114 function b() { | 114 function b() { |
115 var x = 2147483649; | 115 var x = 2147483649; |
116 return +x; | 116 return +(x >>> 0); |
117 } | 117 } |
118 function c() { | 118 function c() { |
119 var x = 0x80000000; | 119 var x = 0x80000000; |
120 return +x; | 120 return +(x >>> 0); |
121 } | 121 } |
122 function d() { | 122 function d() { |
123 var x = 0x80000001; | 123 var x = 0x80000001; |
124 return +x; | 124 return +(x >>> 0); |
125 } | 125 } |
126 function e() { | 126 function e() { |
127 var x = 0xffffffff; | 127 var x = 0xffffffff; |
128 return +x; | 128 return +(x >>> 0); |
129 } | 129 } |
130 return {a: a, b: b, c: c, d: d, e: e}; | 130 return {a: a, b: b, c: c, d: d, e: e}; |
131 } | 131 } |
132 | 132 |
133 RunThreeWayTest(LargeUnsignedLiterals, function(module) { | 133 RunThreeWayTest(LargeUnsignedLiterals, function(module) { |
134 return; // TODO(bradnelson): unsigned literals are broken! | 134 return; // TODO(bradnelson): unsigned literals are broken! |
135 assertEquals(2147483648, module.a()); | 135 assertEquals(2147483648, module.a()); |
136 assertEquals(2147483649, module.b()); | 136 assertEquals(2147483649, module.b()); |
137 assertEquals(0x80000000, module.c()); | 137 assertEquals(0x80000000, module.c()); |
138 assertEquals(0x80000001, module.d()); | 138 assertEquals(0x80000001, module.d()); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // TODO(bradnelson): fails validation of F32 literals somehow. | 253 // TODO(bradnelson): fails validation of F32 literals somehow. |
254 RunThreeWayTest(ManyF32a, function(module) { | 254 RunThreeWayTest(ManyF32a, function(module) { |
255 assertEquals(2.0999999917333043e-24, module.k1()); | 255 assertEquals(2.0999999917333043e-24, module.k1()); |
256 assertEquals(2.099999868734112e-19, module.k2()); | 256 assertEquals(2.099999868734112e-19, module.k2()); |
257 assertEquals(2.099999997029825e-14, module.k3()); | 257 assertEquals(2.099999997029825e-14, module.k3()); |
258 assertEquals(2.099999951710174e-9, module.k4()); | 258 assertEquals(2.099999951710174e-9, module.k4()); |
259 assertEquals(0.0002099999983329326, module.k5()); | 259 assertEquals(0.0002099999983329326, module.k5()); |
260 assertEquals(21.399999618530273, module.k6()); | 260 assertEquals(21.399999618530273, module.k6()); |
261 }); | 261 }); |
262 } | 262 } |
OLD | NEW |