Skip to content

Commit

Permalink
Add u128 test
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment committed Nov 13, 2024
1 parent 09f8f4d commit 0da750e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/cli/tests/reference/wasm-export-types.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/* tslint:disable */
/* eslint-disable */
export function example(a: number, b: bigint, c: any, d: string): string;
export function example_128(a: bigint): bigint | undefined;

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly example: (a: number, b: bigint, c: any, d: number, e: number) => [number, number];
readonly example_128: (a: bigint, b: bigint) => [number, bigint, bigint];
readonly __wbindgen_export_0: WebAssembly.Table;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
Expand Down
9 changes: 9 additions & 0 deletions crates/cli/tests/reference/wasm-export-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ export function example(a, b, c, d) {
}
}

/**
* @param {bigint} a
* @returns {bigint | undefined}
*/
export function example_128(a) {
const ret = wasm.example_128(a, a >> BigInt(64));
return ret[0] === 0 ? undefined : (BigInt.asUintN(64, ret[1]) | (BigInt.asUintN(64, ret[2]) << BigInt(64)));
}

async function __wbg_load(module, imports) {
if (typeof Response === 'function' && module instanceof Response) {
if (typeof WebAssembly.instantiateStreaming === 'function') {
Expand Down
5 changes: 5 additions & 0 deletions crates/cli/tests/reference/wasm-export-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ use wasm_bindgen::prelude::*;
pub fn example(a: u32, b: u64, c: JsValue, d: &str) -> String {
todo!()
}

#[wasm_bindgen]
pub fn example_128(a: u128) -> Option<u128> {
None
}
3 changes: 3 additions & 0 deletions crates/cli/tests/reference/wasm-export-types.wat
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
(type (;2;) (func (param i32 i32 i32)))
(type (;3;) (func (param i32 i32 i32 i32) (result i32)))
(type (;4;) (func (param i32 i64 externref i32 i32) (result i32 i32)))
(type (;5;) (func (param i64 i64) (result i32 i64 i64)))
(import "wbg" "__wbindgen_init_externref_table" (func (;0;) (type 0)))
(func $__wbindgen_realloc (;1;) (type 3) (param i32 i32 i32 i32) (result i32))
(func $__wbindgen_malloc (;2;) (type 1) (param i32 i32) (result i32))
(func $__wbindgen_free (;3;) (type 2) (param i32 i32 i32))
(func $"example externref shim multivalue shim" (;4;) (type 4) (param i32 i64 externref i32 i32) (result i32 i32))
(func $"example_128 multivalue shim" (;5;) (type 5) (param i64 i64) (result i32 i64 i64))
(table (;0;) 128 externref)
(memory (;0;) 17)
(export "memory" (memory 0))
(export "example" (func $"example externref shim multivalue shim"))
(export "example_128" (func $"example_128 multivalue shim"))
(export "__wbindgen_export_0" (table 0))
(export "__wbindgen_malloc" (func $__wbindgen_malloc))
(export "__wbindgen_realloc" (func $__wbindgen_realloc))
Expand Down

0 comments on commit 0da750e

Please sign in to comment.