diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-01-15 01:00:08 +0100 |
---|---|---|
committer | Alon Zakai <azakai@google.com> | 2020-01-14 16:00:08 -0800 |
commit | 5ca79a71b2a2379083093d4d9136b2ae4095dfe8 (patch) | |
tree | 80263fb09290b896362a36d3ae062ee6cb64fb8c /test/binaryen.js/global.js | |
parent | a43b533b0778a1daf47178a3d3d9e559f3d390ed (diff) | |
download | binaryen-5ca79a71b2a2379083093d4d9136b2ae4095dfe8.tar.gz binaryen-5ca79a71b2a2379083093d4d9136b2ae4095dfe8.tar.bz2 binaryen-5ca79a71b2a2379083093d4d9136b2ae4095dfe8.zip |
Align binaryen.js with the npm package (#2551)
Binaryen.js now uses binaryen (was Binaryen) as its global
name to align with the npm package. Also fixes issues with
emitting and testing both the JS and Wasm builds.
Diffstat (limited to 'test/binaryen.js/global.js')
-rw-r--r-- | test/binaryen.js/global.js | 46 |
1 files changed, 19 insertions, 27 deletions
diff --git a/test/binaryen.js/global.js b/test/binaryen.js/global.js index 48571ef93..b0baf2599 100644 --- a/test/binaryen.js/global.js +++ b/test/binaryen.js/global.js @@ -1,7 +1,3 @@ -function assert(x) { - if (!x) throw 'error!'; -} - function cleanInfo(info) { var ret = {}; for (var x in info) { @@ -12,34 +8,30 @@ function cleanInfo(info) { return ret; } -function test() { - var module = new Binaryen.Module(); - module.setFeatures(Binaryen.Features.MVP | Binaryen.Features.MutableGlobals); +var module = new binaryen.Module(); +module.setFeatures(binaryen.Features.MVP | binaryen.Features.MutableGlobals); - var initExpr = module.i32.const(1); - var global = module.addGlobal("a-global", Binaryen.i32, false, initExpr); +var initExpr = module.i32.const(1); +var global = module.addGlobal("a-global", binaryen.i32, false, initExpr); - console.log("GetGlobal is equal: " + (global === module.getGlobal("a-global"))); +console.log("GetGlobal is equal: " + (global === module.getGlobal("a-global"))); - var globalInfo = Binaryen.getGlobalInfo(global); - console.log("getGlobalInfo=" + JSON.stringify(cleanInfo(globalInfo))); +var globalInfo = binaryen.getGlobalInfo(global); +console.log("getGlobalInfo=" + JSON.stringify(cleanInfo(globalInfo))); - var initExpInfo = Binaryen.getExpressionInfo(globalInfo.init); - console.log("getExpressionInfo(init)=" + JSON.stringify(cleanInfo(initExpInfo))); - console.log(Binaryen.emitText(globalInfo.init)); +var initExpInfo = binaryen.getExpressionInfo(globalInfo.init); +console.log("getExpressionInfo(init)=" + JSON.stringify(cleanInfo(initExpInfo))); +console.log(binaryen.emitText(globalInfo.init)); - module.addGlobalExport("a-global", "a-global-exp"); - module.addGlobalImport("a-global-imp", "module", "base", Binaryen.i32, false); - module.addGlobalImport("a-mut-global-imp", "module", "base", Binaryen.i32, true); +module.addGlobalExport("a-global", "a-global-exp"); +module.addGlobalImport("a-global-imp", "module", "base", binaryen.i32, false); +module.addGlobalImport("a-mut-global-imp", "module", "base", binaryen.i32, true); - assert(module.validate()); - console.log(module.emitText()); +assert(module.validate()); +console.log(module.emitText()); - module.removeGlobal("a-global"); - module.removeExport("a-global-exp"); - - assert(module.validate()); - console.log(module.emitText()); -} +module.removeGlobal("a-global"); +module.removeExport("a-global-exp"); -Binaryen.ready.then(test); +assert(module.validate()); +console.log(module.emitText()); |