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