Skip to content

Commit 0080366

Browse files
committed
add u8 and u16 array return
1 parent deded47 commit 0080366

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/runtime/test_primitive_types.zig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,15 @@ const Primitives = struct {
149149
a.* += @intCast(arr.len);
150150
}
151151
}
152+
153+
// return uint8Array
154+
pub fn _uint8Array(_: *const Primitives, arr: []u8) []u8 {
155+
return arr;
156+
}
157+
158+
pub fn _uint16Array(_: *const Primitives, arr: []u16) []u16 {
159+
return arr;
160+
}
152161
};
153162

154163
const testing = @import("testing.zig");
@@ -281,4 +290,13 @@ test "JS: primitive types" {
281290
.{ "try { p.intu64(arr_i64) } catch(e) { e instanceof TypeError; }", "true" },
282291
.{ "try { p.intu64(arr_u32) } catch(e) { e instanceof TypeError; }", "true" },
283292
}, .{});
293+
294+
// returns array type
295+
try runner.testCases(&.{
296+
.{ "const re_arr_u16 = p.uint16Array(new Uint16Array([10, 20, 30]))", "undefined" },
297+
.{ "re_arr_u16", "10,20,30" },
298+
299+
.{ "const re_arr_u8 = p.uint8Array(new Uint8Array([10, 20, 30]))", "undefined" },
300+
.{ "re_arr_u8", "10,20,30" },
301+
}, .{});
284302
}

0 commit comments

Comments
 (0)