| author | |
| committer | |
| log | aa9caf5064b3fc01579b7bd8c765ff33323a073a |
| tree | 1072a5e6fe39957fd2fdb37f4816799ecf9a627b |
| parent | 4d134a01f5a8baae346783f19d9b5db8c8256d32 |
22 files changed, 208 insertions(+), 137 deletions(-)
doc/docgen.zig+1-1| ... | @@ -672,7 +672,7 @@ const TermState = enum { | ... | @@ -672,7 +672,7 @@ const TermState = enum { |
| 672 | 672 | ||
| 673 | test "term color" { | 673 | test "term color" { |
| 674 | const input_bytes = "A\x1b[32;1mgreen\x1b[0mB"; | 674 | const input_bytes = "A\x1b[32;1mgreen\x1b[0mB"; |
| 675 | const result = try termColor(std.testing.allocator, input_bytes); | 675 | const result = try termColor(std.testing.leak_count_allocator, input_bytes); |
| 676 | testing.expectEqualSlices(u8, "A<span class=\"t32\">green</span>B", result); | 676 | testing.expectEqualSlices(u8, "A<span class=\"t32\">green</span>B", result); |
| 677 | } | 677 | } |
| 678 | 678 |
lib/std/array_list.zig+8-7| ... | @@ -320,7 +320,7 @@ test "std.ArrayList.basic" { | ... | @@ -320,7 +320,7 @@ test "std.ArrayList.basic" { |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | test "std.ArrayList.orderedRemove" { | 322 | test "std.ArrayList.orderedRemove" { |
| 323 | var list = ArrayList(i32).init(testing.allocator); | 323 | var list = ArrayList(i32).init(testing.leak_count_allocator); |
| 324 | defer list.deinit(); | 324 | defer list.deinit(); |
| 325 | 325 | ||
| 326 | try list.append(1); | 326 | try list.append(1); |
| ... | @@ -347,7 +347,7 @@ test "std.ArrayList.orderedRemove" { | ... | @@ -347,7 +347,7 @@ test "std.ArrayList.orderedRemove" { |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | test "std.ArrayList.swapRemove" { | 349 | test "std.ArrayList.swapRemove" { |
| 350 | var list = ArrayList(i32).init(testing.allocator); | 350 | var list = ArrayList(i32).init(testing.leak_count_allocator); |
| 351 | defer list.deinit(); | 351 | defer list.deinit(); |
| 352 | 352 | ||
| 353 | try list.append(1); | 353 | try list.append(1); |
| ... | @@ -374,7 +374,7 @@ test "std.ArrayList.swapRemove" { | ... | @@ -374,7 +374,7 @@ test "std.ArrayList.swapRemove" { |
| 374 | } | 374 | } |
| 375 | 375 | ||
| 376 | test "std.ArrayList.swapRemoveOrError" { | 376 | test "std.ArrayList.swapRemoveOrError" { |
| 377 | var list = ArrayList(i32).init(testing.allocator); | 377 | var list = ArrayList(i32).init(testing.leak_count_allocator); |
| 378 | defer list.deinit(); | 378 | defer list.deinit(); |
| 379 | 379 | ||
| 380 | // Test just after initialization | 380 | // Test just after initialization |
| ... | @@ -402,7 +402,7 @@ test "std.ArrayList.swapRemoveOrError" { | ... | @@ -402,7 +402,7 @@ test "std.ArrayList.swapRemoveOrError" { |
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | test "std.ArrayList.insert" { | 404 | test "std.ArrayList.insert" { |
| 405 | var list = ArrayList(i32).init(testing.allocator); | 405 | var list = ArrayList(i32).init(testing.leak_count_allocator); |
| 406 | defer list.deinit(); | 406 | defer list.deinit(); |
| 407 | 407 | ||
| 408 | try list.append(1); | 408 | try list.append(1); |
| ... | @@ -416,7 +416,7 @@ test "std.ArrayList.insert" { | ... | @@ -416,7 +416,7 @@ test "std.ArrayList.insert" { |
| 416 | } | 416 | } |
| 417 | 417 | ||
| 418 | test "std.ArrayList.insertSlice" { | 418 | test "std.ArrayList.insertSlice" { |
| 419 | var list = ArrayList(i32).init(testing.allocator); | 419 | var list = ArrayList(i32).init(testing.leak_count_allocator); |
| 420 | defer list.deinit(); | 420 | defer list.deinit(); |
| 421 | 421 | ||
| 422 | try list.append(1); | 422 | try list.append(1); |
| ... | @@ -443,7 +443,8 @@ const Item = struct { | ... | @@ -443,7 +443,8 @@ const Item = struct { |
| 443 | }; | 443 | }; |
| 444 | 444 | ||
| 445 | test "std.ArrayList: ArrayList(T) of struct T" { | 445 | test "std.ArrayList: ArrayList(T) of struct T" { |
| 446 | var root = Item{ .integer = 1, .sub_items = ArrayList(Item).init(testing.allocator) }; | 446 | var root = Item{ .integer = 1, .sub_items = ArrayList(Item).init(testing.leak_count_allocator) }; |
| 447 | try root.sub_items.append(Item{ .integer = 42, .sub_items = ArrayList(Item).init(testing.allocator) }); | 447 | defer root.sub_items.deinit(); |
| 448 | try root.sub_items.append(Item{ .integer = 42, .sub_items = ArrayList(Item).init(testing.leak_count_allocator) }); | ||
| 448 | testing.expect(root.sub_items.items[0].integer == 42); | 449 | testing.expect(root.sub_items.items[0].integer == 42); |
| 449 | } | 450 | } |
lib/std/buffer.zig+8-3| ... | @@ -150,7 +150,9 @@ pub const Buffer = struct { | ... | @@ -150,7 +150,9 @@ pub const Buffer = struct { |
| 150 | }; | 150 | }; |
| 151 | 151 | ||
| 152 | test "simple Buffer" { | 152 | test "simple Buffer" { |
| 153 | var buf = try Buffer.init(testing.allocator, ""); | 153 | var buf = try Buffer.init(testing.leak_count_allocator, ""); |
| 154 | defer buf.deinit(); | ||
| 155 | |||
| 154 | testing.expect(buf.len() == 0); | 156 | testing.expect(buf.len() == 0); |
| 155 | try buf.append("hello"); | 157 | try buf.append("hello"); |
| 156 | try buf.append(" "); | 158 | try buf.append(" "); |
| ... | @@ -159,6 +161,7 @@ test "simple Buffer" { | ... | @@ -159,6 +161,7 @@ test "simple Buffer" { |
| 159 | testing.expect(mem.eql(u8, mem.toSliceConst(u8, buf.toSliceConst().ptr), buf.toSliceConst())); | 161 | testing.expect(mem.eql(u8, mem.toSliceConst(u8, buf.toSliceConst().ptr), buf.toSliceConst())); |
| 160 | 162 | ||
| 161 | var buf2 = try Buffer.initFromBuffer(buf); | 163 | var buf2 = try Buffer.initFromBuffer(buf); |
| 164 | defer buf2.deinit(); | ||
| 162 | testing.expect(buf.eql(buf2.toSliceConst())); | 165 | testing.expect(buf.eql(buf2.toSliceConst())); |
| 163 | 166 | ||
| 164 | testing.expect(buf.startsWith("hell")); | 167 | testing.expect(buf.startsWith("hell")); |
| ... | @@ -169,14 +172,16 @@ test "simple Buffer" { | ... | @@ -169,14 +172,16 @@ test "simple Buffer" { |
| 169 | } | 172 | } |
| 170 | 173 | ||
| 171 | test "Buffer.initSize" { | 174 | test "Buffer.initSize" { |
| 172 | var buf = try Buffer.initSize(testing.allocator, 3); | 175 | var buf = try Buffer.initSize(testing.leak_count_allocator, 3); |
| 176 | defer buf.deinit(); | ||
| 173 | testing.expect(buf.len() == 3); | 177 | testing.expect(buf.len() == 3); |
| 174 | try buf.append("hello"); | 178 | try buf.append("hello"); |
| 175 | testing.expect(mem.eql(u8, buf.toSliceConst()[3..], "hello")); | 179 | testing.expect(mem.eql(u8, buf.toSliceConst()[3..], "hello")); |
| 176 | } | 180 | } |
| 177 | 181 | ||
| 178 | test "Buffer.initCapacity" { | 182 | test "Buffer.initCapacity" { |
| 179 | var buf = try Buffer.initCapacity(testing.allocator, 10); | 183 | var buf = try Buffer.initCapacity(testing.leak_count_allocator, 10); |
| 184 | defer buf.deinit(); | ||
| 180 | testing.expect(buf.len() == 0); | 185 | testing.expect(buf.len() == 0); |
| 181 | testing.expect(buf.capacity() >= 10); | 186 | testing.expect(buf.capacity() >= 10); |
| 182 | const old_cap = buf.capacity(); | 187 | const old_cap = buf.capacity(); |
lib/std/debug.zig+1-1| ... | @@ -2193,7 +2193,7 @@ fn readInitialLength(comptime E: type, in_stream: *io.InStream(E), is_64: *bool) | ... | @@ -2193,7 +2193,7 @@ fn readInitialLength(comptime E: type, in_stream: *io.InStream(E), is_64: *bool) |
| 2193 | } | 2193 | } |
| 2194 | 2194 | ||
| 2195 | pub const global_allocator = blk: { | 2195 | pub const global_allocator = blk: { |
| 2196 | @compileError("Please switch to std.testing.allocator."); | 2196 | @compileError("Please switch to std.testing.leak_count_allocator."); |
| 2197 | }; | 2197 | }; |
| 2198 | var global_fixed_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(global_allocator_mem[0..]); | 2198 | var global_fixed_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(global_allocator_mem[0..]); |
| 2199 | var global_allocator_mem: [100 * 1024]u8 = undefined; | 2199 | var global_allocator_mem: [100 * 1024]u8 = undefined; |
lib/std/fifo.zig+2-2| ... | @@ -347,7 +347,7 @@ pub fn LinearFifo( | ... | @@ -347,7 +347,7 @@ pub fn LinearFifo( |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | test "LinearFifo(u8, .Dynamic)" { | 349 | test "LinearFifo(u8, .Dynamic)" { |
| 350 | var fifo = LinearFifo(u8, .Dynamic).init(testing.allocator); | 350 | var fifo = LinearFifo(u8, .Dynamic).init(testing.leak_count_allocator); |
| 351 | defer fifo.deinit(); | 351 | defer fifo.deinit(); |
| 352 | 352 | ||
| 353 | try fifo.write("HELLO"); | 353 | try fifo.write("HELLO"); |
| ... | @@ -422,7 +422,7 @@ test "LinearFifo" { | ... | @@ -422,7 +422,7 @@ test "LinearFifo" { |
| 422 | var fifo = switch (bt) { | 422 | var fifo = switch (bt) { |
| 423 | .Static => FifoType.init(), | 423 | .Static => FifoType.init(), |
| 424 | .Slice => FifoType.init(buf[0..]), | 424 | .Slice => FifoType.init(buf[0..]), |
| 425 | .Dynamic => FifoType.init(testing.allocator), | 425 | .Dynamic => FifoType.init(testing.leak_count_allocator), |
| 426 | }; | 426 | }; |
| 427 | defer fifo.deinit(); | 427 | defer fifo.deinit(); |
| 428 | 428 |
lib/std/fmt.zig+10-5| ... | @@ -1598,7 +1598,8 @@ test "hexToBytes" { | ... | @@ -1598,7 +1598,8 @@ test "hexToBytes" { |
| 1598 | test "formatIntValue with comptime_int" { | 1598 | test "formatIntValue with comptime_int" { |
| 1599 | const value: comptime_int = 123456789123456789; | 1599 | const value: comptime_int = 123456789123456789; |
| 1600 | 1600 | ||
| 1601 | var buf = try std.Buffer.init(std.testing.allocator, ""); | 1601 | var buf = try std.Buffer.init(std.testing.leak_count_allocator, ""); |
| 1602 | defer buf.deinit(); | ||
| 1602 | try formatIntValue(value, "", FormatOptions{}, &buf, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append); | 1603 | try formatIntValue(value, "", FormatOptions{}, &buf, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append); |
| 1603 | std.testing.expect(mem.eql(u8, buf.toSlice(), "123456789123456789")); | 1604 | std.testing.expect(mem.eql(u8, buf.toSlice(), "123456789123456789")); |
| 1604 | } | 1605 | } |
| ... | @@ -1652,19 +1653,23 @@ test "formatType max_depth" { | ... | @@ -1652,19 +1653,23 @@ test "formatType max_depth" { |
| 1652 | inst.a = &inst; | 1653 | inst.a = &inst; |
| 1653 | inst.tu.ptr = &inst.tu; | 1654 | inst.tu.ptr = &inst.tu; |
| 1654 | 1655 | ||
| 1655 | var buf0 = try std.Buffer.init(std.testing.allocator, ""); | 1656 | var buf0 = try std.Buffer.init(std.testing.leak_count_allocator, ""); |
| 1657 | defer buf0.deinit(); | ||
| 1656 | try formatType(inst, "", FormatOptions{}, &buf0, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 0); | 1658 | try formatType(inst, "", FormatOptions{}, &buf0, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 0); |
| 1657 | std.testing.expect(mem.eql(u8, buf0.toSlice(), "S{ ... }")); | 1659 | std.testing.expect(mem.eql(u8, buf0.toSlice(), "S{ ... }")); |
| 1658 | 1660 | ||
| 1659 | var buf1 = try std.Buffer.init(std.testing.allocator, ""); | 1661 | var buf1 = try std.Buffer.init(std.testing.leak_count_allocator, ""); |
| 1662 | defer buf1.deinit(); | ||
| 1660 | try formatType(inst, "", FormatOptions{}, &buf1, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 1); | 1663 | try formatType(inst, "", FormatOptions{}, &buf1, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 1); |
| 1661 | std.testing.expect(mem.eql(u8, buf1.toSlice(), "S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }")); | 1664 | std.testing.expect(mem.eql(u8, buf1.toSlice(), "S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }")); |
| 1662 | 1665 | ||
| 1663 | var buf2 = try std.Buffer.init(std.testing.allocator, ""); | 1666 | var buf2 = try std.Buffer.init(std.testing.leak_count_allocator, ""); |
| 1667 | defer buf2.deinit(); | ||
| 1664 | try formatType(inst, "", FormatOptions{}, &buf2, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 2); | 1668 | try formatType(inst, "", FormatOptions{}, &buf2, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 2); |
| 1665 | std.testing.expect(mem.eql(u8, buf2.toSlice(), "S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }")); | 1669 | std.testing.expect(mem.eql(u8, buf2.toSlice(), "S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }")); |
| 1666 | 1670 | ||
| 1667 | var buf3 = try std.Buffer.init(std.testing.allocator, ""); | 1671 | var buf3 = try std.Buffer.init(std.testing.leak_count_allocator, ""); |
| 1672 | defer buf3.deinit(); | ||
| 1668 | try formatType(inst, "", FormatOptions{}, &buf3, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 3); | 1673 | try formatType(inst, "", FormatOptions{}, &buf3, @TypeOf(std.Buffer.append).ReturnType.ErrorSet, std.Buffer.append, 3); |
| 1669 | std.testing.expect(mem.eql(u8, buf3.toSlice(), "S{ .a = S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ .ptr = TU{ ... } } }, .e = E.Two, .vec = (10.200,2.220) }")); | 1674 | std.testing.expect(mem.eql(u8, buf3.toSlice(), "S{ .a = S{ .a = S{ .a = S{ ... }, .tu = TU{ ... }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ ... } }, .e = E.Two, .vec = (10.200,2.220) }, .tu = TU{ .ptr = TU{ .ptr = TU{ ... } } }, .e = E.Two, .vec = (10.200,2.220) }")); |
| 1670 | } | 1675 | } |
lib/std/fs/path.zig+87-79| ... | @@ -665,15 +665,16 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { | ... | @@ -665,15 +665,16 @@ pub fn resolvePosix(allocator: *Allocator, paths: []const []const u8) ![]u8 { |
| 665 | } | 665 | } |
| 666 | 666 | ||
| 667 | test "resolve" { | 667 | test "resolve" { |
| 668 | const cwd = try process.getCwdAlloc(testing.allocator); | 668 | const cwd = try process.getCwdAlloc(testing.leak_count_allocator); |
| 669 | defer testing.leak_count_allocator.free(cwd); | ||
| 669 | if (builtin.os == .windows) { | 670 | if (builtin.os == .windows) { |
| 670 | if (windowsParsePath(cwd).kind == WindowsPath.Kind.Drive) { | 671 | if (windowsParsePath(cwd).kind == WindowsPath.Kind.Drive) { |
| 671 | cwd[0] = asciiUpper(cwd[0]); | 672 | cwd[0] = asciiUpper(cwd[0]); |
| 672 | } | 673 | } |
| 673 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{"."}), cwd)); | 674 | try testResolveWindows(&[_][]const u8{"."}, cwd); |
| 674 | } else { | 675 | } else { |
| 675 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "a/b/c/", "../../.." }), cwd)); | 676 | try testResolvePosix(&[_][]const u8{ "a/b/c/", "../../.." }, cwd); |
| 676 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{"."}), cwd)); | 677 | try testResolvePosix(&[_][]const u8{"."}, cwd); |
| 677 | } | 678 | } |
| 678 | } | 679 | } |
| 679 | 680 | ||
| ... | @@ -683,66 +684,71 @@ test "resolveWindows" { | ... | @@ -683,66 +684,71 @@ test "resolveWindows" { |
| 683 | return error.SkipZigTest; | 684 | return error.SkipZigTest; |
| 684 | } | 685 | } |
| 685 | if (builtin.os == .windows) { | 686 | if (builtin.os == .windows) { |
| 686 | const cwd = try process.getCwdAlloc(testing.allocator); | 687 | const cwd = try process.getCwdAlloc(testing.leak_count_allocator); |
| 688 | defer testing.leak_count_allocator.free(cwd); | ||
| 687 | const parsed_cwd = windowsParsePath(cwd); | 689 | const parsed_cwd = windowsParsePath(cwd); |
| 688 | { | 690 | { |
| 689 | const result = testResolveWindows(&[_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }); | 691 | const expected = try join(testing.leak_count_allocator, &[_][]const u8{ |
| 690 | const expected = try join(testing.allocator, &[_][]const u8{ | ||
| 691 | parsed_cwd.disk_designator, | 692 | parsed_cwd.disk_designator, |
| 692 | "usr\\local\\lib\\zig\\std\\array_list.zig", | 693 | "usr\\local\\lib\\zig\\std\\array_list.zig", |
| 693 | }); | 694 | }); |
| 695 | defer testing.leak_count_allocator.free(expected); | ||
| 694 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { | 696 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { |
| 695 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); | 697 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); |
| 696 | } | 698 | } |
| 697 | testing.expect(mem.eql(u8, result, expected)); | 699 | try testResolveWindows(&[_][]const u8{ "/usr/local", "lib\\zig\\std\\array_list.zig" }, expected); |
| 698 | } | 700 | } |
| 699 | { | 701 | { |
| 700 | const result = testResolveWindows(&[_][]const u8{ "usr/local", "lib\\zig" }); | 702 | const expected = try join(testing.leak_count_allocator, &[_][]const u8{ |
| 701 | const expected = try join(testing.allocator, &[_][]const u8{ | ||
| 702 | cwd, | 703 | cwd, |
| 703 | "usr\\local\\lib\\zig", | 704 | "usr\\local\\lib\\zig", |
| 704 | }); | 705 | }); |
| 706 | defer testing.leak_count_allocator.free(expected); | ||
| 705 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { | 707 | if (parsed_cwd.kind == WindowsPath.Kind.Drive) { |
| 706 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); | 708 | expected[0] = asciiUpper(parsed_cwd.disk_designator[0]); |
| 707 | } | 709 | } |
| 708 | testing.expect(mem.eql(u8, result, expected)); | 710 | try testResolveWindows(&[_][]const u8{ "usr/local", "lib\\zig" }, expected); |
| 709 | } | 711 | } |
| 710 | } | 712 | } |
| 711 | 713 | ||
| 712 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }), "C:\\hi\\ok")); | 714 | try testResolveWindows(&[_][]const u8{ "c:\\a\\b\\c", "/hi", "ok" }, "C:\\hi\\ok"); |
| 713 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }), "C:\\blah\\a")); | 715 | try testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "c:../a" }, "C:\\blah\\a"); |
| 714 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }), "C:\\blah\\a")); | 716 | try testResolveWindows(&[_][]const u8{ "c:/blah\\blah", "d:/games", "C:../a" }, "C:\\blah\\a"); |
| 715 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }), "D:\\e.exe")); | 717 | try testResolveWindows(&[_][]const u8{ "c:/ignore", "d:\\a/b\\c/d", "\\e.exe" }, "D:\\e.exe"); |
| 716 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/ignore", "c:/some/file" }), "C:\\some\\file")); | 718 | try testResolveWindows(&[_][]const u8{ "c:/ignore", "c:/some/file" }, "C:\\some\\file"); |
| 717 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "d:/ignore", "d:some/dir//" }), "D:\\ignore\\some\\dir")); | 719 | try testResolveWindows(&[_][]const u8{ "d:/ignore", "d:some/dir//" }, "D:\\ignore\\some\\dir"); |
| 718 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "//server/share", "..", "relative\\" }), "\\\\server\\share\\relative")); | 720 | try testResolveWindows(&[_][]const u8{ "//server/share", "..", "relative\\" }, "\\\\server\\share\\relative"); |
| 719 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//" }), "C:\\")); | 721 | try testResolveWindows(&[_][]const u8{ "c:/", "//" }, "C:\\"); |
| 720 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//dir" }), "C:\\dir")); | 722 | try testResolveWindows(&[_][]const u8{ "c:/", "//dir" }, "C:\\dir"); |
| 721 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//server/share" }), "\\\\server\\share\\")); | 723 | try testResolveWindows(&[_][]const u8{ "c:/", "//server/share" }, "\\\\server\\share\\"); |
| 722 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "//server//share" }), "\\\\server\\share\\")); | 724 | try testResolveWindows(&[_][]const u8{ "c:/", "//server//share" }, "\\\\server\\share\\"); |
| 723 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "c:/", "///some//dir" }), "C:\\some\\dir")); | 725 | try testResolveWindows(&[_][]const u8{ "c:/", "///some//dir" }, "C:\\some\\dir"); |
| 724 | testing.expect(mem.eql(u8, testResolveWindows(&[_][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }), "C:\\foo\\tmp.3\\cycles\\root.js")); | 726 | try testResolveWindows(&[_][]const u8{ "C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js" }, "C:\\foo\\tmp.3\\cycles\\root.js"); |
| 725 | } | 727 | } |
| 726 | 728 | ||
| 727 | test "resolvePosix" { | 729 | test "resolvePosix" { |
| 728 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b", "c" }), "/a/b/c")); | 730 | try testResolvePosix(&[_][]const u8{ "/a/b", "c" }, "/a/b/c"); |
| 729 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b", "c", "//d", "e///" }), "/d/e")); | 731 | try testResolvePosix(&[_][]const u8{ "/a/b", "c", "//d", "e///" }, "/d/e"); |
| 730 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/a/b/c", "..", "../" }), "/a")); | 732 | try testResolvePosix(&[_][]const u8{ "/a/b/c", "..", "../" }, "/a"); |
| 731 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/", "..", ".." }), "/")); | 733 | try testResolvePosix(&[_][]const u8{ "/", "..", ".." }, "/"); |
| 732 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{"/a/b/c/"}), "/a/b/c")); | 734 | try testResolvePosix(&[_][]const u8{"/a/b/c/"}, "/a/b/c"); |
| 733 | 735 | ||
| 734 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/var/lib", "../", "file/" }), "/var/file")); | 736 | try testResolvePosix(&[_][]const u8{ "/var/lib", "../", "file/" }, "/var/file"); |
| 735 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/var/lib", "/../", "file/" }), "/file")); | 737 | try testResolvePosix(&[_][]const u8{ "/var/lib", "/../", "file/" }, "/file"); |
| 736 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/some/dir", ".", "/absolute/" }), "/absolute")); | 738 | try testResolvePosix(&[_][]const u8{ "/some/dir", ".", "/absolute/" }, "/absolute"); |
| 737 | testing.expect(mem.eql(u8, testResolvePosix(&[_][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }), "/foo/tmp.3/cycles/root.js")); | 739 | try testResolvePosix(&[_][]const u8{ "/foo/tmp.3/", "../tmp.3/cycles/root.js" }, "/foo/tmp.3/cycles/root.js"); |
| 738 | } | 740 | } |
| 739 | 741 | ||
| 740 | fn testResolveWindows(paths: []const []const u8) []u8 { | 742 | fn testResolveWindows(paths: []const []const u8, expected: []const u8) !void { |
| 741 | return resolveWindows(testing.allocator, paths) catch unreachable; | 743 | const actual = try resolveWindows(testing.leak_count_allocator, paths); |
| 744 | defer testing.leak_count_allocator.free(actual); | ||
| 745 | return testing.expect(mem.eql(u8, actual, expected)); | ||
| 742 | } | 746 | } |
| 743 | 747 | ||
| 744 | fn testResolvePosix(paths: []const []const u8) []u8 { | 748 | fn testResolvePosix(paths: []const []const u8, expected: []const u8) !void { |
| 745 | return resolvePosix(testing.allocator, paths) catch unreachable; | 749 | const actual = try resolvePosix(testing.leak_count_allocator, paths); |
| 750 | defer testing.leak_count_allocator.free(actual); | ||
| 751 | return testing.expect(mem.eql(u8, actual, expected)); | ||
| 746 | } | 752 | } |
| 747 | 753 | ||
| 748 | /// If the path is a file in the current directory (no directory component) | 754 | /// If the path is a file in the current directory (no directory component) |
| ... | @@ -1126,51 +1132,53 @@ test "relative" { | ... | @@ -1126,51 +1132,53 @@ test "relative" { |
| 1126 | // TODO https://github.com/ziglang/zig/issues/3288 | 1132 | // TODO https://github.com/ziglang/zig/issues/3288 |
| 1127 | return error.SkipZigTest; | 1133 | return error.SkipZigTest; |
| 1128 | } | 1134 | } |
| 1129 | testRelativeWindows("c:/blah\\blah", "d:/games", "D:\\games"); | 1135 | try testRelativeWindows("c:/blah\\blah", "d:/games", "D:\\games"); |
| 1130 | testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa", ".."); | 1136 | try testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa", ".."); |
| 1131 | testRelativeWindows("c:/aaaa/bbbb", "c:/cccc", "..\\..\\cccc"); | 1137 | try testRelativeWindows("c:/aaaa/bbbb", "c:/cccc", "..\\..\\cccc"); |
| 1132 | testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa/bbbb", ""); | 1138 | try testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa/bbbb", ""); |
| 1133 | testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa/cccc", "..\\cccc"); | 1139 | try testRelativeWindows("c:/aaaa/bbbb", "c:/aaaa/cccc", "..\\cccc"); |
| 1134 | testRelativeWindows("c:/aaaa/", "c:/aaaa/cccc", "cccc"); | 1140 | try testRelativeWindows("c:/aaaa/", "c:/aaaa/cccc", "cccc"); |
| 1135 | testRelativeWindows("c:/", "c:\\aaaa\\bbbb", "aaaa\\bbbb"); | 1141 | try testRelativeWindows("c:/", "c:\\aaaa\\bbbb", "aaaa\\bbbb"); |
| 1136 | testRelativeWindows("c:/aaaa/bbbb", "d:\\", "D:\\"); | 1142 | try testRelativeWindows("c:/aaaa/bbbb", "d:\\", "D:\\"); |
| 1137 | testRelativeWindows("c:/AaAa/bbbb", "c:/aaaa/bbbb", ""); | 1143 | try testRelativeWindows("c:/AaAa/bbbb", "c:/aaaa/bbbb", ""); |
| 1138 | testRelativeWindows("c:/aaaaa/", "c:/aaaa/cccc", "..\\aaaa\\cccc"); | 1144 | try testRelativeWindows("c:/aaaaa/", "c:/aaaa/cccc", "..\\aaaa\\cccc"); |
| 1139 | testRelativeWindows("C:\\foo\\bar\\baz\\quux", "C:\\", "..\\..\\..\\.."); | 1145 | try testRelativeWindows("C:\\foo\\bar\\baz\\quux", "C:\\", "..\\..\\..\\.."); |
| 1140 | testRelativeWindows("C:\\foo\\test", "C:\\foo\\test\\bar\\package.json", "bar\\package.json"); | 1146 | try testRelativeWindows("C:\\foo\\test", "C:\\foo\\test\\bar\\package.json", "bar\\package.json"); |
| 1141 | testRelativeWindows("C:\\foo\\bar\\baz-quux", "C:\\foo\\bar\\baz", "..\\baz"); | 1147 | try testRelativeWindows("C:\\foo\\bar\\baz-quux", "C:\\foo\\bar\\baz", "..\\baz"); |
| 1142 | testRelativeWindows("C:\\foo\\bar\\baz", "C:\\foo\\bar\\baz-quux", "..\\baz-quux"); | 1148 | try testRelativeWindows("C:\\foo\\bar\\baz", "C:\\foo\\bar\\baz-quux", "..\\baz-quux"); |
| 1143 | testRelativeWindows("\\\\foo\\bar", "\\\\foo\\bar\\baz", "baz"); | 1149 | try testRelativeWindows("\\\\foo\\bar", "\\\\foo\\bar\\baz", "baz"); |
| 1144 | testRelativeWindows("\\\\foo\\bar\\baz", "\\\\foo\\bar", ".."); | 1150 | try testRelativeWindows("\\\\foo\\bar\\baz", "\\\\foo\\bar", ".."); |
| 1145 | testRelativeWindows("\\\\foo\\bar\\baz-quux", "\\\\foo\\bar\\baz", "..\\baz"); | 1151 | try testRelativeWindows("\\\\foo\\bar\\baz-quux", "\\\\foo\\bar\\baz", "..\\baz"); |
| 1146 | testRelativeWindows("\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz-quux", "..\\baz-quux"); | 1152 | try testRelativeWindows("\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz-quux", "..\\baz-quux"); |
| 1147 | testRelativeWindows("C:\\baz-quux", "C:\\baz", "..\\baz"); | 1153 | try testRelativeWindows("C:\\baz-quux", "C:\\baz", "..\\baz"); |
| 1148 | testRelativeWindows("C:\\baz", "C:\\baz-quux", "..\\baz-quux"); | 1154 | try testRelativeWindows("C:\\baz", "C:\\baz-quux", "..\\baz-quux"); |
| 1149 | testRelativeWindows("\\\\foo\\baz-quux", "\\\\foo\\baz", "..\\baz"); | 1155 | try testRelativeWindows("\\\\foo\\baz-quux", "\\\\foo\\baz", "..\\baz"); |
| 1150 | testRelativeWindows("\\\\foo\\baz", "\\\\foo\\baz-quux", "..\\baz-quux"); | 1156 | try testRelativeWindows("\\\\foo\\baz", "\\\\foo\\baz-quux", "..\\baz-quux"); |
| 1151 | testRelativeWindows("C:\\baz", "\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz"); | 1157 | try testRelativeWindows("C:\\baz", "\\\\foo\\bar\\baz", "\\\\foo\\bar\\baz"); |
| 1152 | testRelativeWindows("\\\\foo\\bar\\baz", "C:\\baz", "C:\\baz"); | 1158 | try testRelativeWindows("\\\\foo\\bar\\baz", "C:\\baz", "C:\\baz"); |
| 1153 | 1159 | ||
| 1154 | testRelativePosix("/var/lib", "/var", ".."); | 1160 | try testRelativePosix("/var/lib", "/var", ".."); |
| 1155 | testRelativePosix("/var/lib", "/bin", "../../bin"); | 1161 | try testRelativePosix("/var/lib", "/bin", "../../bin"); |
| 1156 | testRelativePosix("/var/lib", "/var/lib", ""); | 1162 | try testRelativePosix("/var/lib", "/var/lib", ""); |
| 1157 | testRelativePosix("/var/lib", "/var/apache", "../apache"); | 1163 | try testRelativePosix("/var/lib", "/var/apache", "../apache"); |
| 1158 | testRelativePosix("/var/", "/var/lib", "lib"); | 1164 | try testRelativePosix("/var/", "/var/lib", "lib"); |
| 1159 | testRelativePosix("/", "/var/lib", "var/lib"); | 1165 | try testRelativePosix("/", "/var/lib", "var/lib"); |
| 1160 | testRelativePosix("/foo/test", "/foo/test/bar/package.json", "bar/package.json"); | 1166 | try testRelativePosix("/foo/test", "/foo/test/bar/package.json", "bar/package.json"); |
| 1161 | testRelativePosix("/Users/a/web/b/test/mails", "/Users/a/web/b", "../.."); | 1167 | try testRelativePosix("/Users/a/web/b/test/mails", "/Users/a/web/b", "../.."); |
| 1162 | testRelativePosix("/foo/bar/baz-quux", "/foo/bar/baz", "../baz"); | 1168 | try testRelativePosix("/foo/bar/baz-quux", "/foo/bar/baz", "../baz"); |
| 1163 | testRelativePosix("/foo/bar/baz", "/foo/bar/baz-quux", "../baz-quux"); | 1169 | try testRelativePosix("/foo/bar/baz", "/foo/bar/baz-quux", "../baz-quux"); |
| 1164 | testRelativePosix("/baz-quux", "/baz", "../baz"); | 1170 | try testRelativePosix("/baz-quux", "/baz", "../baz"); |
| 1165 | testRelativePosix("/baz", "/baz-quux", "../baz-quux"); | 1171 | try testRelativePosix("/baz", "/baz-quux", "../baz-quux"); |
| 1166 | } | 1172 | } |
| 1167 | 1173 | ||
| 1168 | fn testRelativePosix(from: []const u8, to: []const u8, expected_output: []const u8) void { | 1174 | fn testRelativePosix(from: []const u8, to: []const u8, expected_output: []const u8) !void { |
| 1169 | const result = relativePosix(testing.allocator, from, to) catch unreachable; | 1175 | const result = try relativePosix(testing.leak_count_allocator, from, to); |
| 1176 | defer testing.leak_count_allocator.free(result); | ||
| 1170 | testing.expectEqualSlices(u8, expected_output, result); | 1177 | testing.expectEqualSlices(u8, expected_output, result); |
| 1171 | } | 1178 | } |
| 1172 | 1179 | ||
| 1173 | fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []const u8) void { | 1180 | fn testRelativeWindows(from: []const u8, to: []const u8, expected_output: []const u8) !void { |
| 1174 | const result = relativeWindows(testing.allocator, from, to) catch unreachable; | 1181 | const result = try relativeWindows(testing.leak_count_allocator, from, to); |
| 1182 | defer testing.leak_count_allocator.free(result); | ||
| 1175 | testing.expectEqualSlices(u8, expected_output, result); | 1183 | testing.expectEqualSlices(u8, expected_output, result); |
| 1176 | } | 1184 | } |
lib/std/linked_list.zig+3-3| ... | @@ -143,7 +143,7 @@ pub fn SinglyLinkedList(comptime T: type) type { | ... | @@ -143,7 +143,7 @@ pub fn SinglyLinkedList(comptime T: type) type { |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | test "basic SinglyLinkedList test" { | 145 | test "basic SinglyLinkedList test" { |
| 146 | const allocator = testing.allocator; | 146 | const allocator = testing.leak_count_allocator; |
| 147 | var list = SinglyLinkedList(u32).init(); | 147 | var list = SinglyLinkedList(u32).init(); |
| 148 | 148 | ||
| 149 | var one = try list.createNode(1, allocator); | 149 | var one = try list.createNode(1, allocator); |
| ... | @@ -404,7 +404,7 @@ pub fn TailQueue(comptime T: type) type { | ... | @@ -404,7 +404,7 @@ pub fn TailQueue(comptime T: type) type { |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | test "basic TailQueue test" { | 406 | test "basic TailQueue test" { |
| 407 | const allocator = testing.allocator; | 407 | const allocator = testing.leak_count_allocator; |
| 408 | var list = TailQueue(u32).init(); | 408 | var list = TailQueue(u32).init(); |
| 409 | 409 | ||
| 410 | var one = try list.createNode(1, allocator); | 410 | var one = try list.createNode(1, allocator); |
| ... | @@ -456,7 +456,7 @@ test "basic TailQueue test" { | ... | @@ -456,7 +456,7 @@ test "basic TailQueue test" { |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | test "TailQueue concatenation" { | 458 | test "TailQueue concatenation" { |
| 459 | const allocator = testing.allocator; | 459 | const allocator = testing.leak_count_allocator; |
| 460 | var list1 = TailQueue(u32).init(); | 460 | var list1 = TailQueue(u32).init(); |
| 461 | var list2 = TailQueue(u32).init(); | 461 | var list2 = TailQueue(u32).init(); |
| 462 | 462 |
lib/std/os/test.zig+1-1| ... | @@ -9,7 +9,7 @@ const elf = std.elf; | ... | @@ -9,7 +9,7 @@ const elf = std.elf; |
| 9 | const File = std.fs.File; | 9 | const File = std.fs.File; |
| 10 | const Thread = std.Thread; | 10 | const Thread = std.Thread; |
| 11 | 11 | ||
| 12 | const a = std.testing.allocator; | 12 | const a = std.testing.leak_count_allocator; |
| 13 | 13 | ||
| 14 | const builtin = @import("builtin"); | 14 | const builtin = @import("builtin"); |
| 15 | const AtomicRmwOp = builtin.AtomicRmwOp; | 15 | const AtomicRmwOp = builtin.AtomicRmwOp; |
lib/std/priority_queue.zig+14-14| ... | @@ -239,7 +239,7 @@ fn greaterThan(a: u32, b: u32) bool { | ... | @@ -239,7 +239,7 @@ fn greaterThan(a: u32, b: u32) bool { |
| 239 | const PQ = PriorityQueue(u32); | 239 | const PQ = PriorityQueue(u32); |
| 240 | 240 | ||
| 241 | test "std.PriorityQueue: add and remove min heap" { | 241 | test "std.PriorityQueue: add and remove min heap" { |
| 242 | var queue = PQ.init(testing.allocator, lessThan); | 242 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 243 | defer queue.deinit(); | 243 | defer queue.deinit(); |
| 244 | 244 | ||
| 245 | try queue.add(54); | 245 | try queue.add(54); |
| ... | @@ -257,7 +257,7 @@ test "std.PriorityQueue: add and remove min heap" { | ... | @@ -257,7 +257,7 @@ test "std.PriorityQueue: add and remove min heap" { |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | test "std.PriorityQueue: add and remove same min heap" { | 259 | test "std.PriorityQueue: add and remove same min heap" { |
| 260 | var queue = PQ.init(testing.allocator, lessThan); | 260 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 261 | defer queue.deinit(); | 261 | defer queue.deinit(); |
| 262 | 262 | ||
| 263 | try queue.add(1); | 263 | try queue.add(1); |
| ... | @@ -275,14 +275,14 @@ test "std.PriorityQueue: add and remove same min heap" { | ... | @@ -275,14 +275,14 @@ test "std.PriorityQueue: add and remove same min heap" { |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | test "std.PriorityQueue: removeOrNull on empty" { | 277 | test "std.PriorityQueue: removeOrNull on empty" { |
| 278 | var queue = PQ.init(testing.allocator, lessThan); | 278 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 279 | defer queue.deinit(); | 279 | defer queue.deinit(); |
| 280 | 280 | ||
| 281 | expect(queue.removeOrNull() == null); | 281 | expect(queue.removeOrNull() == null); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | test "std.PriorityQueue: edge case 3 elements" { | 284 | test "std.PriorityQueue: edge case 3 elements" { |
| 285 | var queue = PQ.init(testing.allocator, lessThan); | 285 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 286 | defer queue.deinit(); | 286 | defer queue.deinit(); |
| 287 | 287 | ||
| 288 | try queue.add(9); | 288 | try queue.add(9); |
| ... | @@ -294,7 +294,7 @@ test "std.PriorityQueue: edge case 3 elements" { | ... | @@ -294,7 +294,7 @@ test "std.PriorityQueue: edge case 3 elements" { |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | test "std.PriorityQueue: peek" { | 296 | test "std.PriorityQueue: peek" { |
| 297 | var queue = PQ.init(testing.allocator, lessThan); | 297 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 298 | defer queue.deinit(); | 298 | defer queue.deinit(); |
| 299 | 299 | ||
| 300 | expect(queue.peek() == null); | 300 | expect(queue.peek() == null); |
| ... | @@ -306,7 +306,7 @@ test "std.PriorityQueue: peek" { | ... | @@ -306,7 +306,7 @@ test "std.PriorityQueue: peek" { |
| 306 | } | 306 | } |
| 307 | 307 | ||
| 308 | test "std.PriorityQueue: sift up with odd indices" { | 308 | test "std.PriorityQueue: sift up with odd indices" { |
| 309 | var queue = PQ.init(testing.allocator, lessThan); | 309 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 310 | defer queue.deinit(); | 310 | defer queue.deinit(); |
| 311 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 311 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| 312 | for (items) |e| { | 312 | for (items) |e| { |
| ... | @@ -320,7 +320,7 @@ test "std.PriorityQueue: sift up with odd indices" { | ... | @@ -320,7 +320,7 @@ test "std.PriorityQueue: sift up with odd indices" { |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | test "std.PriorityQueue: addSlice" { | 322 | test "std.PriorityQueue: addSlice" { |
| 323 | var queue = PQ.init(testing.allocator, lessThan); | 323 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 324 | defer queue.deinit(); | 324 | defer queue.deinit(); |
| 325 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 325 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| 326 | try queue.addSlice(items[0..]); | 326 | try queue.addSlice(items[0..]); |
| ... | @@ -333,8 +333,8 @@ test "std.PriorityQueue: addSlice" { | ... | @@ -333,8 +333,8 @@ test "std.PriorityQueue: addSlice" { |
| 333 | 333 | ||
| 334 | test "std.PriorityQueue: fromOwnedSlice" { | 334 | test "std.PriorityQueue: fromOwnedSlice" { |
| 335 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; | 335 | const items = [_]u32{ 15, 7, 21, 14, 13, 22, 12, 6, 7, 25, 5, 24, 11, 16, 15, 24, 2, 1 }; |
| 336 | const heap_items = try std.mem.dupe(testing.allocator, u32, items[0..]); | 336 | const heap_items = try std.mem.dupe(testing.leak_count_allocator, u32, items[0..]); |
| 337 | var queue = PQ.fromOwnedSlice(testing.allocator, lessThan, heap_items[0..]); | 337 | var queue = PQ.fromOwnedSlice(testing.leak_count_allocator, lessThan, heap_items[0..]); |
| 338 | defer queue.deinit(); | 338 | defer queue.deinit(); |
| 339 | 339 | ||
| 340 | const sorted_items = [_]u32{ 1, 2, 5, 6, 7, 7, 11, 12, 13, 14, 15, 15, 16, 21, 22, 24, 24, 25 }; | 340 | const sorted_items = [_]u32{ 1, 2, 5, 6, 7, 7, 11, 12, 13, 14, 15, 15, 16, 21, 22, 24, 24, 25 }; |
| ... | @@ -344,7 +344,7 @@ test "std.PriorityQueue: fromOwnedSlice" { | ... | @@ -344,7 +344,7 @@ test "std.PriorityQueue: fromOwnedSlice" { |
| 344 | } | 344 | } |
| 345 | 345 | ||
| 346 | test "std.PriorityQueue: add and remove max heap" { | 346 | test "std.PriorityQueue: add and remove max heap" { |
| 347 | var queue = PQ.init(testing.allocator, greaterThan); | 347 | var queue = PQ.init(testing.leak_count_allocator, greaterThan); |
| 348 | defer queue.deinit(); | 348 | defer queue.deinit(); |
| 349 | 349 | ||
| 350 | try queue.add(54); | 350 | try queue.add(54); |
| ... | @@ -362,7 +362,7 @@ test "std.PriorityQueue: add and remove max heap" { | ... | @@ -362,7 +362,7 @@ test "std.PriorityQueue: add and remove max heap" { |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | test "std.PriorityQueue: add and remove same max heap" { | 364 | test "std.PriorityQueue: add and remove same max heap" { |
| 365 | var queue = PQ.init(testing.allocator, greaterThan); | 365 | var queue = PQ.init(testing.leak_count_allocator, greaterThan); |
| 366 | defer queue.deinit(); | 366 | defer queue.deinit(); |
| 367 | 367 | ||
| 368 | try queue.add(1); | 368 | try queue.add(1); |
| ... | @@ -380,8 +380,8 @@ test "std.PriorityQueue: add and remove same max heap" { | ... | @@ -380,8 +380,8 @@ test "std.PriorityQueue: add and remove same max heap" { |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | test "std.PriorityQueue: iterator" { | 382 | test "std.PriorityQueue: iterator" { |
| 383 | var queue = PQ.init(testing.allocator, lessThan); | 383 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 384 | var map = std.AutoHashMap(u32, void).init(testing.allocator); | 384 | var map = std.AutoHashMap(u32, void).init(testing.leak_count_allocator); |
| 385 | defer { | 385 | defer { |
| 386 | queue.deinit(); | 386 | queue.deinit(); |
| 387 | map.deinit(); | 387 | map.deinit(); |
| ... | @@ -402,7 +402,7 @@ test "std.PriorityQueue: iterator" { | ... | @@ -402,7 +402,7 @@ test "std.PriorityQueue: iterator" { |
| 402 | } | 402 | } |
| 403 | 403 | ||
| 404 | test "std.PriorityQueue: remove at index" { | 404 | test "std.PriorityQueue: remove at index" { |
| 405 | var queue = PQ.init(testing.allocator, lessThan); | 405 | var queue = PQ.init(testing.leak_count_allocator, lessThan); |
| 406 | defer queue.deinit(); | 406 | defer queue.deinit(); |
| 407 | 407 | ||
| 408 | try queue.add(3); | 408 | try queue.add(3); |
lib/std/process.zig+5-4| ... | @@ -114,7 +114,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { | ... | @@ -114,7 +114,7 @@ pub fn getEnvMap(allocator: *Allocator) !BufMap { |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | test "os.getEnvMap" { | 116 | test "os.getEnvMap" { |
| 117 | var env = try getEnvMap(std.testing.allocator); | 117 | var env = try getEnvMap(std.testing.leak_count_allocator); |
| 118 | defer env.deinit(); | 118 | defer env.deinit(); |
| 119 | } | 119 | } |
| 120 | 120 | ||
| ... | @@ -165,7 +165,7 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned | ... | @@ -165,7 +165,7 @@ pub fn getEnvVarOwned(allocator: *mem.Allocator, key: []const u8) GetEnvVarOwned |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | test "os.getEnvVarOwned" { | 167 | test "os.getEnvVarOwned" { |
| 168 | var ga = std.testing.allocator; | 168 | var ga = std.testing.leak_count_allocator; |
| 169 | testing.expectError(error.EnvironmentVariableNotFound, getEnvVarOwned(ga, "BADENV")); | 169 | testing.expectError(error.EnvironmentVariableNotFound, getEnvVarOwned(ga, "BADENV")); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| ... | @@ -492,10 +492,11 @@ test "windows arg parsing" { | ... | @@ -492,10 +492,11 @@ test "windows arg parsing" { |
| 492 | fn testWindowsCmdLine(input_cmd_line: [*]const u8, expected_args: []const []const u8) void { | 492 | fn testWindowsCmdLine(input_cmd_line: [*]const u8, expected_args: []const []const u8) void { |
| 493 | var it = ArgIteratorWindows.initWithCmdLine(input_cmd_line); | 493 | var it = ArgIteratorWindows.initWithCmdLine(input_cmd_line); |
| 494 | for (expected_args) |expected_arg| { | 494 | for (expected_args) |expected_arg| { |
| 495 | const arg = it.next(std.testing.allocator).? catch unreachable; | 495 | const arg = it.next(std.testing.leak_count_allocator).? catch unreachable; |
| 496 | defer std.testing.leak_count_allocator.free(arg); | ||
| 496 | testing.expectEqualSlices(u8, expected_arg, arg); | 497 | testing.expectEqualSlices(u8, expected_arg, arg); |
| 497 | } | 498 | } |
| 498 | testing.expect(it.next(std.testing.allocator) == null); | 499 | testing.expect(it.next(std.testing.leak_count_allocator) == null); |
| 499 | } | 500 | } |
| 500 | 501 | ||
| 501 | pub const UserInfo = struct { | 502 | pub const UserInfo = struct { |
lib/std/special/test_runner.zig+3| ... | @@ -14,6 +14,7 @@ pub fn main() anyerror!void { | ... | @@ -14,6 +14,7 @@ pub fn main() anyerror!void { |
| 14 | 14 | ||
| 15 | for (test_fn_list) |test_fn, i| { | 15 | for (test_fn_list) |test_fn, i| { |
| 16 | std.testing.allocator_instance.reset(); | 16 | std.testing.allocator_instance.reset(); |
| 17 | |||
| 17 | var test_node = root_node.start(test_fn.name, null); | 18 | var test_node = root_node.start(test_fn.name, null); |
| 18 | test_node.activate(); | 19 | test_node.activate(); |
| 19 | progress.refresh(); | 20 | progress.refresh(); |
| ... | @@ -36,6 +37,8 @@ pub fn main() anyerror!void { | ... | @@ -36,6 +37,8 @@ pub fn main() anyerror!void { |
| 36 | return err; | 37 | return err; |
| 37 | }, | 38 | }, |
| 38 | } | 39 | } |
| 40 | |||
| 41 | try std.testing.leak_count_allocator_instance.validate(); | ||
| 39 | } | 42 | } |
| 40 | root_node.end(); | 43 | root_node.end(); |
| 41 | if (ok_count == test_fn_list.len) { | 44 | if (ok_count == test_fn_list.len) { |
lib/std/testing.zig+42| ... | @@ -7,6 +7,48 @@ pub const allocator = &allocator_instance.allocator; | ... | @@ -7,6 +7,48 @@ pub const allocator = &allocator_instance.allocator; |
| 7 | pub var allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]); | 7 | pub var allocator_instance = std.heap.ThreadSafeFixedBufferAllocator.init(allocator_mem[0..]); |
| 8 | var allocator_mem: [100 * 1024]u8 = undefined; | 8 | var allocator_mem: [100 * 1024]u8 = undefined; |
| 9 | 9 | ||
| 10 | pub const leak_count_allocator = &leak_count_allocator_instance.allocator; | ||
| 11 | pub var leak_count_allocator_instance = LeakCountAllocator.init(allocator); | ||
| 12 | const LeakCountAllocator = struct { | ||
| 13 | count: usize, | ||
| 14 | allocator: std.mem.Allocator, | ||
| 15 | internal_allocator: *std.mem.Allocator, | ||
| 16 | |||
| 17 | fn init(allo: *std.mem.Allocator) LeakCountAllocator { | ||
| 18 | return .{ | ||
| 19 | .count = 0, | ||
| 20 | .allocator = .{ | ||
| 21 | .reallocFn = realloc, | ||
| 22 | .shrinkFn = shrink, | ||
| 23 | }, | ||
| 24 | .internal_allocator = allo, | ||
| 25 | }; | ||
| 26 | } | ||
| 27 | |||
| 28 | fn realloc(allo: *std.mem.Allocator, old_mem: []u8, old_align: u29, new_size: usize, new_align: u29) ![]u8 { | ||
| 29 | const self = @fieldParentPtr(LeakCountAllocator, "allocator", allo); | ||
| 30 | if (old_mem.len == 0) { | ||
| 31 | self.count += 1; | ||
| 32 | } | ||
| 33 | return self.internal_allocator.reallocFn(self.internal_allocator, old_mem, old_align, new_size, new_align); | ||
| 34 | } | ||
| 35 | |||
| 36 | fn shrink(allo: *std.mem.Allocator, old_mem: []u8, old_align: u29, new_size: usize, new_align: u29) []u8 { | ||
| 37 | const self = @fieldParentPtr(LeakCountAllocator, "allocator", allo); | ||
| 38 | if (new_size == 0) { | ||
| 39 | self.count -= 1; | ||
| 40 | } | ||
| 41 | return self.internal_allocator.shrinkFn(self.internal_allocator, old_mem, old_align, new_size, new_align); | ||
| 42 | } | ||
| 43 | |||
| 44 | fn validate(self: LeakCountAllocator) !void { | ||
| 45 | if (self.count > 0) { | ||
| 46 | std.debug.warn("Detected leaked allocations without matching free: {}\n", .{self.count}); | ||
| 47 | return error.Leak; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 10 | /// This function is intended to be used only in tests. It prints diagnostics to stderr | 52 | /// This function is intended to be used only in tests. It prints diagnostics to stderr |
| 11 | /// and then aborts when actual_error_union is not expected_error. | 53 | /// and then aborts when actual_error_union is not expected_error. |
| 12 | pub fn expectError(expected_error: anyerror, actual_error_union: var) void { | 54 | pub fn expectError(expected_error: anyerror, actual_error_union: var) void { |
lib/std/unicode.zig+12-6| ... | @@ -501,14 +501,16 @@ test "utf16leToUtf8" { | ... | @@ -501,14 +501,16 @@ test "utf16leToUtf8" { |
| 501 | { | 501 | { |
| 502 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A'); | 502 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 'A'); |
| 503 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 'a'); | 503 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 'a'); |
| 504 | const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le); | 504 | const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le); |
| 505 | defer std.testing.leak_count_allocator.free(utf8); | ||
| 505 | testing.expect(mem.eql(u8, utf8, "Aa")); | 506 | testing.expect(mem.eql(u8, utf8, "Aa")); |
| 506 | } | 507 | } |
| 507 | 508 | ||
| 508 | { | 509 | { |
| 509 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0x80); | 510 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0x80); |
| 510 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xffff); | 511 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xffff); |
| 511 | const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le); | 512 | const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le); |
| 513 | defer std.testing.leak_count_allocator.free(utf8); | ||
| 512 | testing.expect(mem.eql(u8, utf8, "\xc2\x80" ++ "\xef\xbf\xbf")); | 514 | testing.expect(mem.eql(u8, utf8, "\xc2\x80" ++ "\xef\xbf\xbf")); |
| 513 | } | 515 | } |
| 514 | 516 | ||
| ... | @@ -516,7 +518,8 @@ test "utf16leToUtf8" { | ... | @@ -516,7 +518,8 @@ test "utf16leToUtf8" { |
| 516 | // the values just outside the surrogate half range | 518 | // the values just outside the surrogate half range |
| 517 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd7ff); | 519 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd7ff); |
| 518 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xe000); | 520 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xe000); |
| 519 | const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le); | 521 | const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le); |
| 522 | defer std.testing.leak_count_allocator.free(utf8); | ||
| 520 | testing.expect(mem.eql(u8, utf8, "\xed\x9f\xbf" ++ "\xee\x80\x80")); | 523 | testing.expect(mem.eql(u8, utf8, "\xed\x9f\xbf" ++ "\xee\x80\x80")); |
| 521 | } | 524 | } |
| 522 | 525 | ||
| ... | @@ -524,7 +527,8 @@ test "utf16leToUtf8" { | ... | @@ -524,7 +527,8 @@ test "utf16leToUtf8" { |
| 524 | // smallest surrogate pair | 527 | // smallest surrogate pair |
| 525 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd800); | 528 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xd800); |
| 526 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00); | 529 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00); |
| 527 | const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le); | 530 | const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le); |
| 531 | defer std.testing.leak_count_allocator.free(utf8); | ||
| 528 | testing.expect(mem.eql(u8, utf8, "\xf0\x90\x80\x80")); | 532 | testing.expect(mem.eql(u8, utf8, "\xf0\x90\x80\x80")); |
| 529 | } | 533 | } |
| 530 | 534 | ||
| ... | @@ -532,14 +536,16 @@ test "utf16leToUtf8" { | ... | @@ -532,14 +536,16 @@ test "utf16leToUtf8" { |
| 532 | // largest surrogate pair | 536 | // largest surrogate pair |
| 533 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff); | 537 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff); |
| 534 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdfff); | 538 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdfff); |
| 535 | const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le); | 539 | const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le); |
| 540 | defer std.testing.leak_count_allocator.free(utf8); | ||
| 536 | testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xbf\xbf")); | 541 | testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xbf\xbf")); |
| 537 | } | 542 | } |
| 538 | 543 | ||
| 539 | { | 544 | { |
| 540 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff); | 545 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[0..], 0xdbff); |
| 541 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00); | 546 | mem.writeIntSliceLittle(u16, utf16le_as_bytes[2..], 0xdc00); |
| 542 | const utf8 = try utf16leToUtf8Alloc(std.testing.allocator, &utf16le); | 547 | const utf8 = try utf16leToUtf8Alloc(std.testing.leak_count_allocator, &utf16le); |
| 548 | defer std.testing.leak_count_allocator.free(utf8); | ||
| 543 | testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xb0\x80")); | 549 | testing.expect(mem.eql(u8, utf8, "\xf4\x8f\xb0\x80")); |
| 544 | } | 550 | } |
| 545 | } | 551 | } |
lib/std/zig/ast.zig+1-1| ... | @@ -2287,7 +2287,7 @@ pub const Node = struct { | ... | @@ -2287,7 +2287,7 @@ pub const Node = struct { |
| 2287 | test "iterate" { | 2287 | test "iterate" { |
| 2288 | var root = Node.Root{ | 2288 | var root = Node.Root{ |
| 2289 | .base = Node{ .id = Node.Id.Root }, | 2289 | .base = Node{ .id = Node.Id.Root }, |
| 2290 | .decls = Node.Root.DeclList.init(std.testing.allocator), | 2290 | .decls = Node.Root.DeclList.init(std.testing.leak_count_allocator), |
| 2291 | .eof_token = 0, | 2291 | .eof_token = 0, |
| 2292 | }; | 2292 | }; |
| 2293 | var base = &root.base; | 2293 | var base = &root.base; |
test/compare_output.zig+2-2| ... | @@ -445,7 +445,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -445,7 +445,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 445 | \\const std = @import("std"); | 445 | \\const std = @import("std"); |
| 446 | \\const io = std.io; | 446 | \\const io = std.io; |
| 447 | \\const os = std.os; | 447 | \\const os = std.os; |
| 448 | \\const allocator = std.testing.allocator; | 448 | \\const allocator = std.testing.leak_count_allocator; |
| 449 | \\ | 449 | \\ |
| 450 | \\pub fn main() !void { | 450 | \\pub fn main() !void { |
| 451 | \\ var args_it = std.process.args(); | 451 | \\ var args_it = std.process.args(); |
| ... | @@ -486,7 +486,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { | ... | @@ -486,7 +486,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 486 | \\const std = @import("std"); | 486 | \\const std = @import("std"); |
| 487 | \\const io = std.io; | 487 | \\const io = std.io; |
| 488 | \\const os = std.os; | 488 | \\const os = std.os; |
| 489 | \\const allocator = std.testing.allocator; | 489 | \\const allocator = std.testing.leak_count_allocator; |
| 490 | \\ | 490 | \\ |
| 491 | \\pub fn main() !void { | 491 | \\pub fn main() !void { |
| 492 | \\ var args_it = std.process.args(); | 492 | \\ var args_it = std.process.args(); |
test/compile_errors.zig+1-1| ... | @@ -5765,7 +5765,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { | ... | @@ -5765,7 +5765,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5765 | \\ | 5765 | \\ |
| 5766 | \\export fn entry() void { | 5766 | \\export fn entry() void { |
| 5767 | \\ const a = MdNode.Header { | 5767 | \\ const a = MdNode.Header { |
| 5768 | \\ .text = MdText.init(&std.testing.allocator), | 5768 | \\ .text = MdText.init(&std.testing.leak_count_allocator), |
| 5769 | \\ .weight = HeaderWeight.H1, | 5769 | \\ .weight = HeaderWeight.H1, |
| 5770 | \\ }; | 5770 | \\ }; |
| 5771 | \\} | 5771 | \\} |
test/stage1/behavior/const_slice_child.zig+1-1| ... | @@ -22,7 +22,7 @@ fn foo(args: [][]const u8) void { | ... | @@ -22,7 +22,7 @@ fn foo(args: [][]const u8) void { |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | fn bar(argc: usize) void { | 24 | fn bar(argc: usize) void { |
| 25 | const args = testing.allocator.alloc([]const u8, argc) catch unreachable; | 25 | const args = testing.leak_count_allocator.alloc([]const u8, argc) catch unreachable; |
| 26 | for (args) |_, i| { | 26 | for (args) |_, i| { |
| 27 | const ptr = argv[i]; | 27 | const ptr = argv[i]; |
| 28 | args[i] = ptr[0..strlen(ptr)]; | 28 | args[i] = ptr[0..strlen(ptr)]; |
test/standalone/brace_expansion/main.zig+2-2| ... | @@ -201,7 +201,7 @@ pub fn main() !void { | ... | @@ -201,7 +201,7 @@ pub fn main() !void { |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | test "invalid inputs" { | 203 | test "invalid inputs" { |
| 204 | global_allocator = std.testing.allocator; | 204 | global_allocator = std.testing.leak_count_allocator; |
| 205 | 205 | ||
| 206 | expectError("}ABC", error.InvalidInput); | 206 | expectError("}ABC", error.InvalidInput); |
| 207 | expectError("{ABC", error.InvalidInput); | 207 | expectError("{ABC", error.InvalidInput); |
| ... | @@ -222,7 +222,7 @@ fn expectError(test_input: []const u8, expected_err: anyerror) void { | ... | @@ -222,7 +222,7 @@ fn expectError(test_input: []const u8, expected_err: anyerror) void { |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | test "valid inputs" { | 224 | test "valid inputs" { |
| 225 | global_allocator = std.testing.allocator; | 225 | global_allocator = std.testing.leak_count_allocator; |
| 226 | 226 | ||
| 227 | expectExpansion("{x,y,z}", "x y z"); | 227 | expectExpansion("{x,y,z}", "x y z"); |
| 228 | expectExpansion("{A,B}{x,y}", "Ax Ay Bx By"); | 228 | expectExpansion("{A,B}{x,y}", "Ax Ay Bx By"); |
test/standalone/cat/main.zig+1-1| ... | @@ -4,7 +4,7 @@ const process = std.process; | ... | @@ -4,7 +4,7 @@ const process = std.process; |
| 4 | const fs = std.fs; | 4 | const fs = std.fs; |
| 5 | const mem = std.mem; | 5 | const mem = std.mem; |
| 6 | const warn = std.debug.warn; | 6 | const warn = std.debug.warn; |
| 7 | const allocator = std.testing.allocator; | 7 | const allocator = std.testing.leak_count_allocator; |
| 8 | 8 | ||
| 9 | pub fn main() !void { | 9 | pub fn main() !void { |
| 10 | var args_it = process.args(); | 10 | var args_it = process.args(); |
test/standalone/empty_env/main.zig+1-1| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn main() void { | 3 | pub fn main() void { |
| 4 | const env_map = std.process.getEnvMap(std.testing.allocator) catch @panic("unable to get env map"); | 4 | const env_map = std.process.getEnvMap(std.testing.leak_count_allocator) catch @panic("unable to get env map"); |
| 5 | std.testing.expect(env_map.count() == 0); | 5 | std.testing.expect(env_map.count() == 0); |
| 6 | } | 6 | } |
test/standalone/load_dynamic_library/main.zig+2-2| ... | @@ -1,8 +1,8 @@ | ... | @@ -1,8 +1,8 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn main() !void { | 3 | pub fn main() !void { |
| 4 | const args = try std.process.argsAlloc(std.testing.allocator); | 4 | const args = try std.process.argsAlloc(std.testing.leak_count_allocator); |
| 5 | defer std.process.argsFree(std.testing.allocator, args); | 5 | defer std.process.argsFree(std.testing.leak_count_allocator, args); |
| 6 | 6 | ||
| 7 | const dynlib_name = args[1]; | 7 | const dynlib_name = args[1]; |
| 8 | 8 |