8f4e8a34e6bed03cf4d5b2d88497ce8ddf6de95c
[WebKit-https.git] / JSTests / wasm / js-api / validate.js
1 import * as assert from '../assert.js';
2 import Builder from '../Builder.js';
3
4 assert.isFunction(WebAssembly.validate);
5 assert.isFunction(WebAssembly.__proto__.validate);
6 assert.eq(WebAssembly.validate.length, 1);
7
8 {
9     const builder = (new Builder())
10         .Type().End()
11         .Import().Memory("imp", "memory", {initial: 20}).End()
12         .Function().End()
13         .Memory().InitialMaxPages(1, 1).End()
14         .Export().End()
15         .Code()
16         .End();
17
18     assert.truthy(!WebAssembly.validate(builder.WebAssembly().get()));
19 }
20
21 {
22     const builder = (new Builder())
23         .Type().End()
24         .Import().Memory("imp", "memory", {initial: 20}).End()
25         .Function().End()
26         .Export().End()
27         .Code()
28         .End();
29
30     assert.truthy(WebAssembly.validate(builder.WebAssembly().get()));
31 }