diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-14 22:16:26 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-14 22:16:26 -0700 |
| commit | cacd5366a6707cb030e212ea3cc46052168d4006 (patch) | |
| tree | 8e6d5d7c40bb763acd180040af8396d4198cbe92 /test/behavior/basic.zig | |
| parent | 55eea3b045c86c78eb8d9cc862122d260352a631 (diff) | |
| download | zig-cacd5366a6707cb030e212ea3cc46052168d4006.tar.gz zig-cacd5366a6707cb030e212ea3cc46052168d4006.zip | |
stage2: LLVM backend: implement `wrap_optional` AIR
and move over some passing tests
Diffstat (limited to 'test/behavior/basic.zig')
| -rw-r--r-- | test/behavior/basic.zig | 35 |
1 files changed, 35 insertions, 0 deletions
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); +} |
