aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/call.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-02-27 18:23:50 +0200
committerAndrew Kelley <andrew@ziglang.org>2022-02-27 18:59:44 -0500
commit87dc60e8de58a392fe6e5e6b4dd5c41f487d367a (patch)
tree4f76d7c2b0a51a4c917bb31b539bb54fe33fd542 /test/behavior/call.zig
parent720a5f87d402740045cc28650726c42adb521166 (diff)
downloadzig-87dc60e8de58a392fe6e5e6b4dd5c41f487d367a.tar.gz
zig-87dc60e8de58a392fe6e5e6b4dd5c41f487d367a.zip
stage2: implement builtin_call
Diffstat (limited to 'test/behavior/call.zig')
-rw-r--r--test/behavior/call.zig23
1 files changed, 21 insertions, 2 deletions
diff --git a/test/behavior/call.zig b/test/behavior/call.zig
index 69e8fc6570..57bc0fb3f7 100644
--- a/test/behavior/call.zig
+++ b/test/behavior/call.zig
@@ -3,6 +3,21 @@ const std = @import("std");
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
+test "super basic invocations" {
+ const foo = struct {
+ fn foo() i32 {
+ return 1234;
+ }
+ }.foo;
+ try expect(@call(.{}, foo, .{}) == 1234);
+ comptime try expect(@call(.{ .modifier = .always_inline }, foo, .{}) == 1234);
+ {
+ // comptime call without comptime keyword
+ const result = @call(.{ .modifier = .compile_time }, foo, .{}) == 1234;
+ comptime try expect(result);
+ }
+}
+
test "basic invocations" {
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
@@ -34,7 +49,10 @@ test "basic invocations" {
}
test "tuple parameters" {
- if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
const add = struct {
fn add(a: i32, b: i32) i32 {
@@ -47,7 +65,8 @@ test "tuple parameters" {
try expect(@call(.{}, add, .{ 12, b }) == 46);
try expect(@call(.{}, add, .{ a, b }) == 46);
try expect(@call(.{}, add, .{ 12, 34 }) == 46);
- comptime try expect(@call(.{}, add, .{ 12, 34 }) == 46);
+ if (builtin.zig_backend == .stage1) comptime try expect(@call(.{}, add, .{ 12, 34 }) == 46); // TODO
+ try expect(comptime @call(.{}, add, .{ 12, 34 }) == 46);
{
const separate_args0 = .{ a, b };
const separate_args1 = .{ a, 34 };