| author | |
| committer | |
| log | d4911794ae8f43745b2d98a725acf440954f8d90 |
| tree | 83a30dd7b139139e86a9d53f69136b43732a9b74 |
| parent | 3667489051db56637de71d537436a20431a8e184 |
In general, let's not lean on GitHub issue numbers as having meaning.
The goal of behavior tests is to produce a minimum set of tests that
test 100% of the language.5 files changed, 78 insertions(+), 78 deletions(-)
test/behavior.zig+1-1| ... | ... | @@ -55,7 +55,6 @@ test { |
| 55 | 55 | _ = @import("behavior/bugs/3384.zig"); |
| 56 | 56 | _ = @import("behavior/bugs/3586.zig"); |
| 57 | 57 | _ = @import("behavior/bugs/3742.zig"); |
| 58 | _ = @import("behavior/bugs/3779.zig"); | |
| 59 | 58 | _ = @import("behavior/bugs/4328.zig"); |
| 60 | 59 | _ = @import("behavior/bugs/4560.zig"); |
| 61 | 60 | _ = @import("behavior/bugs/4769_a.zig"); |
| ... | ... | @@ -209,6 +208,7 @@ test { |
| 209 | 208 | _ = @import("behavior/slice.zig"); |
| 210 | 209 | _ = @import("behavior/slice_sentinel_comptime.zig"); |
| 211 | 210 | _ = @import("behavior/src.zig"); |
| 211 | _ = @import("behavior/string_literals.zig"); | |
| 212 | 212 | _ = @import("behavior/struct.zig"); |
| 213 | 213 | _ = @import("behavior/struct_contains_null_ptr_itself.zig"); |
| 214 | 214 | _ = @import("behavior/struct_contains_slice_of_itself.zig"); |
test/behavior/bugs/3779.zig deleted-76| ... | ... | @@ -1,76 +0,0 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | ||
| 4 | const TestEnum = enum { TestEnumValue }; | |
| 5 | const tag_name = @tagName(TestEnum.TestEnumValue); | |
| 6 | const ptr_tag_name: [*:0]const u8 = tag_name; | |
| 7 | ||
| 8 | test "@tagName() returns a string literal" { | |
| 9 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 10 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 11 | ||
| 12 | try std.testing.expect(*const [13:0]u8 == @TypeOf(tag_name)); | |
| 13 | try std.testing.expect(std.mem.eql(u8, "TestEnumValue", tag_name)); | |
| 14 | try std.testing.expect(std.mem.eql(u8, "TestEnumValue", ptr_tag_name[0..tag_name.len])); | |
| 15 | } | |
| 16 | ||
| 17 | const TestError = error{TestErrorCode}; | |
| 18 | const error_name = @errorName(TestError.TestErrorCode); | |
| 19 | const ptr_error_name: [*:0]const u8 = error_name; | |
| 20 | ||
| 21 | test "@errorName() returns a string literal" { | |
| 22 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 23 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 24 | ||
| 25 | try std.testing.expect(*const [13:0]u8 == @TypeOf(error_name)); | |
| 26 | try std.testing.expect(std.mem.eql(u8, "TestErrorCode", error_name)); | |
| 27 | try std.testing.expect(std.mem.eql(u8, "TestErrorCode", ptr_error_name[0..error_name.len])); | |
| 28 | } | |
| 29 | ||
| 30 | const TestType = struct {}; | |
| 31 | const type_name = @typeName(TestType); | |
| 32 | const ptr_type_name: [*:0]const u8 = type_name; | |
| 33 | ||
| 34 | test "@typeName() returns a string literal" { | |
| 35 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 36 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 37 | ||
| 38 | try std.testing.expect(*const [type_name.len:0]u8 == @TypeOf(type_name)); | |
| 39 | try std.testing.expect(std.mem.eql(u8, "behavior.bugs.3779.TestType", type_name)); | |
| 40 | try std.testing.expect(std.mem.eql(u8, "behavior.bugs.3779.TestType", ptr_type_name[0..type_name.len])); | |
| 41 | } | |
| 42 | ||
| 43 | const actual_contents = @embedFile("3779_file_to_embed.txt"); | |
| 44 | const ptr_actual_contents: [*:0]const u8 = actual_contents; | |
| 45 | const expected_contents = "hello zig\n"; | |
| 46 | ||
| 47 | test "@embedFile() returns a string literal" { | |
| 48 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 49 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 50 | ||
| 51 | try std.testing.expect(*const [expected_contents.len:0]u8 == @TypeOf(actual_contents)); | |
| 52 | try std.testing.expect(std.mem.eql(u8, expected_contents, actual_contents)); | |
| 53 | try std.testing.expect(std.mem.eql(u8, expected_contents, actual_contents)); | |
| 54 | try std.testing.expect(std.mem.eql(u8, expected_contents, ptr_actual_contents[0..actual_contents.len])); | |
| 55 | } | |
| 56 | ||
| 57 | fn testFnForSrc() std.builtin.SourceLocation { | |
| 58 | return @src(); | |
| 59 | } | |
| 60 | ||
| 61 | test "@src() returns a struct containing 0-terminated string slices" { | |
| 62 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 63 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 64 | ||
| 65 | const src = testFnForSrc(); | |
| 66 | try std.testing.expect([:0]const u8 == @TypeOf(src.file)); | |
| 67 | try std.testing.expect(std.mem.endsWith(u8, src.file, "3779.zig")); | |
| 68 | try std.testing.expect([:0]const u8 == @TypeOf(src.fn_name)); | |
| 69 | try std.testing.expect(std.mem.endsWith(u8, src.fn_name, "testFnForSrc")); | |
| 70 | ||
| 71 | const ptr_src_file: [*:0]const u8 = src.file; | |
| 72 | _ = ptr_src_file; // unused | |
| 73 | ||
| 74 | const ptr_src_fn_name: [*:0]const u8 = src.fn_name; | |
| 75 | _ = ptr_src_fn_name; // unused | |
| 76 | } |
test/behavior/bugs/3779_file_to_embed.txt deleted-1| ... | ... | @@ -1 +0,0 @@ |
| 1 | hello zig |
test/behavior/file_to_embed.txt created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | hello zig |
test/behavior/string_literals.zig created+76| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | const std = @import("std"); | |
| 2 | const builtin = @import("builtin"); | |
| 3 | ||
| 4 | const TestEnum = enum { TestEnumValue }; | |
| 5 | const tag_name = @tagName(TestEnum.TestEnumValue); | |
| 6 | const ptr_tag_name: [*:0]const u8 = tag_name; | |
| 7 | ||
| 8 | test "@tagName() returns a string literal" { | |
| 9 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 10 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 11 | ||
| 12 | try std.testing.expect(*const [13:0]u8 == @TypeOf(tag_name)); | |
| 13 | try std.testing.expect(std.mem.eql(u8, "TestEnumValue", tag_name)); | |
| 14 | try std.testing.expect(std.mem.eql(u8, "TestEnumValue", ptr_tag_name[0..tag_name.len])); | |
| 15 | } | |
| 16 | ||
| 17 | const TestError = error{TestErrorCode}; | |
| 18 | const error_name = @errorName(TestError.TestErrorCode); | |
| 19 | const ptr_error_name: [*:0]const u8 = error_name; | |
| 20 | ||
| 21 | test "@errorName() returns a string literal" { | |
| 22 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 23 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 24 | ||
| 25 | try std.testing.expect(*const [13:0]u8 == @TypeOf(error_name)); | |
| 26 | try std.testing.expect(std.mem.eql(u8, "TestErrorCode", error_name)); | |
| 27 | try std.testing.expect(std.mem.eql(u8, "TestErrorCode", ptr_error_name[0..error_name.len])); | |
| 28 | } | |
| 29 | ||
| 30 | const TestType = struct {}; | |
| 31 | const type_name = @typeName(TestType); | |
| 32 | const ptr_type_name: [*:0]const u8 = type_name; | |
| 33 | ||
| 34 | test "@typeName() returns a string literal" { | |
| 35 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 36 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 37 | ||
| 38 | try std.testing.expect(*const [type_name.len:0]u8 == @TypeOf(type_name)); | |
| 39 | try std.testing.expect(std.mem.eql(u8, "behavior.string_literals.TestType", type_name)); | |
| 40 | try std.testing.expect(std.mem.eql(u8, "behavior.string_literals.TestType", ptr_type_name[0..type_name.len])); | |
| 41 | } | |
| 42 | ||
| 43 | const actual_contents = @embedFile("file_to_embed.txt"); | |
| 44 | const ptr_actual_contents: [*:0]const u8 = actual_contents; | |
| 45 | const expected_contents = "hello zig\n"; | |
| 46 | ||
| 47 | test "@embedFile() returns a string literal" { | |
| 48 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 49 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 50 | ||
| 51 | try std.testing.expect(*const [expected_contents.len:0]u8 == @TypeOf(actual_contents)); | |
| 52 | try std.testing.expect(std.mem.eql(u8, expected_contents, actual_contents)); | |
| 53 | try std.testing.expect(std.mem.eql(u8, expected_contents, actual_contents)); | |
| 54 | try std.testing.expect(std.mem.eql(u8, expected_contents, ptr_actual_contents[0..actual_contents.len])); | |
| 55 | } | |
| 56 | ||
| 57 | fn testFnForSrc() std.builtin.SourceLocation { | |
| 58 | return @src(); | |
| 59 | } | |
| 60 | ||
| 61 | test "@src() returns a struct containing 0-terminated string slices" { | |
| 62 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | |
| 63 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO | |
| 64 | ||
| 65 | const src = testFnForSrc(); | |
| 66 | try std.testing.expect([:0]const u8 == @TypeOf(src.file)); | |
| 67 | try std.testing.expect(std.mem.endsWith(u8, src.file, "string_literals.zig")); | |
| 68 | try std.testing.expect([:0]const u8 == @TypeOf(src.fn_name)); | |
| 69 | try std.testing.expect(std.mem.endsWith(u8, src.fn_name, "testFnForSrc")); | |
| 70 | ||
| 71 | const ptr_src_file: [*:0]const u8 = src.file; | |
| 72 | _ = ptr_src_file; // unused | |
| 73 | ||
| 74 | const ptr_src_fn_name: [*:0]const u8 = src.fn_name; | |
| 75 | _ = ptr_src_fn_name; // unused | |
| 76 | } |