add more interpreter tests

This commit is contained in:
Techatrix 2023-01-20 22:25:19 +01:00
parent 6d12c640ee
commit 89ac9d00f5

View File

@ -83,6 +83,39 @@ test "ComptimeInterpreter - if" {
, .{ .simple = .bool }, .{ .simple = .bool_false }); , .{ .simple = .bool }, .{ .simple = .bool_false });
} }
test "ComptimeInterpreter - field access" {
if (true) return error.SkipZigTest; // TODO
try testExprCheck(
\\blk: {
\\ const foo = struct {alpha: u32, beta: bool} = undefined;
\\ break :blk foo.beta;
\\}
, .{ .simple = .bool }, null);
}
test "ComptimeInterpreter - pointer operations" {
if (true) return error.SkipZigTest; // TODO
try testExprCheck(
\\blk: {
\\ const foo: []const u8 = "";
\\ break :blk foo.len;
\\}
, .{ .simple = .usize }, .{ .bytes = "" });
try testExprCheck(
\\blk: {
\\ const foo = true;
\\ break :blk &foo;
\\}
, @panic("TODO"), .{ .simple = .bool_true });
try testExprCheck(
\\blk: {
\\ const foo = true;
\\ const bar = &foo;
\\ break :blk bar.*;
\\}
, @panic("TODO"), .{ .simple = .bool_true });
}
test "ComptimeInterpreter - call return primitive type" { test "ComptimeInterpreter - call return primitive type" {
try testCallCheck( try testCallCheck(
\\pub fn Foo() type { \\pub fn Foo() type {