Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions zig-code/build-system/unit-testing-skip-foreign/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub fn build(b: *std.Build) void {
}
}

// zig-doctest: build-system --collapseable -- test --summary all

// build=succeed
// additional_option=test
// additional_option=--summary
// additional_option=all
12 changes: 8 additions & 4 deletions zig-code/build-system/unit-testing-skip-foreign/main.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// zig-doctest: syntax --name main
const std = @import("std");

test "simple test" {
var list = std.ArrayList(i32).init(std.testing.allocator);
defer list.deinit();
try list.append(42);
const allocator = std.testing.allocator;

var list: std.ArrayList(i32) = .empty;
defer list.deinit(allocator);

try list.append(allocator, 42);
try std.testing.expectEqual(@as(i32, 42), list.pop());
}

// syntax
9 changes: 6 additions & 3 deletions zig-code/build-system/unit-testing/main.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
const std = @import("std");

test "simple test" {
var list = std.ArrayList(i32).init(std.testing.allocator);
defer list.deinit();
try list.append(42);
const allocator = std.testing.allocator;

var list: std.ArrayList(i32) = .empty;
defer list.deinit(allocator);

try list.append(allocator, 42);
try std.testing.expectEqual(@as(i32, 42), list.pop());
}

Expand Down