Add basic tests for the new builtins

This commit is contained in:
Jakub Konka 2020-06-02 13:26:49 +02:00 committed by Andrew Kelley
parent 146be2a8cb
commit 73a3bfd1dd
3 changed files with 29 additions and 0 deletions

View File

@ -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",
});
}

View File

@ -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");
}

View 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());
}