-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test different CLI flags in reference tests (#4264)
- Loading branch information
1 parent
8771907
commit 2a1c7ac
Showing
17 changed files
with
610 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export function add_that_might_fail(a: number, b: number): number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
let wasm; | ||
export function __wbg_set_wasm(val) { | ||
wasm = val; | ||
} | ||
|
||
/** | ||
* @param {number} a | ||
* @param {number} b | ||
* @returns {number} | ||
*/ | ||
export function add_that_might_fail(a, b) { | ||
const ret = wasm.add_that_might_fail(a, b); | ||
return ret >>> 0; | ||
} | ||
|
||
export function __wbg_random_5d40be260a2cfbac() { | ||
const ret = Math.random(); | ||
return ret; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
(module $reference_test.wasm | ||
(type (;0;) (func (param i32 i32) (result i32))) | ||
(func $add_that_might_fail (;0;) (type 0) (param i32 i32) (result i32)) | ||
(memory (;0;) 17) | ||
(export "memory" (memory 0)) | ||
(export "add_that_might_fail" (func $add_that_might_fail)) | ||
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext") | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export function add_that_might_fail(a: number, b: number): number; | ||
|
||
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
|
||
export interface InitOutput { | ||
readonly memory: WebAssembly.Memory; | ||
readonly add_that_might_fail: (a: number, b: number) => number; | ||
readonly __wbindgen_export_0: WebAssembly.Table; | ||
readonly __wbindgen_start: () => void; | ||
} | ||
|
||
export type SyncInitInput = BufferSource | WebAssembly.Module; | ||
/** | ||
* Instantiates the given `module`, which can either be bytes or | ||
* a precompiled `WebAssembly.Module`. | ||
* | ||
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated. | ||
* | ||
* @returns {InitOutput} | ||
*/ | ||
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput; | ||
|
||
/** | ||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and | ||
* for everything else, calls `WebAssembly.instantiate` directly. | ||
* | ||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. | ||
* | ||
* @returns {Promise<InitOutput>} | ||
*/ | ||
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
let wasm; | ||
|
||
/** | ||
* @param {number} a | ||
* @param {number} b | ||
* @returns {number} | ||
*/ | ||
export function add_that_might_fail(a, b) { | ||
const ret = wasm.add_that_might_fail(a, b); | ||
return ret >>> 0; | ||
} | ||
|
||
async function __wbg_load(module, imports) { | ||
if (typeof Response === 'function' && module instanceof Response) { | ||
if (typeof WebAssembly.instantiateStreaming === 'function') { | ||
try { | ||
return await WebAssembly.instantiateStreaming(module, imports); | ||
|
||
} catch (e) { | ||
if (module.headers.get('Content-Type') != 'application/wasm') { | ||
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e); | ||
|
||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
|
||
const bytes = await module.arrayBuffer(); | ||
return await WebAssembly.instantiate(bytes, imports); | ||
|
||
} else { | ||
const instance = await WebAssembly.instantiate(module, imports); | ||
|
||
if (instance instanceof WebAssembly.Instance) { | ||
return { instance, module }; | ||
|
||
} else { | ||
return instance; | ||
} | ||
} | ||
} | ||
|
||
function __wbg_get_imports() { | ||
const imports = {}; | ||
imports.wbg = {}; | ||
imports.wbg.__wbg_random_5d40be260a2cfbac = function() { | ||
const ret = Math.random(); | ||
return ret; | ||
}; | ||
imports.wbg.__wbindgen_init_externref_table = function() { | ||
const table = wasm.__wbindgen_export_0; | ||
const offset = table.grow(4); | ||
table.set(0, undefined); | ||
table.set(offset + 0, undefined); | ||
table.set(offset + 1, null); | ||
table.set(offset + 2, true); | ||
table.set(offset + 3, false); | ||
; | ||
}; | ||
|
||
return imports; | ||
} | ||
|
||
function __wbg_init_memory(imports, memory) { | ||
|
||
} | ||
|
||
function __wbg_finalize_init(instance, module) { | ||
wasm = instance.exports; | ||
__wbg_init.__wbindgen_wasm_module = module; | ||
|
||
|
||
wasm.__wbindgen_start(); | ||
return wasm; | ||
} | ||
|
||
function initSync(module) { | ||
if (wasm !== undefined) return wasm; | ||
|
||
|
||
if (typeof module !== 'undefined') { | ||
if (Object.getPrototypeOf(module) === Object.prototype) { | ||
({module} = module) | ||
} else { | ||
console.warn('using deprecated parameters for `initSync()`; pass a single object instead') | ||
} | ||
} | ||
|
||
const imports = __wbg_get_imports(); | ||
|
||
__wbg_init_memory(imports); | ||
|
||
if (!(module instanceof WebAssembly.Module)) { | ||
module = new WebAssembly.Module(module); | ||
} | ||
|
||
const instance = new WebAssembly.Instance(module, imports); | ||
|
||
return __wbg_finalize_init(instance, module); | ||
} | ||
|
||
async function __wbg_init(module_or_path) { | ||
if (wasm !== undefined) return wasm; | ||
|
||
|
||
if (typeof module_or_path !== 'undefined') { | ||
if (Object.getPrototypeOf(module_or_path) === Object.prototype) { | ||
({module_or_path} = module_or_path) | ||
} else { | ||
console.warn('using deprecated parameters for the initialization function; pass a single object instead') | ||
} | ||
} | ||
|
||
if (typeof module_or_path === 'undefined') { | ||
module_or_path = new URL('reference_test_bg.wasm', import.meta.url); | ||
} | ||
const imports = __wbg_get_imports(); | ||
|
||
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) { | ||
module_or_path = fetch(module_or_path); | ||
} | ||
|
||
__wbg_init_memory(imports); | ||
|
||
const { instance, module } = await __wbg_load(await module_or_path, imports); | ||
|
||
return __wbg_finalize_init(instance, module); | ||
} | ||
|
||
export { initSync }; | ||
export default __wbg_init; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(module $reference_test.wasm | ||
(type (;0;) (func)) | ||
(type (;1;) (func (param i32 i32) (result i32))) | ||
(import "wbg" "__wbindgen_init_externref_table" (func (;0;) (type 0))) | ||
(func $add_that_might_fail (;1;) (type 1) (param i32 i32) (result i32)) | ||
(table (;0;) 128 externref) | ||
(memory (;0;) 17) | ||
(export "memory" (memory 0)) | ||
(export "add_that_might_fail" (func $add_that_might_fail)) | ||
(export "__wbindgen_export_0" (table 0)) | ||
(export "__wbindgen_start" (func 0)) | ||
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext") | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
declare namespace wasm_bindgen { | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export function add_that_might_fail(a: number, b: number): number; | ||
|
||
} | ||
|
||
declare type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module; | ||
|
||
declare interface InitOutput { | ||
readonly memory: WebAssembly.Memory; | ||
readonly add_that_might_fail: (a: number, b: number) => number; | ||
readonly __wbindgen_export_0: WebAssembly.Table; | ||
readonly __wbindgen_start: () => void; | ||
} | ||
|
||
/** | ||
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and | ||
* for everything else, calls `WebAssembly.instantiate` directly. | ||
* | ||
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated. | ||
* | ||
* @returns {Promise<InitOutput>} | ||
*/ | ||
declare function wasm_bindgen (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>; |
Oops, something went wrong.