| function shouldBe(actual, expected) { |
| throw new Error('bad value: ' + actual); |
| wasm/locals.wasm is generated by pack-asmjs <https://github.com/WebAssembly/polyfill-prototype-1> from the following script: |
| function asmModule(global, env, buffer) { |
| function testSetLocalExpression1() { |
| function testSetLocalExpression2() { |
| return (x + (((x = 3) + x) | 0)) | 0; |
| function testSetLocalExpression3() { |
| return (x + (((x = ((x + 1) | 0)) + x) | 0)) | 0; |
| testSetLocalExpression1: testSetLocalExpression1, |
| testSetLocalExpression2: testSetLocalExpression2, |
| testSetLocalExpression3: testSetLocalExpression3, |
| var module = loadWebAssembly("wasm/locals.wasm"); |
| shouldBe(module.sum(12, 30), 42); |
| shouldBe(module.add1(42), 43); |
| shouldBe(module.testSetLocalExpression1(), 2); |
| shouldBe(module.testSetLocalExpression2(), 7); |
| shouldBe(module.testSetLocalExpression3(), 5); |