| import * as assert from '../assert.js' |
| |
| /* |
| (module |
| (type $A (array (mut i32))) |
| |
| (func (export "null_src") (result i32) (local (ref $A)) |
| i32.const 4 |
| i32.const 42 |
| array.new $A |
| local.tee 0 |
| i32.const 0 |
| ref.null $A |
| i32.const 0 |
| i32.const 4 |
| array.copy $A $A |
| |
| local.get 0 |
| i32.const 0 |
| array.get $A |
| ) |
| |
| (func (export "null_dst") (result i32) (local (ref $A)) |
| ref.null $A |
| i32.const 0 |
| i32.const 4 |
| i32.const 42 |
| array.new $A |
| local.tee 0 |
| i32.const 0 |
| i32.const 4 |
| array.copy $A $A |
| |
| local.get 0 |
| i32.const 0 |
| array.get $A |
| ) |
| ) |
| */ |
| |
| const wasm = new Uint8Array([ |
| 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x88, 0x80, 0x80, 0x80, 0x00, 0x02, 0x5e, 0x7f, |
| 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03, 0x83, 0x80, 0x80, 0x80, 0x00, 0x02, 0x01, 0x01, 0x07, 0x97, 0x80, |
| 0x80, 0x80, 0x00, 0x02, 0x08, 0x6e, 0x75, 0x6c, 0x6c, 0x5f, 0x73, 0x72, 0x63, 0x00, 0x00, 0x08, 0x6e, |
| 0x75, 0x6c, 0x6c, 0x5f, 0x64, 0x73, 0x74, 0x00, 0x01, 0x0a, 0xcd, 0x80, 0x80, 0x80, 0x00, 0x02, 0xa1, |
| 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x64, 0x00, 0x41, 0x04, 0x41, 0x2a, 0xfb, 0x06, 0x00, 0x22, 0x00, |
| 0x41, 0x00, 0xd0, 0x00, 0x41, 0x00, 0x41, 0x04, 0xfb, 0x11, 0x00, 0x00, 0x20, 0x00, 0x41, 0x00, 0xfb, |
| 0x0b, 0x00, 0x0b, 0xa1, 0x80, 0x80, 0x80, 0x00, 0x01, 0x01, 0x64, 0x00, 0xd0, 0x00, 0x41, 0x00, 0x41, |
| 0x04, 0x41, 0x2a, 0xfb, 0x06, 0x00, 0x22, 0x00, 0x41, 0x00, 0x41, 0x04, 0xfb, 0x11, 0x00, 0x00, 0x20, |
| 0x00, 0x41, 0x00, 0xfb, 0x0b, 0x00, 0x0b |
| ]); |
| |
| let instance = WebAssembly.instantiate(wasm); |
| for (let i = 0; i < 50000; i ++) { |
| assert.throws(() => instance.exports.null_src(), TypeError); |
| assert.throws(() => instance.exports.null_dst(), TypeError); |
| } |