-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #3469 from Cellule:users/micfer/wasm/reserved Make sure reserved value are 0 Fixes #3450
- Loading branch information
Showing
3 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
/* global assert,testRunner */ // eslint rule | ||
WScript.LoadScriptFile("../UnitTestFrameWork/UnitTestFrameWork.js"); | ||
WScript.LoadScriptFile("../wasmspec/testsuite/harness/wasm-constants.js"); | ||
WScript.LoadScriptFile("../wasmspec/testsuite/harness/wasm-module-builder.js"); | ||
WScript.Flag("-off:wasmdeferred"); | ||
|
||
function makeReservedTest(name, body, msg) { | ||
return { | ||
name, | ||
body() { | ||
const builder = new WasmModuleBuilder(); | ||
builder.addFunction(null, kSig_v_i).addBody(body); | ||
try { | ||
new WebAssembly.Module(builder.toBuffer()); | ||
assert.fail("Expected an exception"); | ||
} catch (e) { | ||
if (!(e instanceof WebAssembly.CompileError) || RegExp(msg, "i").test(e.message)) { | ||
return; | ||
} | ||
assert.fail(`Expected error message: ${msg}. Got ${e.message}`); | ||
} | ||
} | ||
} | ||
} | ||
|
||
const tests = [ | ||
makeReservedTest("current_memory reserved", [kExprMemorySize, 1], "current_memory reserved value must be 0"), | ||
makeReservedTest("grow_memory reserved", [kExprGrowMemory, 1], "grow_memory reserved value must be 0"), | ||
makeReservedTest("call_indirect reserved", [kExprCallIndirect, 1], "call_indirect reserved value must be 0"), | ||
]; | ||
|
||
WScript.LoadScriptFile("../UnitTestFrameWork/yargs.js"); | ||
const argv = yargsParse(WScript.Arguments, { | ||
boolean: ["verbose"], | ||
number: ["start", "end"], | ||
default: { | ||
verbose: true, | ||
start: 0, | ||
end: tests.length | ||
} | ||
}).argv; | ||
|
||
const todoTests = tests | ||
.slice(argv.start, argv.end); | ||
|
||
testRunner.run(todoTests, {verbose: argv.verbose}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters