OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --expose-wasm | |
ahaas
2017/01/24 12:40:14
There is no need for --expose-wasm anymore, is the
titzer
2017/01/24 12:42:56
Gonna keep it, just in case we get turned off :-)
| |
6 | |
7 load('test/mjsunit/wasm/wasm-constants.js'); | |
8 load('test/mjsunit/wasm/wasm-module-builder.js'); | |
9 | |
10 function toBytes(string) { | |
11 var a = new Array(string.length + 1); | |
12 a[0] = string.length; | |
13 for (i = 0; i < string.length; i++) { | |
14 a[i + 1] = string.charCodeAt(i); | |
15 } | |
16 return a; | |
17 } | |
18 | |
19 (function TestEmptyNamesSection() { | |
20 print('TestEmptyNamesSection...'); | |
21 var builder = new WasmModuleBuilder(); | |
22 | |
23 builder.addExplicitSection([kUnknownSectionCode, 6, ...toBytes('name'), 0]); | |
24 | |
25 var buffer = builder.toBuffer(); | |
26 assertTrue(WebAssembly.validate(buffer)); | |
27 assertTrue((new WebAssembly.Module(buffer)) instanceof WebAssembly.Module); | |
28 })(); | |
29 | |
30 (function TestTruncatedNamesSection() { | |
31 print('TestTruncatedNamesSection...'); | |
32 var builder = new WasmModuleBuilder(); | |
33 | |
34 builder.addExplicitSection([kUnknownSectionCode, 6, ...toBytes('name'), 1]); | |
35 | |
36 var buffer = builder.toBuffer(); | |
37 assertTrue(WebAssembly.validate(buffer)); | |
38 assertTrue((new WebAssembly.Module(buffer)) instanceof WebAssembly.Module); | |
39 })(); | |
40 | |
41 (function TestBrokenNamesSection() { | |
42 print('TestBrokenNamesSection...'); | |
43 var builder = new WasmModuleBuilder(); | |
44 | |
45 builder.addExplicitSection( | |
46 [kUnknownSectionCode, 7, ...toBytes('name'), 1, 100]); | |
47 | |
48 var buffer = builder.toBuffer(); | |
49 assertTrue(WebAssembly.validate(buffer)); | |
50 assertTrue((new WebAssembly.Module(buffer)) instanceof WebAssembly.Module); | |
51 })(); | |
OLD | NEW |