blob: 3ce087043ab0d1952e36c8fad60da59dfb599d57 [file] [log] [blame]
//@ skip
function shouldBe(actual, expected) {
if (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) {
"use asm";
function sum(x, y) {
x = x | 0;
y = y | 0;
var result = 0;
result = (x + y) | 0;
return result | 0;
}
function add1(x) {
x = x | 0;
return (x + 1) | 0;
}
function testSetLocalExpression1() {
var x = 0;
return (x = 2);
}
function testSetLocalExpression2() {
var x = 0;
x = 1;
return (x + (((x = 3) + x) | 0)) | 0;
}
function testSetLocalExpression3() {
var x = 0;
x = 1;
return (x + (((x = ((x + 1) | 0)) + x) | 0)) | 0;
}
return {
sum: sum,
add1: add1,
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);