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 --allow-natives-syntax | 5 // Flags: --expose-wasm --allow-natives-syntax |
6 | 6 |
7 if ((typeof drainJobQueue) != "function") { | 7 if ((typeof drainJobQueue) != "function") { |
8 drainJobQueue = () => { %RunMicrotasks() }; | 8 drainJobQueue = () => { %RunMicrotasks() }; |
9 } | 9 } |
10 | 10 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); | 47 let wasmDesc = Object.getOwnPropertyDescriptor(this, 'WebAssembly'); |
48 assertEq(typeof wasmDesc.value, "object"); | 48 assertEq(typeof wasmDesc.value, "object"); |
49 assertEq(wasmDesc.writable, true); | 49 assertEq(wasmDesc.writable, true); |
50 assertEq(wasmDesc.enumerable, false); | 50 assertEq(wasmDesc.enumerable, false); |
51 assertEq(wasmDesc.configurable, true); | 51 assertEq(wasmDesc.configurable, true); |
52 | 52 |
53 // 'WebAssembly' object | 53 // 'WebAssembly' object |
54 assertEq(WebAssembly, wasmDesc.value); | 54 assertEq(WebAssembly, wasmDesc.value); |
55 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); | 55 //TODO assertEq(String(WebAssembly), "[object WebAssembly]"); |
56 | 56 |
57 // 'WebAssembly.(Compile|Runtime)Error' data property | 57 // 'WebAssembly.CompileError' |
58 let compileErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'CompileErro
r'); | 58 let compileErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'CompileErro
r'); |
| 59 assertEq(typeof compileErrorDesc.value, "function"); |
| 60 assertEq(compileErrorDesc.writable, true); |
| 61 assertEq(compileErrorDesc.enumerable, false); |
| 62 assertEq(compileErrorDesc.configurable, true); |
| 63 let CompileError = WebAssembly.CompileError; |
| 64 assertEq(CompileError, compileErrorDesc.value); |
| 65 assertEq(CompileError.length, 1); |
| 66 assertEq(CompileError.name, "CompileError"); |
| 67 let compileError = new CompileError; |
| 68 assertEq(compileError instanceof CompileError, true); |
| 69 assertEq(compileError instanceof Error, true); |
| 70 assertEq(compileError instanceof TypeError, false); |
| 71 assertEq(compileError.message, ""); |
| 72 assertEq(new CompileError("hi").message, "hi"); |
| 73 |
| 74 // 'WebAssembly.RuntimeError' |
59 let runtimeErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'RuntimeErro
r'); | 75 let runtimeErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'RuntimeErro
r'); |
60 assertEq(typeof compileErrorDesc.value, "function"); | |
61 assertEq(typeof runtimeErrorDesc.value, "function"); | 76 assertEq(typeof runtimeErrorDesc.value, "function"); |
62 if (PROP_FLAGS) assertEq(compileErrorDesc.writable, true); | 77 assertEq(runtimeErrorDesc.writable, true); |
63 if (PROP_FLAGS) assertEq(runtimeErrorDesc.writable, true); | 78 assertEq(runtimeErrorDesc.enumerable, false); |
64 if (PROP_FLAGS) assertEq(compileErrorDesc.enumerable, false); | 79 assertEq(runtimeErrorDesc.configurable, true); |
65 if (PROP_FLAGS) assertEq(runtimeErrorDesc.enumerable, false); | 80 let RuntimeError = WebAssembly.RuntimeError; |
66 if (PROP_FLAGS) assertEq(compileErrorDesc.configurable, true); | 81 assertEq(RuntimeError, runtimeErrorDesc.value); |
67 if (PROP_FLAGS) assertEq(runtimeErrorDesc.configurable, true); | 82 assertEq(RuntimeError.length, 1); |
| 83 assertEq(RuntimeError.name, "RuntimeError"); |
| 84 let runtimeError = new RuntimeError; |
| 85 assertEq(runtimeError instanceof RuntimeError, true); |
| 86 assertEq(runtimeError instanceof Error, true); |
| 87 assertEq(runtimeError instanceof TypeError, false); |
| 88 assertEq(runtimeError.message, ""); |
| 89 assertEq(new RuntimeError("hi").message, "hi"); |
68 | 90 |
69 // 'WebAssembly.(Compile|Runtime)Error' constructor function | 91 // 'WebAssembly.LinkError' |
70 let CompileError = WebAssembly.CompileError; | 92 let linkErrorDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'LinkError'); |
71 let RuntimeError = WebAssembly.RuntimeError; | 93 assertEq(typeof linkErrorDesc.value, "function"); |
72 assertEq(CompileError, compileErrorDesc.value); | 94 assertEq(linkErrorDesc.writable, true); |
73 assertEq(RuntimeError, runtimeErrorDesc.value); | 95 assertEq(linkErrorDesc.enumerable, false); |
74 assertEq(CompileError.length, 1); | 96 assertEq(linkErrorDesc.configurable, true); |
75 assertEq(RuntimeError.length, 1); | 97 let LinkError = WebAssembly.LinkError; |
76 assertEq(CompileError.name, "CompileError"); | 98 assertEq(LinkError, linkErrorDesc.value); |
77 assertEq(RuntimeError.name, "RuntimeError"); | 99 assertEq(LinkError.length, 1); |
78 | 100 assertEq(LinkError.name, "LinkError"); |
79 // 'WebAssembly.(Compile|Runtime)Error' instance objects | 101 let linkError = new LinkError; |
80 let compileError = new CompileError; | 102 assertEq(linkError instanceof LinkError, true); |
81 let runtimeError = new RuntimeError; | 103 assertEq(linkError instanceof Error, true); |
82 assertEq(compileError instanceof CompileError, true); | 104 assertEq(linkError instanceof TypeError, false); |
83 assertEq(runtimeError instanceof RuntimeError, true); | 105 assertEq(linkError.message, ""); |
84 assertEq(compileError instanceof Error, true); | 106 assertEq(new LinkError("hi").message, "hi"); |
85 assertEq(runtimeError instanceof Error, true); | |
86 assertEq(compileError instanceof TypeError, false); | |
87 assertEq(runtimeError instanceof TypeError, false); | |
88 assertEq(compileError.message, ""); | |
89 assertEq(runtimeError.message, ""); | |
90 assertEq(new CompileError("hi").message, "hi"); | |
91 assertEq(new RuntimeError("hi").message, "hi"); | |
92 | 107 |
93 // 'WebAssembly.Module' data property | 108 // 'WebAssembly.Module' data property |
94 let moduleDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Module'); | 109 let moduleDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Module'); |
95 assertEq(typeof moduleDesc.value, "function"); | 110 assertEq(typeof moduleDesc.value, "function"); |
96 assertEq(moduleDesc.writable, true); | 111 assertEq(moduleDesc.writable, true); |
97 assertEq(moduleDesc.enumerable, false); | 112 assertEq(moduleDesc.enumerable, false); |
98 assertEq(moduleDesc.configurable, true); | 113 assertEq(moduleDesc.configurable, true); |
99 | 114 |
100 // 'WebAssembly.Module' constructor function | 115 // 'WebAssembly.Module' constructor function |
101 let Module = WebAssembly.Module; | 116 let Module = WebAssembly.Module; |
102 assertEq(Module, moduleDesc.value); | 117 assertEq(Module, moduleDesc.value); |
103 //TODO assertEq(Module.length, 1); | 118 assertEq(Module.length, 1); |
104 //TODO assertEq(Module.name, "Module"); | 119 assertEq(Module.name, "Module"); |
105 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid
den/); | 120 assertErrorMessage(() => Module(), TypeError, /constructor without new is forbid
den/); |
106 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument
s/); | 121 assertErrorMessage(() => new Module(), TypeError, /requires more than 0 argument
s/); |
107 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must
be an ArrayBuffer or typed array object"); | 122 assertErrorMessage(() => new Module(undefined), TypeError, "first argument must
be an ArrayBuffer or typed array object"); |
108 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar
rayBuffer or typed array object"); | 123 assertErrorMessage(() => new Module(1), TypeError, "first argument must be an Ar
rayBuffer or typed array object"); |
109 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A
rrayBuffer or typed array object"); | 124 assertErrorMessage(() => new Module({}), TypeError, "first argument must be an A
rrayBuffer or typed array object"); |
110 //TODO assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /fai
led to match magic number/); | 125 //TODO assertErrorMessage(() => new Module(new Uint8Array()), CompileError, /fai
led to match magic number/); |
111 //TODO assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /fa
iled to match magic number/); | 126 //TODO assertErrorMessage(() => new Module(new ArrayBuffer()), CompileError, /fa
iled to match magic number/); |
112 assertEq(new Module(emptyModuleBinary) instanceof Module, true); | 127 assertEq(new Module(emptyModuleBinary) instanceof Module, true); |
113 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); | 128 assertEq(new Module(emptyModuleBinary.buffer) instanceof Module, true); |
114 | 129 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // 'WebAssembly.Instance' data property | 215 // 'WebAssembly.Instance' data property |
201 let instanceDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Instance'); | 216 let instanceDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Instance'); |
202 assertEq(typeof instanceDesc.value, "function"); | 217 assertEq(typeof instanceDesc.value, "function"); |
203 assertEq(instanceDesc.writable, true); | 218 assertEq(instanceDesc.writable, true); |
204 assertEq(instanceDesc.enumerable, false); | 219 assertEq(instanceDesc.enumerable, false); |
205 assertEq(instanceDesc.configurable, true); | 220 assertEq(instanceDesc.configurable, true); |
206 | 221 |
207 // 'WebAssembly.Instance' constructor function | 222 // 'WebAssembly.Instance' constructor function |
208 let Instance = WebAssembly.Instance; | 223 let Instance = WebAssembly.Instance; |
209 assertEq(Instance, instanceDesc.value); | 224 assertEq(Instance, instanceDesc.value); |
210 //TODO assertEq(Instance.length, 1); | 225 assertEq(Instance.length, 1); |
211 //TODO assertEq(Instance.name, "Instance"); | 226 assertEq(Instance.name, "Instance"); |
212 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forb
idden/); | 227 assertErrorMessage(() => Instance(), TypeError, /constructor without new is forb
idden/); |
213 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a W
ebAssembly.Module"); | 228 assertErrorMessage(() => new Instance(1), TypeError, "first argument must be a W
ebAssembly.Module"); |
214 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a
WebAssembly.Module"); | 229 assertErrorMessage(() => new Instance({}), TypeError, "first argument must be a
WebAssembly.Module"); |
215 //TODO assertErrorMessage(() => new Instance(emptyModule, null), TypeError, "sec
ond argument must be an object"); | 230 //TODO assertErrorMessage(() => new Instance(emptyModule, null), TypeError, "sec
ond argument must be an object"); |
216 //TODO assertEq(new Instance(emptyModule) instanceof Instance, true); | 231 //TODO assertEq(new Instance(emptyModule) instanceof Instance, true); |
217 //TODO assertEq(new Instance(emptyModule, {}) instanceof Instance, true); | 232 //TODO assertEq(new Instance(emptyModule, {}) instanceof Instance, true); |
218 | 233 |
219 // 'WebAssembly.Instance.prototype' data property | 234 // 'WebAssembly.Instance.prototype' data property |
220 let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype'); | 235 let instanceProtoDesc = Object.getOwnPropertyDescriptor(Instance, 'prototype'); |
221 assertEq(typeof instanceProtoDesc.value, "object"); | 236 assertEq(typeof instanceProtoDesc.value, "object"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 // 'WebAssembly.Memory' data property | 268 // 'WebAssembly.Memory' data property |
254 let memoryDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Memory'); | 269 let memoryDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Memory'); |
255 assertEq(typeof memoryDesc.value, "function"); | 270 assertEq(typeof memoryDesc.value, "function"); |
256 assertEq(memoryDesc.writable, true); | 271 assertEq(memoryDesc.writable, true); |
257 assertEq(memoryDesc.enumerable, false); | 272 assertEq(memoryDesc.enumerable, false); |
258 assertEq(memoryDesc.configurable, true); | 273 assertEq(memoryDesc.configurable, true); |
259 | 274 |
260 // 'WebAssembly.Memory' constructor function | 275 // 'WebAssembly.Memory' constructor function |
261 let Memory = WebAssembly.Memory; | 276 let Memory = WebAssembly.Memory; |
262 assertEq(Memory, memoryDesc.value); | 277 assertEq(Memory, memoryDesc.value); |
263 //TODO assertEq(Memory.length, 1); | 278 assertEq(Memory.length, 1); |
264 //TODO assertEq(Memory.name, "Memory"); | 279 assertEq(Memory.name, "Memory"); |
265 assertErrorMessage(() => Memory(), TypeError, /constructor without new is forbid
den/); | 280 assertErrorMessage(() => Memory(), TypeError, /constructor without new is forbid
den/); |
266 assertErrorMessage(() => new Memory(1), TypeError, "first argument must be a mem
ory descriptor"); | 281 assertErrorMessage(() => new Memory(1), TypeError, "first argument must be a mem
ory descriptor"); |
267 assertErrorMessage(() => new Memory({initial:{valueOf() { throw new Error("here"
)}}}), Error, "here"); | 282 assertErrorMessage(() => new Memory({initial:{valueOf() { throw new Error("here"
)}}}), Error, "here"); |
268 assertErrorMessage(() => new Memory({initial:-1}), RangeError, /bad Memory initi
al size/); | 283 assertErrorMessage(() => new Memory({initial:-1}), RangeError, /bad Memory initi
al size/); |
269 assertErrorMessage(() => new Memory({initial:Math.pow(2,32)}), RangeError, /bad
Memory initial size/); | 284 assertErrorMessage(() => new Memory({initial:Math.pow(2,32)}), RangeError, /bad
Memory initial size/); |
270 assertErrorMessage(() => new Memory({initial:1, maximum: Math.pow(2,32)/Math.pow
(2,14) }), RangeError, /bad Memory maximum size/); | 285 assertErrorMessage(() => new Memory({initial:1, maximum: Math.pow(2,32)/Math.pow
(2,14) }), RangeError, /bad Memory maximum size/); |
271 assertErrorMessage(() => new Memory({initial:2, maximum:1 }), RangeError, /bad M
emory maximum size/); | 286 assertErrorMessage(() => new Memory({initial:2, maximum:1 }), RangeError, /bad M
emory maximum size/); |
272 assertErrorMessage(() => new Memory({maximum: -1 }), RangeError, /bad Memory max
imum size/); | 287 assertErrorMessage(() => new Memory({maximum: -1 }), RangeError, /bad Memory max
imum size/); |
273 assertEq(new Memory({initial:1}) instanceof Memory, true); | 288 assertEq(new Memory({initial:1}) instanceof Memory, true); |
274 assertEq(new Memory({initial:1.5}).buffer.byteLength, kPageSize); | 289 assertEq(new Memory({initial:1.5}).buffer.byteLength, kPageSize); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // 'WebAssembly.Table' data property | 356 // 'WebAssembly.Table' data property |
342 let tableDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Table'); | 357 let tableDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'Table'); |
343 assertEq(typeof tableDesc.value, "function"); | 358 assertEq(typeof tableDesc.value, "function"); |
344 assertEq(tableDesc.writable, true); | 359 assertEq(tableDesc.writable, true); |
345 assertEq(tableDesc.enumerable, false); | 360 assertEq(tableDesc.enumerable, false); |
346 assertEq(tableDesc.configurable, true); | 361 assertEq(tableDesc.configurable, true); |
347 | 362 |
348 // 'WebAssembly.Table' constructor function | 363 // 'WebAssembly.Table' constructor function |
349 let Table = WebAssembly.Table; | 364 let Table = WebAssembly.Table; |
350 assertEq(Table, tableDesc.value); | 365 assertEq(Table, tableDesc.value); |
351 //TODO assertEq(Table.length, 1); | 366 assertEq(Table.length, 1); |
352 //TODO assertEq(Table.name, "Table"); | 367 assertEq(Table.name, "Table"); |
353 assertErrorMessage(() => Table(), TypeError, /constructor without new is forbidd
en/); | 368 assertErrorMessage(() => Table(), TypeError, /constructor without new is forbidd
en/); |
354 assertErrorMessage(() => new Table(1), TypeError, "first argument must be a tabl
e descriptor"); | 369 assertErrorMessage(() => new Table(1), TypeError, "first argument must be a tabl
e descriptor"); |
355 assertErrorMessage(() => new Table({initial:1, element:1}), TypeError, /must be
"anyfunc"/); | 370 assertErrorMessage(() => new Table({initial:1, element:1}), TypeError, /must be
"anyfunc"/); |
356 assertErrorMessage(() => new Table({initial:1, element:"any"}), TypeError, /must
be "anyfunc"/); | 371 assertErrorMessage(() => new Table({initial:1, element:"any"}), TypeError, /must
be "anyfunc"/); |
357 assertErrorMessage(() => new Table({initial:1, element:{valueOf() { return "anyf
unc" }}}), TypeError, /must be "anyfunc"/); | 372 assertErrorMessage(() => new Table({initial:1, element:{valueOf() { return "anyf
unc" }}}), TypeError, /must be "anyfunc"/); |
358 assertErrorMessage(() => new Table({initial:{valueOf() { throw new Error("here")
}}, element:"anyfunc"}), Error, "here"); | 373 assertErrorMessage(() => new Table({initial:{valueOf() { throw new Error("here")
}}, element:"anyfunc"}), Error, "here"); |
359 assertErrorMessage(() => new Table({initial:-1, element:"anyfunc"}), RangeError,
/bad Table initial size/); | 374 assertErrorMessage(() => new Table({initial:-1, element:"anyfunc"}), RangeError,
/bad Table initial size/); |
360 assertErrorMessage(() => new Table({initial:Math.pow(2,32), element:"anyfunc"}),
RangeError, /bad Table initial size/); | 375 assertErrorMessage(() => new Table({initial:Math.pow(2,32), element:"anyfunc"}),
RangeError, /bad Table initial size/); |
361 assertErrorMessage(() => new Table({initial:2, maximum:1, element:"anyfunc"}), R
angeError, /bad Table maximum size/); | 376 assertErrorMessage(() => new Table({initial:2, maximum:1, element:"anyfunc"}), R
angeError, /bad Table maximum size/); |
362 assertErrorMessage(() => new Table({initial:2, maximum:Math.pow(2,32), element:"
anyfunc"}), RangeError, /bad Table maximum size/); | 377 assertErrorMessage(() => new Table({initial:2, maximum:Math.pow(2,32), element:"
anyfunc"}), RangeError, /bad Table maximum size/); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 assertEq(lengthGetter.call(tbl1), 2); | 415 assertEq(lengthGetter.call(tbl1), 2); |
401 | 416 |
402 // 'WebAssembly.Table.prototype.get' data property | 417 // 'WebAssembly.Table.prototype.get' data property |
403 let getDesc = Object.getOwnPropertyDescriptor(tableProto, 'get'); | 418 let getDesc = Object.getOwnPropertyDescriptor(tableProto, 'get'); |
404 assertEq(typeof getDesc.value, "function"); | 419 assertEq(typeof getDesc.value, "function"); |
405 assertEq(getDesc.enumerable, false); | 420 assertEq(getDesc.enumerable, false); |
406 assertEq(getDesc.configurable, true); | 421 assertEq(getDesc.configurable, true); |
407 | 422 |
408 // 'WebAssembly.Table.prototype.get' method | 423 // 'WebAssembly.Table.prototype.get' method |
409 let get = getDesc.value; | 424 let get = getDesc.value; |
410 //TODO:length assertEq(get.length, 1); | 425 assertEq(get.length, 1); |
411 assertErrorMessage(() => get.call(), TypeError, /called on incompatible undefine
d/); | 426 assertErrorMessage(() => get.call(), TypeError, /called on incompatible undefine
d/); |
412 assertErrorMessage(() => get.call({}), TypeError, /called on incompatible Object
/); | 427 assertErrorMessage(() => get.call({}), TypeError, /called on incompatible Object
/); |
413 assertEq(get.call(tbl1, 0), null); | 428 assertEq(get.call(tbl1, 0), null); |
414 assertEq(get.call(tbl1, 1), null); | 429 assertEq(get.call(tbl1, 1), null); |
415 assertEq(get.call(tbl1, 1.5), null); | 430 assertEq(get.call(tbl1, 1.5), null); |
416 assertErrorMessage(() => get.call(tbl1, 2), RangeError, /bad Table get index/); | 431 assertErrorMessage(() => get.call(tbl1, 2), RangeError, /bad Table get index/); |
417 assertErrorMessage(() => get.call(tbl1, 2.5), RangeError, /bad Table get index/)
; | 432 assertErrorMessage(() => get.call(tbl1, 2.5), RangeError, /bad Table get index/)
; |
418 assertErrorMessage(() => get.call(tbl1, -1), RangeError, /bad Table get index/); | 433 assertErrorMessage(() => get.call(tbl1, -1), RangeError, /bad Table get index/); |
419 //TODO assertErrorMessage(() => get.call(tbl1, Math.pow(2,33)), RangeError, /bad
Table get index/); | 434 //TODO assertErrorMessage(() => get.call(tbl1, Math.pow(2,33)), RangeError, /bad
Table get index/); |
420 assertErrorMessage(() => get.call(tbl1, {valueOf() { throw new Error("hi") }}),
Error, "hi"); | 435 assertErrorMessage(() => get.call(tbl1, {valueOf() { throw new Error("hi") }}),
Error, "hi"); |
421 | 436 |
422 // 'WebAssembly.Table.prototype.set' data property | 437 // 'WebAssembly.Table.prototype.set' data property |
423 let setDesc = Object.getOwnPropertyDescriptor(tableProto, 'set'); | 438 let setDesc = Object.getOwnPropertyDescriptor(tableProto, 'set'); |
424 assertEq(typeof setDesc.value, "function"); | 439 assertEq(typeof setDesc.value, "function"); |
425 assertEq(setDesc.enumerable, false); | 440 assertEq(setDesc.enumerable, false); |
426 assertEq(setDesc.configurable, true); | 441 assertEq(setDesc.configurable, true); |
427 | 442 |
428 // 'WebAssembly.Table.prototype.set' method | 443 // 'WebAssembly.Table.prototype.set' method |
429 let set = setDesc.value; | 444 let set = setDesc.value; |
430 //TODO assertEq(set.length, 2); | 445 assertEq(set.length, 2); |
431 assertErrorMessage(() => set.call(), TypeError, /called on incompatible undefine
d/); | 446 assertErrorMessage(() => set.call(), TypeError, /called on incompatible undefine
d/); |
432 assertErrorMessage(() => set.call({}), TypeError, /called on incompatible Object
/); | 447 assertErrorMessage(() => set.call({}), TypeError, /called on incompatible Object
/); |
433 assertErrorMessage(() => set.call(tbl1, 0), TypeError, /requires more than 1 arg
ument/); | 448 assertErrorMessage(() => set.call(tbl1, 0), TypeError, /requires more than 1 arg
ument/); |
434 assertErrorMessage(() => set.call(tbl1, 2, null), RangeError, /bad Table set ind
ex/); | 449 assertErrorMessage(() => set.call(tbl1, 2, null), RangeError, /bad Table set ind
ex/); |
435 assertErrorMessage(() => set.call(tbl1, -1, null), RangeError, /bad Table set in
dex/); | 450 assertErrorMessage(() => set.call(tbl1, -1, null), RangeError, /bad Table set in
dex/); |
436 //TODO assertErrorMessage(() => set.call(tbl1, Math.pow(2,33), null), RangeError
, /bad Table set index/); | 451 //TODO assertErrorMessage(() => set.call(tbl1, Math.pow(2,33), null), RangeError
, /bad Table set index/); |
437 assertErrorMessage(() => set.call(tbl1, 0, undefined), TypeError, /can only assi
gn WebAssembly exported functions to Table/); | 452 assertErrorMessage(() => set.call(tbl1, 0, undefined), TypeError, /can only assi
gn WebAssembly exported functions to Table/); |
438 assertErrorMessage(() => set.call(tbl1, 0, {}), TypeError, /can only assign WebA
ssembly exported functions to Table/); | 453 assertErrorMessage(() => set.call(tbl1, 0, {}), TypeError, /can only assign WebA
ssembly exported functions to Table/); |
439 assertErrorMessage(() => set.call(tbl1, 0, function() {}), TypeError, /can only
assign WebAssembly exported functions to Table/); | 454 assertErrorMessage(() => set.call(tbl1, 0, function() {}), TypeError, /can only
assign WebAssembly exported functions to Table/); |
440 assertErrorMessage(() => set.call(tbl1, 0, Math.sin), TypeError, /can only assig
n WebAssembly exported functions to Table/); | 455 assertErrorMessage(() => set.call(tbl1, 0, Math.sin), TypeError, /can only assig
n WebAssembly exported functions to Table/); |
441 assertErrorMessage(() => set.call(tbl1, {valueOf() { throw Error("hai") }}, null
), Error, "hai"); | 456 assertErrorMessage(() => set.call(tbl1, {valueOf() { throw Error("hai") }}, null
), Error, "hai"); |
442 assertEq(set.call(tbl1, 0, null), undefined); | 457 assertEq(set.call(tbl1, 0, null), undefined); |
443 assertEq(set.call(tbl1, 1, null), undefined); | 458 assertEq(set.call(tbl1, 1, null), undefined); |
444 | 459 |
445 // 'WebAssembly.Table.prototype.grow' data property | 460 // 'WebAssembly.Table.prototype.grow' data property |
446 let tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow'); | 461 let tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow'); |
447 assertEq(typeof tblGrowDesc.value, "function"); | 462 assertEq(typeof tblGrowDesc.value, "function"); |
448 assertEq(tblGrowDesc.enumerable, false); | 463 assertEq(tblGrowDesc.enumerable, false); |
449 assertEq(tblGrowDesc.configurable, true); | 464 assertEq(tblGrowDesc.configurable, true); |
450 | 465 |
451 // 'WebAssembly.Table.prototype.grow' method | 466 // 'WebAssembly.Table.prototype.grow' method |
452 if (false) { // TODO: Table.grow | 467 if (false) { // TODO: Table.grow |
453 let tblGrow = tblGrowDesc.value; | 468 let tblGrow = tblGrowDesc.value; |
454 //TODO assertEq(tblGrow.length, 1); | 469 assertEq(tblGrow.length, 1); |
455 assertErrorMessage(() => tblGrow.call(), TypeError, /called on incompatible unde
fined/); | 470 assertErrorMessage(() => tblGrow.call(), TypeError, /called on incompatible unde
fined/); |
456 assertErrorMessage(() => tblGrow.call({}), TypeError, /called on incompatible Ob
ject/); | 471 assertErrorMessage(() => tblGrow.call({}), TypeError, /called on incompatible Ob
ject/); |
457 assertErrorMessage(() => tblGrow.call(tbl1, -1), RangeError, /bad Table grow del
ta/); | 472 assertErrorMessage(() => tblGrow.call(tbl1, -1), RangeError, /bad Table grow del
ta/); |
458 assertErrorMessage(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError, /bad Ta
ble grow delta/); | 473 assertErrorMessage(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError, /bad Ta
ble grow delta/); |
459 var tbl = new Table({element:"anyfunc", initial:1, maximum:2}); | 474 var tbl = new Table({element:"anyfunc", initial:1, maximum:2}); |
460 assertEq(tbl.length, 1); | 475 assertEq(tbl.length, 1); |
461 assertEq(tbl.grow(0), 1); | 476 assertEq(tbl.grow(0), 1); |
462 assertEq(tbl.length, 1); | 477 assertEq(tbl.length, 1); |
463 assertEq(tbl.grow(1), 1); | 478 assertEq(tbl.grow(1), 1); |
464 assertEq(tbl.length, 2); | 479 assertEq(tbl.length, 2); |
465 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); | 480 assertErrorMessage(() => tbl.grow(1), Error, /failed to grow table/); |
466 } | 481 } |
467 | 482 |
468 // 'WebAssembly.compile' data property | 483 // 'WebAssembly.compile' data property |
469 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); | 484 let compileDesc = Object.getOwnPropertyDescriptor(WebAssembly, 'compile'); |
470 assertEq(typeof compileDesc.value, "function"); | 485 assertEq(typeof compileDesc.value, "function"); |
471 assertEq(compileDesc.writable, true); | 486 assertEq(compileDesc.writable, true); |
472 assertEq(compileDesc.enumerable, false); | 487 assertEq(compileDesc.enumerable, false); |
473 assertEq(compileDesc.configurable, true); | 488 assertEq(compileDesc.configurable, true); |
474 | 489 |
475 // 'WebAssembly.compile' function | 490 // 'WebAssembly.compile' function |
476 let compile = WebAssembly.compile; | 491 let compile = WebAssembly.compile; |
477 assertEq(compile, compileDesc.value); | 492 assertEq(compile, compileDesc.value); |
478 //TODO assertEq(compile.length, 1); | 493 assertEq(compile.length, 1); |
479 //TODO assertEq(compile.name, "compile"); | 494 assertEq(compile.name, "compile"); |
480 function assertCompileError(args, err, msg) { | 495 function assertCompileError(args, err, msg) { |
481 var error = null; | 496 var error = null; |
482 try { | 497 try { |
483 compile(...args).catch(e => error = e); | 498 compile(...args).catch(e => error = e); |
484 } catch (e) { | 499 } catch (e) { |
485 // TODO: error shouldn't be thrown, but should be globbed onto the promise. | 500 // TODO: error shouldn't be thrown, but should be globbed onto the promise. |
486 error = e; | 501 error = e; |
487 } | 502 } |
488 drainJobQueue(); | 503 drainJobQueue(); |
489 assertEq(error instanceof err, true); | 504 assertEq(error instanceof err, true); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 assertEq(result.instance instanceof Instance, true); | 565 assertEq(result.instance instanceof Instance, true); |
551 } | 566 } |
552 } | 567 } |
553 assertInstantiateSuccess(emptyModule); | 568 assertInstantiateSuccess(emptyModule); |
554 assertInstantiateSuccess(emptyModuleBinary); | 569 assertInstantiateSuccess(emptyModuleBinary); |
555 assertInstantiateSuccess(emptyModuleBinary.buffer); | 570 assertInstantiateSuccess(emptyModuleBinary.buffer); |
556 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); | 571 assertInstantiateSuccess(importingModule, {"":{f:()=>{}}}); |
557 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); | 572 assertInstantiateSuccess(importingModuleBinary, {"":{f:()=>{}}}); |
558 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); | 573 assertInstantiateSuccess(importingModuleBinary.buffer, {"":{f:()=>{}}}); |
559 } | 574 } |
OLD | NEW |