Skip to content

Commit 4183c6f

Browse files
committedDec 24, 2017
move std/debug.zig to a subdirectory
self hosted compiler parser tests do some fuzz testing
·
0.15.20.2.0
1 parent 9dae796 commit 4183c6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+297
-223
lines changed
 

‎CMakeLists.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ install(FILES "${CMAKE_SOURCE_DIR}/std/c/index.zig" DESTINATION "${ZIG_STD_DEST}
516516
install(FILES "${CMAKE_SOURCE_DIR}/std/c/linux.zig" DESTINATION "${ZIG_STD_DEST}/c")
517517
install(FILES "${CMAKE_SOURCE_DIR}/std/c/windows.zig" DESTINATION "${ZIG_STD_DEST}/c")
518518
install(FILES "${CMAKE_SOURCE_DIR}/std/cstr.zig" DESTINATION "${ZIG_STD_DEST}")
519-
install(FILES "${CMAKE_SOURCE_DIR}/std/debug.zig" DESTINATION "${ZIG_STD_DEST}")
519+
install(FILES "${CMAKE_SOURCE_DIR}/std/debug/index.zig" DESTINATION "${ZIG_STD_DEST}/debug")
520+
install(FILES "${CMAKE_SOURCE_DIR}/std/debug/failing_allocator.zig" DESTINATION "${ZIG_STD_DEST}/debug")
520521
install(FILES "${CMAKE_SOURCE_DIR}/std/dwarf.zig" DESTINATION "${ZIG_STD_DEST}")
521522
install(FILES "${CMAKE_SOURCE_DIR}/std/elf.zig" DESTINATION "${ZIG_STD_DEST}")
522523
install(FILES "${CMAKE_SOURCE_DIR}/std/empty.zig" DESTINATION "${ZIG_STD_DEST}")

‎build.zig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ pub fn installStdLib(b: &Builder) {
172172
"c/linux.zig",
173173
"c/windows.zig",
174174
"cstr.zig",
175-
"debug.zig",
175+
"debug/failing_allocator.zig",
176+
"debug/index.zig",
176177
"dwarf.zig",
177178
"elf.zig",
178179
"empty.zig",

‎src-self-hosted/parser.zig‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,18 +1119,24 @@ fn testCanonical(source: []const u8) {
11191119
break :x failing_allocator.index;
11201120
};
11211121

1122-
// TODO make this pass
1123-
//var fail_index = needed_alloc_count;
1124-
//while (fail_index != 0) {
1125-
// fail_index -= 1;
1126-
// var fixed_allocator = mem.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
1127-
// var failing_allocator = std.debug.FailingAllocator.init(&fixed_allocator.allocator, fail_index);
1128-
// if (testParse(source, &failing_allocator.allocator)) |_| {
1129-
// @panic("non-deterministic memory usage");
1130-
// } else |err| {
1131-
// assert(err == error.OutOfMemory);
1132-
// }
1133-
//}
1122+
var fail_index: usize = 0;
1123+
while (fail_index < needed_alloc_count) : (fail_index += 1) {
1124+
var fixed_allocator = mem.FixedBufferAllocator.init(fixed_buffer_mem[0..]);
1125+
var failing_allocator = std.debug.FailingAllocator.init(&fixed_allocator.allocator, fail_index);
1126+
if (testParse(source, &failing_allocator.allocator)) |_| {
1127+
@panic("non-deterministic memory usage");
1128+
} else |err| {
1129+
assert(err == error.OutOfMemory);
1130+
// TODO make this pass
1131+
//if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) {
1132+
// warn("\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n",
1133+
// fail_index, needed_alloc_count,
1134+
// failing_allocator.allocated_bytes, failing_allocator.freed_bytes,
1135+
// failing_allocator.index, failing_allocator.deallocations);
1136+
// @panic("memory leak detected");
1137+
//}
1138+
}
1139+
}
11341140
}
11351141

11361142
test "zig fmt" {

‎std/array_list.zig‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const debug = @import("debug.zig");
1+
const std = @import("index.zig");
2+
const debug = std.debug;
23
const assert = debug.assert;
3-
const mem = @import("mem.zig");
4+
const mem = std.mem;
45
const Allocator = mem.Allocator;
56

67
pub fn ArrayList(comptime T: type) -> type {

0 commit comments

Comments
 (0)
Please sign in to comment.