Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/runtime/test_primitive_types.zig
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ const Primitives = struct {
a.* += @intCast(arr.len);
}
}

// return uint8Array
pub fn _uint8Array(_: *const Primitives, arr: []u8) []u8 {
return arr;
}

pub fn _uint16Array(_: *const Primitives, arr: []u16) []u16 {
return arr;
}
};

const testing = @import("testing.zig");
Expand Down Expand Up @@ -281,4 +290,13 @@ test "JS: primitive types" {
.{ "try { p.intu64(arr_i64) } catch(e) { e instanceof TypeError; }", "true" },
.{ "try { p.intu64(arr_u32) } catch(e) { e instanceof TypeError; }", "true" },
}, .{});

// returns array type
try runner.testCases(&.{
.{ "const re_arr_u16 = p.uint16Array(new Uint16Array([10, 20, 30]))", "undefined" },
.{ "re_arr_u16", "10,20,30" },

.{ "const re_arr_u8 = p.uint8Array(new Uint8Array([10, 20, 30]))", "undefined" },
.{ "re_arr_u8", "10,20,30" },
}, .{});
}
Loading