Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/mjsunit/wasm/ffi-error.js

Issue 2591753002: [wasm] Implement correct 2-level namespace for imports. (Closed)
Patch Set: Fix debug tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/wasm/ffi.js ('k') | test/mjsunit/wasm/gc-buffer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 load("test/mjsunit/wasm/wasm-constants.js"); 7 load("test/mjsunit/wasm/wasm-constants.js");
8 load("test/mjsunit/wasm/wasm-module-builder.js"); 8 load("test/mjsunit/wasm/wasm-module-builder.js");
9 9
10 function testCallFFI(ffi) { 10 function testCallFFI(ffi) {
11 var builder = new WasmModuleBuilder(); 11 var builder = new WasmModuleBuilder();
12 12
13 var sig_index = kSig_i_dd; 13 var sig_index = kSig_i_dd;
14 builder.addImport("fun", sig_index); 14 builder.addImport("", "fun", sig_index);
15 builder.addFunction("main", sig_index) 15 builder.addFunction("main", sig_index)
16 .addBody([ 16 .addBody([
17 kExprGetLocal, 0, // -- 17 kExprGetLocal, 0, // --
18 kExprGetLocal, 1, // -- 18 kExprGetLocal, 1, // --
19 kExprCallFunction, 0, // -- 19 kExprCallFunction, 0, // --
20 ]) // -- 20 ]) // --
21 .exportFunc(); 21 .exportFunc();
22 22
23 var module = builder.instantiate(ffi); 23 var module = builder.instantiate(ffi);
24 } 24 }
25 25
26 // everything is good. 26 // everything is good.
27 (function() { 27 (function() {
28 var ffi = new Object(); 28 var ffi = {"": {fun: function(a, b) { print(a, b); }}}
29 ffi.fun = function(a, b) { print(a, b); }
30 testCallFFI(ffi); 29 testCallFFI(ffi);
31 })(); 30 })();
32 31
33 32
34 // FFI object should be an object. 33 // FFI object should be an object.
35 assertThrows(function() { 34 assertThrows(function() {
36 var ffi = 0; 35 var ffi = 0;
37 testCallFFI(ffi); 36 testCallFFI(ffi);
38 }); 37 });
39 38
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 93
95 assertThrows(function() { 94 assertThrows(function() {
96 module.exports.function_with_invalid_signature(33); 95 module.exports.function_with_invalid_signature(33);
97 }, TypeError); 96 }, TypeError);
98 })(); 97 })();
99 98
100 (function I64JSImportThrows() { 99 (function I64JSImportThrows() {
101 var builder = new WasmModuleBuilder(); 100 var builder = new WasmModuleBuilder();
102 var sig_index = builder.addType(kSig_i_i); 101 var sig_index = builder.addType(kSig_i_i);
103 var sig_i64_index = builder.addType(kSig_i_l); 102 var sig_i64_index = builder.addType(kSig_i_l);
104 var index = builder.addImport("func", sig_i64_index); 103 var index = builder.addImport("", "func", sig_i64_index);
105 builder.addFunction("main", sig_index) 104 builder.addFunction("main", sig_index)
106 .addBody([ 105 .addBody([
107 kExprGetLocal, 0, 106 kExprGetLocal, 0,
108 kExprI64SConvertI32, 107 kExprI64SConvertI32,
109 kExprCallFunction, index // -- 108 kExprCallFunction, index // --
110 ]) // -- 109 ]) // --
111 .exportFunc(); 110 .exportFunc();
112 var func = function() {return {};}; 111 var func = function() {return {};};
113 var main = builder.instantiate({func: func}).exports.main; 112 var main = builder.instantiate({"": {func: func}}).exports.main;
114 assertThrows(function() { 113 assertThrows(function() {
115 main(13); 114 main(13);
116 }, TypeError); 115 }, TypeError);
117 })(); 116 })();
118 117
119 (function ImportSymbolToNumberThrows() { 118 (function ImportSymbolToNumberThrows() {
120 var builder = new WasmModuleBuilder(); 119 var builder = new WasmModuleBuilder();
121 var index = builder.addImport("func", kSig_i_v); 120 var index = builder.addImport("", "func", kSig_i_v);
122 builder.addFunction("main", kSig_i_v) 121 builder.addFunction("main", kSig_i_v)
123 .addBody([kExprCallFunction, 0]) 122 .addBody([kExprCallFunction, 0])
124 .exportFunc(); 123 .exportFunc();
125 var func = () => Symbol(); 124 var func = () => Symbol();
126 var main = builder.instantiate({func: func}).exports.main; 125 var main = builder.instantiate({"": {func: func}}).exports.main;
127 assertThrows(() => main(), TypeError); 126 assertThrows(() => main(), TypeError);
128 })(); 127 })();
OLDNEW
« no previous file with comments | « test/mjsunit/wasm/ffi.js ('k') | test/mjsunit/wasm/gc-buffer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698