Skip to content

Commit

Permalink
Improve tests for evaluation order. (WebAssembly#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger authored and binji committed Feb 20, 2019
1 parent 5f04d2d commit e638ed4
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions test/js-api/memory/constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,46 @@ test(() => {
},
};
},
});

get shared() {
order.push("shared");
assert_array_equals(order, [
"initial",
"initial valueOf",
"maximum",
"maximum valueOf",
]);
}, "Order of evaluation for descriptor");

test(t => {
const order = [];

new WebAssembly.Memory({
get maximum() {
order.push("maximum");
return {
valueOf() {
order.push("shared valueOf");
return true;
order.push("maximum valueOf");
return 1;
},
};
},

get initial() {
order.push("initial");
return {
valueOf() {
order.push("initial valueOf");
return 1;
},
};
},

get shared() {
order.push("shared");
return {
valueOf: t.unreached_func("should not call shared valueOf"),
};
},
});

assert_array_equals(order, [
Expand All @@ -143,9 +173,8 @@ test(() => {
"maximum",
"maximum valueOf",
"shared",
"shared valueOf",
]);
}, "Order of evaluation for descriptor");
}, "Order of evaluation for descriptor (with shared)");

test(() => {
const argument = { "initial": 0 };
Expand Down

0 comments on commit e638ed4

Please sign in to comment.