OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 EmptyTest() { | 7 function EmptyTest() { |
8 "use asm"; | 8 "use asm"; |
9 function caller() { | 9 function caller() { |
10 empty(); | 10 empty(); |
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1258 return +(a, b); | 1258 return +(a, b); |
1259 } | 1259 } |
1260 | 1260 |
1261 return {ifunc: ifunc, dfunc: dfunc}; | 1261 return {ifunc: ifunc, dfunc: dfunc}; |
1262 } | 1262 } |
1263 | 1263 |
1264 var m = _WASMEXP_.instantiateModuleFromAsm(CommaModule.toString()); | 1264 var m = _WASMEXP_.instantiateModuleFromAsm(CommaModule.toString()); |
1265 assertEquals(123, m.ifunc(456.7, 123)); | 1265 assertEquals(123, m.ifunc(456.7, 123)); |
1266 assertEquals(123.4, m.dfunc(456, 123.4)); | 1266 assertEquals(123.4, m.dfunc(456, 123.4)); |
1267 })(); | 1267 })(); |
1268 | |
1269 | |
1270 (function TestStdlibConstants() { | |
1271 function Module(stdlib) { | |
1272 "use asm"; | |
1273 | |
1274 var StdlibInfinity = stdlib.Infinity; | |
1275 var StdlibNaN = stdlib.NaN; | |
1276 var StdlibMathE = stdlib.Math.E; | |
1277 var StdlibMathLN10 = stdlib.Math.LN10; | |
1278 var StdlibMathLN2 = stdlib.Math.LN2; | |
1279 var StdlibMathLOG2E = stdlib.Math.LOG2E; | |
1280 var StdlibMathLOG10E = stdlib.Math.LOG10E; | |
1281 var StdlibMathPI = stdlib.Math.PI; | |
1282 var StdlibMathSQRT1_2 = stdlib.Math.SQRT1_2; | |
1283 var StdlibMathSQRT2 = stdlib.Math.SQRT2; | |
1284 | |
1285 function caller() { | |
1286 if (StdlibInfinity != 1.0 / 0.0) return 0; | |
1287 // TODO(bradnelson): Figure out why this fails. | |
aseemgarg
2016/02/22 22:15:53
Could this be some parser magic not implemented co
bradnelson
2016/02/23 09:48:55
Not thinking. All comparisons on NaN's fail.
Chang
| |
1288 //if (StdlibNaN != 0.0 / 0.0) return 0; | |
1289 if (StdlibMathE != 2.718281828459045) return 0; | |
1290 if (StdlibMathLN10 != 2.302585092994046) return 0; | |
1291 if (StdlibMathLN2 != 0.6931471805599453) return 0; | |
1292 if (StdlibMathLOG2E != 1.4426950408889634) return 0; | |
1293 if (StdlibMathLOG10E != 0.4342944819032518) return 0; | |
1294 if (StdlibMathPI != 3.141592653589793) return 0; | |
1295 if (StdlibMathSQRT1_2 != 0.7071067811865476) return 0; | |
1296 if (StdlibMathSQRT2 != 1.4142135623730951) return 0; | |
1297 return 1; | |
1298 } | |
1299 | |
1300 return {caller:caller}; | |
1301 } | |
1302 | |
1303 var m =_WASMEXP_.instantiateModuleFromAsm(Module.toString()); | |
1304 assertEquals(1, m.caller()); | |
1305 })(); | |
1306 | |
1307 | |
1308 (function TestStdlibFunctions() { | |
1309 function Module(stdlib) { | |
1310 "use asm"; | |
1311 | |
1312 var StdlibMathAcos = stdlib.Math.acos; | |
1313 var StdlibMathAsin = stdlib.Math.asin; | |
1314 var StdlibMathAtan = stdlib.Math.atan; | |
1315 var StdlibMathCos = stdlib.Math.cos; | |
1316 var StdlibMathSin = stdlib.Math.sin; | |
1317 var StdlibMathTan = stdlib.Math.tan; | |
1318 var StdlibMathExp = stdlib.Math.exp; | |
1319 var StdlibMathLog = stdlib.Math.log; | |
1320 var StdlibMathCeil = stdlib.Math.ceil; | |
1321 var StdlibMathFloor = stdlib.Math.floor; | |
1322 var StdlibMathSqrt = stdlib.Math.sqrt; | |
1323 var StdlibMathAbs = stdlib.Math.abs; | |
1324 var StdlibMathMin = stdlib.Math.min; | |
1325 var StdlibMathMax = stdlib.Math.max; | |
1326 var StdlibMathAtan2 = stdlib.Math.atan2; | |
1327 var StdlibMathPow = stdlib.Math.pow; | |
1328 var StdlibMathImul = stdlib.Math.imul; | |
1329 var fround = stdlib.Math.fround; | |
1330 | |
1331 function caller() { | |
1332 // TODO(bradnelson): Test transendentals when implemented. | |
1333 if (StdlibMathSqrt(123.0) != 11.090536506409418) return 0; | |
aseemgarg
2016/02/22 22:15:53
Change it to a perfect square? That way reading th
bradnelson
2016/02/23 09:48:55
Done.
| |
1334 if (StdlibMathSqrt(fround(123.0)) | |
1335 != fround(11.090536506409418)) return 0; | |
1336 if (StdlibMathCeil(123.7) != 124.0) return 0; | |
1337 if (StdlibMathCeil(fround(123.7)) != fround(124.0)) return 0; | |
1338 if (StdlibMathFloor(123.7) != 123.0) return 0; | |
1339 if (StdlibMathFloor(fround(123.7)) != fround(123.0)) return 0; | |
1340 if (StdlibMathAbs(-123.0) != 123.0) return 0; | |
1341 if (StdlibMathAbs(fround(-123.0)) != fround(123.0)) return 0; | |
1342 if (StdlibMathMin(123.4, 1236.4) != 123.4) return 0; | |
1343 if (StdlibMathMin(fround(123.4), | |
1344 fround(1236.4)) != fround(123.4)) return 0; | |
1345 if (StdlibMathMax(123.4, 1236.4) != 1236.4) return 0; | |
1346 if (StdlibMathMax(fround(123.4), fround(1236.4)) | |
1347 != fround(1236.4)) return 0; | |
1348 if (StdlibMathImul(6, 7) != 42) return 0; | |
1349 return 1; | |
1350 } | |
1351 | |
1352 return {caller:caller}; | |
1353 } | |
1354 | |
1355 var m = _WASMEXP_.instantiateModuleFromAsm(Module.toString()); | |
1356 assertEquals(1, m.caller()); | |
1357 })(); | |
OLD | NEW |