mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
Add basic tests for the new builtins
This commit is contained in:
parent
146be2a8cb
commit
73a3bfd1dd
@ -7504,4 +7504,22 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
, &[_][]const u8{
|
||||
":3:52: error: slice '[]const u8' cannot have its bytes reinterpreted",
|
||||
});
|
||||
|
||||
cases.add("wasmMemorySize is a compile error in non-Wasm targets",
|
||||
\\export fn foo() void {
|
||||
\\ _ = @wasmMemorySize();
|
||||
\\ return;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:9: error: @wasmMemorySize is a wasm32 feature only",
|
||||
});
|
||||
|
||||
cases.add("wasmMemoryGrow is a compile error in non-Wasm targets",
|
||||
\\export fn foo() void {
|
||||
\\ _ = @wasmMemoryGrow(1);
|
||||
\\ return;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:2:9: error: @wasmMemoryGrow is a wasm32 feature only",
|
||||
});
|
||||
}
|
||||
|
||||
@ -126,6 +126,9 @@ comptime {
|
||||
_ = @import("behavior/var_args.zig");
|
||||
_ = @import("behavior/vector.zig");
|
||||
_ = @import("behavior/void.zig");
|
||||
if (builtin.arch == .wasm32) {
|
||||
_ = @import("behavior/wasm.zig");
|
||||
}
|
||||
_ = @import("behavior/while.zig");
|
||||
_ = @import("behavior/widening.zig");
|
||||
}
|
||||
|
||||
8
test/stage1/behavior/wasm.zig
Normal file
8
test/stage1/behavior/wasm.zig
Normal file
@ -0,0 +1,8 @@
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "memory size and grow" {
|
||||
var prev = @wasmMemorySize();
|
||||
expect(prev == @wasmMemoryGrow(1));
|
||||
expect(prev + 1 == @wasmMemorySize());
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user