| author | |
| committer | |
| log | ec36e0609fb97fef96e72fb76f5515b751519a61 |
| tree | 97e03a7f966ef80312be2f46b315ea84a74fd0ed |
| parent | 150169f1e0cf08d4b76fed81fc205a63177b6e01 |
behavior tests should have minimal dependency on std3 files changed, 1 insertions(+), 35 deletions(-)
lib/std/debug.zig+1-1| ... | @@ -1697,7 +1697,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize | ... | @@ -1697,7 +1697,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize |
| 1697 | pub fn format( | 1697 | pub fn format( |
| 1698 | t: @This(), | 1698 | t: @This(), |
| 1699 | comptime fmt: []const u8, | 1699 | comptime fmt: []const u8, |
| 1700 | options: std.fmt.FormatOptions, | 1700 | options: std.fmt.Options, |
| 1701 | writer: *Writer, | 1701 | writer: *Writer, |
| 1702 | ) !void { | 1702 | ) !void { |
| 1703 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, t); | 1703 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, t); |
test/behavior.zig-1| ... | @@ -100,7 +100,6 @@ test { | ... | @@ -100,7 +100,6 @@ test { |
| 100 | _ = @import("behavior/undefined.zig"); | 100 | _ = @import("behavior/undefined.zig"); |
| 101 | _ = @import("behavior/underscore.zig"); | 101 | _ = @import("behavior/underscore.zig"); |
| 102 | _ = @import("behavior/union.zig"); | 102 | _ = @import("behavior/union.zig"); |
| 103 | _ = @import("behavior/union_with_members.zig"); | ||
| 104 | _ = @import("behavior/var_args.zig"); | 103 | _ = @import("behavior/var_args.zig"); |
| 105 | _ = @import("behavior/vector.zig"); | 104 | _ = @import("behavior/vector.zig"); |
| 106 | _ = @import("behavior/void.zig"); | 105 | _ = @import("behavior/void.zig"); |
test/behavior/union_with_members.zig deleted-33| ... | @@ -1,33 +0,0 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | const std = @import("std"); | ||
| 3 | const expect = std.testing.expect; | ||
| 4 | const mem = std.mem; | ||
| 5 | const fmt = std.fmt; | ||
| 6 | |||
| 7 | const ET = union(enum) { | ||
| 8 | SINT: i32, | ||
| 9 | UINT: u32, | ||
| 10 | |||
| 11 | pub fn print(a: *const ET, buf: []u8) anyerror!usize { | ||
| 12 | return switch (a.*) { | ||
| 13 | ET.SINT => |x| fmt.printInt(buf, x, 10, .lower, fmt.FormatOptions{}), | ||
| 14 | ET.UINT => |x| fmt.printInt(buf, x, 10, .lower, fmt.FormatOptions{}), | ||
| 15 | }; | ||
| 16 | } | ||
| 17 | }; | ||
| 18 | |||
| 19 | test "enum with members" { | ||
| 20 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO | ||
| 21 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | ||
| 22 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; | ||
| 23 | |||
| 24 | const a = ET{ .SINT = -42 }; | ||
| 25 | const b = ET{ .UINT = 42 }; | ||
| 26 | var buf: [20]u8 = undefined; | ||
| 27 | |||
| 28 | try expect((a.print(buf[0..]) catch unreachable) == 3); | ||
| 29 | try expect(mem.eql(u8, buf[0..3], "-42")); | ||
| 30 | |||
| 31 | try expect((b.print(buf[0..]) catch unreachable) == 2); | ||
| 32 | try expect(mem.eql(u8, buf[0..2], "42")); | ||
| 33 | } | ||