OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --expose-wasm | 5 // Flags: --expose-wasm |
6 | 6 |
7 'use strict'; | 7 'use strict'; |
8 | 8 |
9 load("test/mjsunit/wasm/wasm-constants.js"); | 9 load("test/mjsunit/wasm/wasm-constants.js"); |
10 load("test/mjsunit/wasm/wasm-module-builder.js"); | 10 load("test/mjsunit/wasm/wasm-module-builder.js"); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 assertCompileError(builder().addFunction("f", kSig_v_v).addBody([ | 64 assertCompileError(builder().addFunction("f", kSig_v_v).addBody([ |
65 kExprGetLocal, 0 | 65 kExprGetLocal, 0 |
66 ]).end().toBuffer()); | 66 ]).end().toBuffer()); |
67 assertCompileError(builder().addStart(0).toBuffer()); | 67 assertCompileError(builder().addStart(0).toBuffer()); |
68 })(); | 68 })(); |
69 | 69 |
70 (function TestLinkingError() { | 70 (function TestLinkingError() { |
71 let b; | 71 let b; |
72 | 72 |
73 b = builder(); | 73 b = builder(); |
74 b.addImportWithModule("foo", "bar", kSig_v_v); | 74 b.addImport("foo", "bar", kSig_v_v); |
75 assertTypeError(b.toBuffer(), {}); | 75 assertTypeError(b.toBuffer(), {}); |
76 b = builder(); | 76 b = builder(); |
77 b.addImportWithModule("foo", "bar", kSig_v_v); | 77 b.addImport("foo", "bar", kSig_v_v); |
78 assertLinkError(b.toBuffer(), {foo: {}}); | 78 assertLinkError(b.toBuffer(), {foo: {}}); |
79 b = builder(); | 79 b = builder(); |
80 b.addImportWithModule("foo", "bar", kSig_v_v); | 80 b.addImport("foo", "bar", kSig_v_v); |
81 assertLinkError(b.toBuffer(), {foo: {bar: 9}}); | 81 assertLinkError(b.toBuffer(), {foo: {bar: 9}}); |
82 | 82 |
83 b = builder(); | 83 b = builder(); |
84 b.addImportedGlobal("foo", "bar", kAstI32); | 84 b.addImportedGlobal("foo", "bar", kAstI32); |
85 assertTypeError(b.toBuffer(), {}); | 85 assertTypeError(b.toBuffer(), {}); |
86 b = builder(); | 86 b = builder(); |
87 b.addImportedGlobal("foo", "bar", kAstI32); | 87 b.addImportedGlobal("foo", "bar", kAstI32); |
88 assertLinkError(b.toBuffer(), {foo: {}}); | 88 assertLinkError(b.toBuffer(), {foo: {}}); |
89 b = builder(); | 89 b = builder(); |
90 b.addImportedGlobal("foo", "bar", kAstI32); | 90 b.addImportedGlobal("foo", "bar", kAstI32); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 125 |
126 assertRuntimeError(builder().addFunction("run", kSig_v_v).addBody([ | 126 assertRuntimeError(builder().addFunction("run", kSig_v_v).addBody([ |
127 ]).exportFunc().end(). | 127 ]).exportFunc().end(). |
128 addFunction("start", kSig_v_v).addBody([ | 128 addFunction("start", kSig_v_v).addBody([ |
129 kExprUnreachable | 129 kExprUnreachable |
130 ]).end().addStart(1).toBuffer()); | 130 ]).end().addStart(1).toBuffer()); |
131 })(); | 131 })(); |
132 | 132 |
133 (function TestConversionError() { | 133 (function TestConversionError() { |
134 let b = builder(); | 134 let b = builder(); |
135 b.addImportWithModule("foo", "bar", kSig_v_l); | 135 b.addImport("foo", "bar", kSig_v_l); |
136 assertConversionError(b.addFunction("run", kSig_v_v).addBody([ | 136 assertConversionError(b.addFunction("run", kSig_v_v).addBody([ |
137 kExprI64Const, 0, kExprCallFunction, 0 | 137 kExprI64Const, 0, kExprCallFunction, 0 |
138 ]).exportFunc().end().toBuffer()); | 138 ]).exportFunc().end().toBuffer()); |
139 | 139 |
140 assertConversionError(builder().addFunction("run", kSig_l_v).addBody([ | 140 assertConversionError(builder().addFunction("run", kSig_l_v).addBody([ |
141 kExprI64Const, 0 | 141 kExprI64Const, 0 |
142 ]).exportFunc().end().toBuffer()); | 142 ]).exportFunc().end().toBuffer()); |
143 })(); | 143 })(); |
OLD | NEW |