| 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 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 unexpectedSuccess() { | 10 function unexpectedSuccess() { |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 | 706 |
| 707 // 'WebAssembly.compile' function | 707 // 'WebAssembly.compile' function |
| 708 let compile = WebAssembly.compile; | 708 let compile = WebAssembly.compile; |
| 709 assertEq(compile, compileDesc.value); | 709 assertEq(compile, compileDesc.value); |
| 710 assertEq(compile.length, 1); | 710 assertEq(compile.length, 1); |
| 711 assertEq(compile.name, 'compile'); | 711 assertEq(compile.name, 'compile'); |
| 712 function assertCompileError(args, err, msg) { | 712 function assertCompileError(args, err, msg) { |
| 713 var error = null; | 713 var error = null; |
| 714 assertPromiseResult(compile(...args), unexpectedSuccess, error => { | 714 assertPromiseResult(compile(...args), unexpectedSuccess, error => { |
| 715 assertTrue(error instanceof err); | 715 assertTrue(error instanceof err); |
| 716 assertTrue(Boolean(error.stack.match('js-api.js'))); | |
| 717 // TODO assertTrue(Boolean(error.message.match(msg))); | 716 // TODO assertTrue(Boolean(error.message.match(msg))); |
| 718 }); | 717 }); |
| 719 } | 718 } |
| 720 assertCompileError([], TypeError, /requires more than 0 arguments/); | 719 assertCompileError([], TypeError, /requires more than 0 arguments/); |
| 721 assertCompileError( | 720 assertCompileError( |
| 722 [undefined], TypeError, | 721 [undefined], TypeError, |
| 723 /first argument must be an ArrayBuffer or typed array object/); | 722 /first argument must be an ArrayBuffer or typed array object/); |
| 724 assertCompileError( | 723 assertCompileError( |
| 725 [1], TypeError, | 724 [1], TypeError, |
| 726 /first argument must be an ArrayBuffer or typed array object/); | 725 /first argument must be an ArrayBuffer or typed array object/); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 753 | 752 |
| 754 // 'WebAssembly.instantiate' function | 753 // 'WebAssembly.instantiate' function |
| 755 let instantiate = WebAssembly.instantiate; | 754 let instantiate = WebAssembly.instantiate; |
| 756 assertEq(instantiate, instantiateDesc.value); | 755 assertEq(instantiate, instantiateDesc.value); |
| 757 assertEq(instantiate.length, 1); | 756 assertEq(instantiate.length, 1); |
| 758 assertEq(instantiate.name, 'instantiate'); | 757 assertEq(instantiate.name, 'instantiate'); |
| 759 function assertInstantiateError(args, err, msg) { | 758 function assertInstantiateError(args, err, msg) { |
| 760 var error = null; | 759 var error = null; |
| 761 assertPromiseResult(instantiate(...args), unexpectedSuccess, error => { | 760 assertPromiseResult(instantiate(...args), unexpectedSuccess, error => { |
| 762 assertTrue(error instanceof err); | 761 assertTrue(error instanceof err); |
| 763 assertTrue(Boolean(error.stack.match('js-api.js'))); | |
| 764 // TODO assertTrue(Boolean(error.message.match(msg))); | 762 // TODO assertTrue(Boolean(error.message.match(msg))); |
| 765 }); | 763 }); |
| 766 } | 764 } |
| 767 var scratch_memory = new WebAssembly.Memory(new ArrayBuffer(10)); | 765 var scratch_memory = new WebAssembly.Memory(new ArrayBuffer(10)); |
| 768 assertInstantiateError([], TypeError, /requires more than 0 arguments/); | 766 assertInstantiateError([], TypeError, /requires more than 0 arguments/); |
| 769 assertInstantiateError( | 767 assertInstantiateError( |
| 770 [undefined], TypeError, /first argument must be a BufferSource/); | 768 [undefined], TypeError, /first argument must be a BufferSource/); |
| 771 assertInstantiateError([1], TypeError, /first argument must be a BufferSource/); | 769 assertInstantiateError([1], TypeError, /first argument must be a BufferSource/); |
| 772 assertInstantiateError( | 770 assertInstantiateError( |
| 773 [{}], TypeError, /first argument must be a BufferSource/); | 771 [{}], TypeError, /first argument must be a BufferSource/); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 }); | 824 }); |
| 827 } | 825 } |
| 828 assertInstantiateSuccess(emptyModule); | 826 assertInstantiateSuccess(emptyModule); |
| 829 assertInstantiateSuccess(emptyModuleBinary); | 827 assertInstantiateSuccess(emptyModuleBinary); |
| 830 assertInstantiateSuccess(emptyModuleBinary.buffer); | 828 assertInstantiateSuccess(emptyModuleBinary.buffer); |
| 831 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); | 829 assertInstantiateSuccess(importingModule, {'': {f: () => {}}}); |
| 832 assertInstantiateSuccess(importingModuleBinary, {'': {f: () => {}}}); | 830 assertInstantiateSuccess(importingModuleBinary, {'': {f: () => {}}}); |
| 833 assertInstantiateSuccess(importingModuleBinary.buffer, {'': {f: () => {}}}); | 831 assertInstantiateSuccess(importingModuleBinary.buffer, {'': {f: () => {}}}); |
| 834 assertInstantiateSuccess( | 832 assertInstantiateSuccess( |
| 835 memoryImportingModuleBinary, {'': {'my_memory': scratch_memory}}); | 833 memoryImportingModuleBinary, {'': {'my_memory': scratch_memory}}); |
| OLD | NEW |