From cacd5366a6707cb030e212ea3cc46052168d4006 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 14 Oct 2021 22:16:26 -0700 Subject: stage2: LLVM backend: implement `wrap_optional` AIR and move over some passing tests --- test/behavior/basic.zig | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'test/behavior/basic.zig') diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig index 33e4c6fd8d..23b0970191 100644 --- a/test/behavior/basic.zig +++ b/test/behavior/basic.zig @@ -411,3 +411,38 @@ test "use of declaration with same name as primitive" { const c: @"u8" = 300; try expect(c == 300); } + +fn emptyFn() void {} + +test "constant equal function pointers" { + const alias = emptyFn; + try expect(comptime x: { + break :x emptyFn == alias; + }); +} + +test "multiline string literal is null terminated" { + const s1 = + \\one + \\two) + \\three + ; + const s2 = "one\ntwo)\nthree"; + try expect(std.cstr.cmp(s1, s2) == 0); +} + +test "self reference through fn ptr field" { + const S = struct { + const A = struct { + f: fn (A) u8, + }; + + fn foo(a: A) u8 { + _ = a; + return 12; + } + }; + var a: S.A = undefined; + a.f = S.foo; + try expect(a.f(a) == 12); +} -- cgit v1.2.3