diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-10-17 17:02:20 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-10-17 17:02:20 -0700 |
| commit | e9d1e5e533d12abe14582736d90e4cb173addc56 (patch) | |
| tree | cb284bafd08c6287cb2ea50312d2cb13f4c91091 /test/behavior/null.zig | |
| parent | 07691db3ae061d8122f6c53c1f34c2fb0df2f7ef (diff) | |
| download | zig-e9d1e5e533d12abe14582736d90e4cb173addc56.tar.gz zig-e9d1e5e533d12abe14582736d90e4cb173addc56.zip | |
stage2: LLVM backend: lower constant field/elem ptrs
Diffstat (limited to 'test/behavior/null.zig')
| -rw-r--r-- | test/behavior/null.zig | 39 |
1 files changed, 2 insertions, 37 deletions
diff --git a/test/behavior/null.zig b/test/behavior/null.zig index 3bd652772b..98018c79bc 100644 --- a/test/behavior/null.zig +++ b/test/behavior/null.zig @@ -1,4 +1,5 @@ -const expect = @import("std").testing.expect; +const std = @import("std"); +const expect = std.testing.expect; test "optional type" { const x: ?bool = true; @@ -58,31 +59,6 @@ fn foo(x: ?i32) ?bool { return value > 1234; } -test "if var maybe pointer" { - try expect(shouldBeAPlus1(Particle{ - .a = 14, - .b = 1, - .c = 1, - .d = 1, - }) == 15); -} -fn shouldBeAPlus1(p: Particle) u64 { - var maybe_particle: ?Particle = p; - if (maybe_particle) |*particle| { - particle.a += 1; - } - if (maybe_particle) |particle| { - return particle.a; - } - return 0; -} -const Particle = struct { - a: u64, - b: u64, - c: u64, - d: u64, -}; - test "null literal outside function" { const is_null = here_is_a_null_literal.context == null; try expect(is_null); @@ -146,17 +122,6 @@ test "null with default unwrap" { try expect(x == 1); } -test "optional types" { - comptime { - const opt_type_struct = StructWithOptionalType{ .t = u8 }; - try expect(opt_type_struct.t != null and opt_type_struct.t.? == u8); - } -} - -const StructWithOptionalType = struct { - t: ?type, -}; - test "optional pointer to 0 bit type null value at runtime" { const EmptyStruct = struct {}; var x: ?*EmptyStruct = null; |
