Index: test/mjsunit/wasm/asm-wasm-stdlib.js |
diff --git a/test/mjsunit/wasm/asm-wasm-stdlib.js b/test/mjsunit/wasm/asm-wasm-stdlib.js |
index 55a244b58d7f999751b02b2fa9ccd48540be8521..82c27d4da99253b70330fa41688768d2326c52a4 100644 |
--- a/test/mjsunit/wasm/asm-wasm-stdlib.js |
+++ b/test/mjsunit/wasm/asm-wasm-stdlib.js |
@@ -47,29 +47,91 @@ var stdlib = this; |
})(); |
-(function TestBadNaNStdlib() { |
+var stdlib = this; |
+var stdlib_root_members = [ |
+ 'Infinity', |
+ 'NaN', |
+]; |
+var stdlib_math_members = [ |
+ 'E', |
+ 'LN10', |
+ 'LN2', |
+ 'LOG2E', |
+ 'LOG10E', |
+ 'PI', |
+ 'SQRT1_2', |
+ 'SQRT2', |
+ 'ceil', |
+ 'clz32', |
+ 'floor', |
+ 'sqrt', |
+ 'abs', |
+ 'min', |
+ 'max', |
+ 'acos', |
+ 'asin', |
+ 'atan', |
+ 'cos', |
+ 'sin', |
+ 'tan', |
+ 'exp', |
+ 'log', |
+ 'atan2', |
+ 'pow', |
+ 'imul', |
+ 'fround', |
+]; |
+ |
+ |
+(function TestBadStdlib() { |
function Module(stdlib) { |
"use asm"; |
- var StdlibNaN = stdlib.NaN; |
- function foo() { return +StdlibNaN; } |
+ var foo = stdlib.NaN; |
return {}; |
} |
- assertThrows(function() { |
- Wasm.instantiateModuleFromAsm(Module.toString(), { NaN: 0 }); |
- }); |
+ for (var i = 0; i < stdlib_root_members.length; ++i) { |
+ var member = stdlib_root_members[i]; |
+ var stdlib = {}; |
+ stdlib[member] = 0; |
+ print(member); |
+ var code = Module.toString().replace('NaN', member); |
+ assertThrows(function() { |
+ Wasm.instantiateModuleFromAsm(code, stdlib); |
+ }); |
+ } |
+ for (var i = 0; i < stdlib_math_members.length; ++i) { |
+ var member = stdlib_math_members[i]; |
+ var stdlib = {Math:{}}; |
+ stdlib['Math'][member] = 0; |
+ print(member); |
+ var code = Module.toString().replace('NaN', 'Math.' + member); |
+ assertThrows(function() { |
+ Wasm.instantiateModuleFromAsm(code, stdlib); |
+ }); |
+ } |
})(); |
(function TestMissingNaNStdlib() { |
function Module(stdlib) { |
"use asm"; |
- var StdlibNaN = stdlib.NaN; |
- function foo() { return +StdlibNaN; } |
+ var foo = stdlib.NaN; |
return {}; |
} |
- assertThrows(function() { |
- Wasm.instantiateModuleFromAsm(Module.toString(), {}); |
- }); |
+ for (var i = 0; i < stdlib_root_members.length; ++i) { |
+ var member = stdlib_root_members[i]; |
+ var code = Module.toString().replace('NaN', member); |
+ assertThrows(function() { |
+ Wasm.instantiateModuleFromAsm(code, {}); |
+ }); |
+ } |
+ for (var i = 0; i < stdlib_math_members.length; ++i) { |
+ var member = stdlib_math_members[i]; |
+ var code = Module.toString().replace('NaN', 'Math.' + member); |
+ assertThrows(function() { |
+ Wasm.instantiateModuleFromAsm(code, {}); |
+ }); |
+ } |
})(); |