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/event.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/event.js')
-rw-r--r-- | test/binaryen.js/event.js | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/test/binaryen.js/event.js b/test/binaryen.js/event.js index f728e9228..73af158f9 100644 --- a/test/binaryen.js/event.js +++ b/test/binaryen.js/event.js @@ -1,7 +1,3 @@ -function assert(x) { - if (!x) throw 'error!'; -} - function cleanInfo(info) { var ret = {}; for (var x in info) { @@ -10,30 +6,26 @@ function cleanInfo(info) { return ret; } -function test() { - var module = new Binaryen.Module(); - module.setFeatures(Binaryen.Features.ExceptionHandling); +var module = new binaryen.Module(); +module.setFeatures(binaryen.Features.ExceptionHandling); - var pairType = Binaryen.createType([Binaryen.i32, Binaryen.f32]); +var pairType = binaryen.createType([binaryen.i32, binaryen.f32]); - var event_ = module.addEvent("a-event", 0, Binaryen.i32, Binaryen.none); +var event_ = module.addEvent("a-event", 0, binaryen.i32, binaryen.none); - console.log("GetEvent is equal: " + (event_ === module.getEvent("a-event"))); +console.log("GetEvent is equal: " + (event_ === module.getEvent("a-event"))); - var eventInfo = Binaryen.getEventInfo(event_); - console.log("getEventInfo=" + JSON.stringify(cleanInfo(eventInfo))); +var eventInfo = binaryen.getEventInfo(event_); +console.log("getEventInfo=" + JSON.stringify(cleanInfo(eventInfo))); - module.addEventExport("a-event", "a-event-exp"); - module.addEventImport("a-event-imp", "module", "base", 0, pairType, Binaryen.none); +module.addEventExport("a-event", "a-event-exp"); +module.addEventImport("a-event-imp", "module", "base", 0, pairType, binaryen.none); - assert(module.validate()); - console.log(module.emitText()); +assert(module.validate()); +console.log(module.emitText()); - module.removeExport("a-event-exp"); - module.removeEvent("a-event"); - - assert(module.validate()); - console.log(module.emitText()); -} +module.removeExport("a-event-exp"); +module.removeEvent("a-event"); -Binaryen.ready.then(test); +assert(module.validate()); +console.log(module.emitText()); |