aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-01-09 00:07:01 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-01-09 00:51:51 -0500
commit3c094116aae459b651934663a31981cf09cdb3e4 (patch)
tree18230df032df9f9857ce6c412c50ca5ad4ffec08 /test
parent98a95cc6987988886b90957415e9ef850b6fb119 (diff)
downloadzig-3c094116aae459b651934663a31981cf09cdb3e4.tar.gz
zig-3c094116aae459b651934663a31981cf09cdb3e4.zip
remove %% prefix operator
See #632 closes #545 closes #510 this makes #651 higher priority
Diffstat (limited to 'test')
-rw-r--r--test/cases/cast.zig24
-rw-r--r--test/cases/const_slice_child.zig2
-rw-r--r--test/cases/defer.zig2
-rw-r--r--test/cases/enum_with_members.zig4
-rw-r--r--test/cases/error.zig6
-rw-r--r--test/cases/ir_block_deps.zig4
-rw-r--r--test/cases/misc.zig4
-rw-r--r--test/cases/switch_prong_err_enum.zig2
-rw-r--r--test/cases/switch_prong_implicit_cast.zig2
-rw-r--r--test/cases/union.zig2
-rw-r--r--test/cases/while.zig2
-rw-r--r--test/compare_output.zig88
-rw-r--r--test/compile_errors.zig4
-rw-r--r--test/standalone/issue_339/test.zig2
-rw-r--r--test/tests.zig138
15 files changed, 143 insertions, 143 deletions
diff --git a/test/cases/cast.zig b/test/cases/cast.zig
index 15cdf47349..673c5891e3 100644
--- a/test/cases/cast.zig
+++ b/test/cases/cast.zig
@@ -85,14 +85,14 @@ const A = struct {
fn castToMaybeTypeError(z: i32) {
const x = i32(1);
const y: %?i32 = x;
- assert(??%%y == 1);
+ assert(??(try y) == 1);
const f = z;
const g: %?i32 = f;
const a = A{ .a = z };
const b: %?A = a;
- assert((??%%b).a == 1);
+ assert((??(b catch unreachable)).a == 1);
}
test "implicitly cast from int to %?T" {
@@ -108,7 +108,7 @@ fn implicitIntLitToMaybe() {
test "return null from fn() -> %?&T" {
const a = returnNullFromMaybeTypeErrorRef();
const b = returnNullLitFromMaybeTypeErrorRef();
- assert(%%a == null and %%b == null);
+ assert((try a) == null and (try b) == null);
}
fn returnNullFromMaybeTypeErrorRef() -> %?&A {
const a: ?&A = null;
@@ -167,7 +167,7 @@ test "implicitly cast from [0]T to %[]T" {
}
fn testCastZeroArrayToErrSliceMut() {
- assert((%%gimmeErrOrSlice()).len == 0);
+ assert((gimmeErrOrSlice() catch unreachable).len == 0);
}
fn gimmeErrOrSlice() -> %[]u8 {
@@ -178,14 +178,14 @@ test "peer type resolution: [0]u8, []const u8, and %[]u8" {
{
var data = "hi";
const slice = data[0..];
- assert((%%peerTypeEmptyArrayAndSliceAndError(true, slice)).len == 0);
- assert((%%peerTypeEmptyArrayAndSliceAndError(false, slice)).len == 1);
+ assert((try peerTypeEmptyArrayAndSliceAndError(true, slice)).len == 0);
+ assert((try peerTypeEmptyArrayAndSliceAndError(false, slice)).len == 1);
}
comptime {
var data = "hi";
const slice = data[0..];
- assert((%%peerTypeEmptyArrayAndSliceAndError(true, slice)).len == 0);
- assert((%%peerTypeEmptyArrayAndSliceAndError(false, slice)).len == 1);
+ assert((try peerTypeEmptyArrayAndSliceAndError(true, slice)).len == 0);
+ assert((try peerTypeEmptyArrayAndSliceAndError(false, slice)).len == 1);
}
}
fn peerTypeEmptyArrayAndSliceAndError(a: bool, slice: []u8) -> %[]u8 {
@@ -231,11 +231,11 @@ fn foo(args: ...) {
test "peer type resolution: error and [N]T" {
// TODO: implicit %T to %U where T can implicitly cast to U
- //assert(mem.eql(u8, %%testPeerErrorAndArray(0), "OK"));
- //comptime assert(mem.eql(u8, %%testPeerErrorAndArray(0), "OK"));
+ //assert(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
+ //comptime assert(mem.eql(u8, try testPeerErrorAndArray(0), "OK"));
- assert(mem.eql(u8, %%testPeerErrorAndArray2(1), "OKK"));
- comptime assert(mem.eql(u8, %%testPeerErrorAndArray2(1), "OKK"));
+ assert(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
+ comptime assert(mem.eql(u8, try testPeerErrorAndArray2(1), "OKK"));
}
error BadValue;
diff --git a/test/cases/const_slice_child.zig b/test/cases/const_slice_child.zig
index e1e06b4e7f..4b7905ec97 100644
--- a/test/cases/const_slice_child.zig
+++ b/test/cases/const_slice_child.zig
@@ -21,7 +21,7 @@ fn foo(args: [][]const u8) {
}
fn bar(argc: usize) {
- const args = %%debug.global_allocator.alloc([]const u8, argc);
+ const args = debug.global_allocator.alloc([]const u8, argc) catch unreachable;
for (args) |_, i| {
const ptr = argv[i];
args[i] = ptr[0..strlen(ptr)];
diff --git a/test/cases/defer.zig b/test/cases/defer.zig
index b1eee8bece..b84e784713 100644
--- a/test/cases/defer.zig
+++ b/test/cases/defer.zig
@@ -14,7 +14,7 @@ fn runSomeErrorDefers(x: bool) -> %bool {
}
test "mixing normal and error defers" {
- assert(%%runSomeErrorDefers(true));
+ assert(runSomeErrorDefers(true) catch unreachable);
assert(result[0] == 'c');
assert(result[1] == 'a');
diff --git a/test/cases/enum_with_members.zig b/test/cases/enum_with_members.zig
index c28692575e..b5bf3ae299 100644
--- a/test/cases/enum_with_members.zig
+++ b/test/cases/enum_with_members.zig
@@ -19,9 +19,9 @@ test "enum with members" {
const b = ET { .UINT = 42 };
var buf: [20]u8 = undefined;
- assert(%%a.print(buf[0..]) == 3);
+ assert((a.print(buf[0..]) catch unreachable) == 3);
assert(mem.eql(u8, buf[0..3], "-42"));
- assert(%%b.print(buf[0..]) == 2);
+ assert((b.print(buf[0..]) catch unreachable) == 2);
assert(mem.eql(u8, buf[0..2], "42"));
}
diff --git a/test/cases/error.zig b/test/cases/error.zig
index dbe96366d3..f4743082d9 100644
--- a/test/cases/error.zig
+++ b/test/cases/error.zig
@@ -16,7 +16,7 @@ pub fn baz() -> %i32 {
}
test "error wrapping" {
- assert(%%baz() == 15);
+ assert((baz() catch unreachable) == 15);
}
error ItBroke;
@@ -65,14 +65,14 @@ fn errBinaryOperatorG(x: bool) -> %isize {
test "unwrap simple value from error" {
- const i = %%unwrapSimpleValueFromErrorDo();
+ const i = unwrapSimpleValueFromErrorDo() catch unreachable;
assert(i == 13);
}
fn unwrapSimpleValueFromErrorDo() -> %isize { return 13; }
test "error return in assignment" {
- %%doErrReturnInAssignment();
+ doErrReturnInAssignment() catch unreachable;
}
fn doErrReturnInAssignment() -> %void {
diff --git a/test/cases/ir_block_deps.zig b/test/cases/ir_block_deps.zig
index 6932a58b7f..12b8808050 100644
--- a/test/cases/ir_block_deps.zig
+++ b/test/cases/ir_block_deps.zig
@@ -16,6 +16,6 @@ fn getErrInt() -> %i32 { return 0; }
error ItBroke;
test "ir block deps" {
- assert(%%foo(1) == 0);
- assert(%%foo(2) == 0);
+ assert((foo(1) catch unreachable) == 0);
+ assert((foo(2) catch unreachable) == 0);
}
diff --git a/test/cases/misc.zig b/test/cases/misc.zig
index e3ddfdfd76..137fda9c74 100644
--- a/test/cases/misc.zig
+++ b/test/cases/misc.zig
@@ -258,7 +258,7 @@ test "explicit cast maybe pointers" {
}
test "generic malloc free" {
- const a = %%memAlloc(u8, 10);
+ const a = memAlloc(u8, 10) catch unreachable;
memFree(u8, a);
}
const some_mem : [100]u8 = undefined;
@@ -417,7 +417,7 @@ test "cast slice to u8 slice" {
}
test "pointer to void return type" {
- %%testPointerToVoidReturnType();
+ testPointerToVoidReturnType() catch unreachable;
}
fn testPointerToVoidReturnType() -> %void {
const a = testPointerToVoidReturnType2();
diff --git a/test/cases/switch_prong_err_enum.zig b/test/cases/switch_prong_err_enum.zig
index 90aa4a4d44..0585112ecf 100644
--- a/test/cases/switch_prong_err_enum.zig
+++ b/test/cases/switch_prong_err_enum.zig
@@ -22,7 +22,7 @@ fn doThing(form_id: u64) -> %FormValue {
}
test "switch prong returns error enum" {
- switch (%%doThing(17)) {
+ switch (doThing(17) catch unreachable) {
FormValue.Address => |payload| { assert(payload == 1); },
else => unreachable,
}
diff --git a/test/cases/switch_prong_implicit_cast.zig b/test/cases/switch_prong_implicit_cast.zig
index 9e7c091494..b59231038d 100644
--- a/test/cases/switch_prong_implicit_cast.zig
+++ b/test/cases/switch_prong_implicit_cast.zig
@@ -16,7 +16,7 @@ fn foo(id: u64) -> %FormValue {
}
test "switch prong implicit cast" {
- const result = switch (%%foo(2)) {
+ const result = switch (foo(2) catch unreachable) {
FormValue.One => false,
FormValue.Two => |x| x,
};
diff --git a/test/cases/union.zig b/test/cases/union.zig
index 6db43fc14b..adab8b7e96 100644
--- a/test/cases/union.zig
+++ b/test/cases/union.zig
@@ -26,7 +26,7 @@ test "unions embedded in aggregate types" {
Value.Array => |arr| assert(arr[4] == 3),
else => unreachable,
}
- switch((%%err).val1) {
+ switch((err catch unreachable).val1) {
Value.Int => |x| assert(x == 1234),
else => unreachable,
}
diff --git a/test/cases/while.zig b/test/cases/while.zig
index e61fe1f9d2..f1e269b9fd 100644
--- a/test/cases/while.zig
+++ b/test/cases/while.zig
@@ -48,7 +48,7 @@ fn runContinueAndBreakTest() {
}
test "return with implicit cast from while loop" {
- %%returnWithImplicitCastFromWhileLoopTest();
+ returnWithImplicitCastFromWhileLoopTest() catch unreachable;
}
fn returnWithImplicitCastFromWhileLoopTest() -> %void {
while (true) {
diff --git a/test/compare_output.zig b/test/compare_output.zig
index d7b9e3e167..e4600d70e5 100644
--- a/test/compare_output.zig
+++ b/test/compare_output.zig
@@ -17,8 +17,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\
\\pub fn main() -> %void {
\\ privateFunction();
- \\ const stdout = &(FileOutStream.init(&%%getStdOut()).stream);
- \\ %%stdout.print("OK 2\n");
+ \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream);
+ \\ stdout.print("OK 2\n") catch unreachable;
\\}
\\
\\fn privateFunction() {
@@ -32,8 +32,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\// purposefully conflicting function with main.zig
\\// but it's private so it should be OK
\\fn privateFunction() {
- \\ const stdout = &(FileOutStream.init(&%%getStdOut()).stream);
- \\ %%stdout.print("OK 1\n");
+ \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream);
+ \\ stdout.print("OK 1\n") catch unreachable;
\\}
\\
\\pub fn printText() {
@@ -58,8 +58,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
tc.addSourceFile("foo.zig",
\\use @import("std").io;
\\pub fn foo_function() {
- \\ const stdout = &(FileOutStream.init(&%%getStdOut()).stream);
- \\ %%stdout.print("OK\n");
+ \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream);
+ \\ stdout.print("OK\n") catch unreachable;
\\}
);
@@ -69,8 +69,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\
\\pub fn bar_function() {
\\ if (foo_function()) {
- \\ const stdout = &(FileOutStream.init(&%%getStdOut()).stream);
- \\ %%stdout.print("OK\n");
+ \\ const stdout = &(FileOutStream.init(&(getStdOut() catch unreachable)).stream);
+ \\ stdout.print("OK\n") catch unreachable;
\\ }
\\}
);
@@ -101,8 +101,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\pub const a_text = "OK\n";
\\
\\pub fn ok() {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print(b_text);
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print(b_text) catch unreachable;
\\}
);
@@ -119,8 +119,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\const io = @import("std").io;
\\
\\pub fn main() -> %void {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print("Hello, world!\n{d4} {x3} {c}\n", u32(12), u16(0x12), u8('a'));
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print("Hello, world!\n{d4} {x3} {c}\n", u32(12), u16(0x12), u8('a')) catch unreachable;
\\}
, "Hello, world!\n0012 012 a\n");
@@ -272,8 +272,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\ var x_local : i32 = print_ok(x);
\\}
\\fn print_ok(val: @typeOf(x)) -> @typeOf(foo) {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print("OK\n");
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print("OK\n") catch unreachable;
\\ return 0;
\\}
\\const foo : i32 = 0;
@@ -354,26 +354,26 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\pub fn main() -> %void {
\\ const bar = Bar {.field2 = 13,};
\\ const foo = Foo {.field1 = bar,};
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
\\ if (!foo.method()) {
- \\ %%stdout.print("BAD\n");
+ \\ stdout.print("BAD\n") catch unreachable;
\\ }
\\ if (!bar.method()) {
- \\ %%stdout.print("BAD\n");
+ \\ stdout.print("BAD\n") catch unreachable;
\\ }
- \\ %%stdout.print("OK\n");
+ \\ stdout.print("OK\n") catch unreachable;
\\}
, "OK\n");
cases.add("defer with only fallthrough",
\\const io = @import("std").io;
\\pub fn main() -> %void {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print("before\n");
- \\ defer %%stdout.print("defer1\n");
- \\ defer %%stdout.print("defer2\n");
- \\ defer %%stdout.print("defer3\n");
- \\ %%stdout.print("after\n");
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print("before\n") catch unreachable;
+ \\ defer stdout.print("defer1\n") catch unreachable;
+ \\ defer stdout.print("defer2\n") catch unreachable;
+ \\ defer stdout.print("defer3\n") catch unreachable;
+ \\ stdout.print("after\n") catch unreachable;
\\}
, "before\nafter\ndefer3\ndefer2\ndefer1\n");
@@ -381,14 +381,14 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\const io = @import("std").io;
\\const os = @import("std").os;
\\pub fn main() -> %void {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print("before\n");
- \\ defer %%stdout.print("defer1\n");
- \\ defer %%stdout.print("defer2\n");
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print("before\n") catch unreachable;
+ \\ defer stdout.print("defer1\n") catch unreachable;
+ \\ defer stdout.print("defer2\n") catch unreachable;
\\ var args_it = @import("std").os.args();
\\ if (args_it.skip() and !args_it.skip()) return;
- \\ defer %%stdout.print("defer3\n");
- \\ %%stdout.print("after\n");
+ \\ defer stdout.print("defer3\n") catch unreachable;
+ \\ stdout.print("after\n") catch unreachable;
\\}
, "before\ndefer2\ndefer1\n");
@@ -398,13 +398,13 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\ do_test() catch return;
\\}
\\fn do_test() -> %void {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print("before\n");
- \\ defer %%stdout.print("defer1\n");
- \\ %defer %%stdout.print("deferErr\n");
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print("before\n") catch unreachable;
+ \\ defer stdout.print("defer1\n") catch unreachable;
+ \\ %defer stdout.print("deferErr\n") catch unreachable;
\\ try its_gonna_fail();
- \\ defer %%stdout.print("defer3\n");
- \\ %%stdout.print("after\n");
+ \\ defer stdout.print("defer3\n") catch unreachable;
+ \\ stdout.print("after\n") catch unreachable;
\\}
\\error IToldYouItWouldFail;
\\fn its_gonna_fail() -> %void {
@@ -418,13 +418,13 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\ do_test() catch return;
\\}
\\fn do_test() -> %void {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print("before\n");
- \\ defer %%stdout.print("defer1\n");
- \\ %defer %%stdout.print("deferErr\n");
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print("before\n") catch unreachable;
+ \\ defer stdout.print("defer1\n") catch unreachable;
+ \\ %defer stdout.print("deferErr\n") catch unreachable;
\\ try its_gonna_pass();
- \\ defer %%stdout.print("defer3\n");
- \\ %%stdout.print("after\n");
+ \\ defer stdout.print("defer3\n") catch unreachable;
+ \\ stdout.print("after\n") catch unreachable;
\\}
\\fn its_gonna_pass() -> %void { }
, "before\nafter\ndefer3\ndefer1\n");
@@ -435,8 +435,8 @@ pub fn addCases(cases: &tests.CompareOutputContext) {
\\const io = @import("std").io;
\\
\\pub fn main() -> %void {
- \\ const stdout = &(io.FileOutStream.init(&%%io.getStdOut()).stream);
- \\ %%stdout.print(foo_txt);
+ \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream);
+ \\ stdout.print(foo_txt) catch unreachable;
\\}
, "1234\nabcd\n");
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index e6e769c85d..005fe55e41 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1423,10 +1423,10 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
cases.add("ignored assert-err-ok return value",
\\export fn foo() {
- \\ %%bar();
+ \\ bar() catch unreachable;
\\}
\\fn bar() -> %i32 { return 0; }
- , ".tmp_source.zig:2:5: error: expression value is ignored");
+ , ".tmp_source.zig:2:11: error: expression value is ignored");
cases.add("ignored statement value",
\\export fn foo() {
diff --git a/test/standalone/issue_339/test.zig b/test/standalone/issue_339/test.zig
index c1faa015c6..e0d6c3f3e5 100644
--- a/test/standalone/issue_339/test.zig
+++ b/test/standalone/issue_339/test.zig
@@ -3,5 +3,5 @@ pub fn panic(msg: []const u8) -> noreturn { @breakpoint(); while (true) {} }
fn bar() -> %void {}
export fn foo() {
- %%bar();
+ bar() catch unreachable;
}
diff --git a/test/tests.zig b/test/tests.zig
index b9808fe764..20e1e94459 100644
--- a/test/tests.zig
+++ b/test/tests.zig
@@ -54,7 +54,7 @@ error TestFailed;
const max_stdout_size = 1 * 1024 * 1024; // 1 MB
pub fn addCompareOutputTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
- const cases = %%b.allocator.create(CompareOutputContext);
+ const cases = b.allocator.create(CompareOutputContext) catch unreachable;
*cases = CompareOutputContext {
.b = b,
.step = b.step("test-compare-output", "Run the compare output tests"),
@@ -68,7 +68,7 @@ pub fn addCompareOutputTests(b: &build.Builder, test_filter: ?[]const u8) -> &bu
}
pub fn addDebugSafetyTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
- const cases = %%b.allocator.create(CompareOutputContext);
+ const cases = b.allocator.create(CompareOutputContext) catch unreachable;
*cases = CompareOutputContext {
.b = b,
.step = b.step("test-debug-safety", "Run the debug safety tests"),
@@ -82,7 +82,7 @@ pub fn addDebugSafetyTests(b: &build.Builder, test_filter: ?[]const u8) -> &buil
}
pub fn addCompileErrorTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
- const cases = %%b.allocator.create(CompileErrorContext);
+ const cases = b.allocator.create(CompileErrorContext) catch unreachable;
*cases = CompileErrorContext {
.b = b,
.step = b.step("test-compile-errors", "Run the compile error tests"),
@@ -96,7 +96,7 @@ pub fn addCompileErrorTests(b: &build.Builder, test_filter: ?[]const u8) -> &bui
}
pub fn addBuildExampleTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
- const cases = %%b.allocator.create(BuildExamplesContext);
+ const cases = b.allocator.create(BuildExamplesContext) catch unreachable;
*cases = BuildExamplesContext {
.b = b,
.step = b.step("test-build-examples", "Build the examples"),
@@ -110,7 +110,7 @@ pub fn addBuildExampleTests(b: &build.Builder, test_filter: ?[]const u8) -> &bui
}
pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
- const cases = %%b.allocator.create(CompareOutputContext);
+ const cases = b.allocator.create(CompareOutputContext) catch unreachable;
*cases = CompareOutputContext {
.b = b,
.step = b.step("test-asm-link", "Run the assemble and link tests"),
@@ -124,7 +124,7 @@ pub fn addAssembleAndLinkTests(b: &build.Builder, test_filter: ?[]const u8) -> &
}
pub fn addTranslateCTests(b: &build.Builder, test_filter: ?[]const u8) -> &build.Step {
- const cases = %%b.allocator.create(TranslateCContext);
+ const cases = b.allocator.create(TranslateCContext) catch unreachable;
*cases = TranslateCContext {
.b = b,
.step = b.step("test-translate-c", "Run the C header file parsing tests"),
@@ -197,10 +197,10 @@ pub const CompareOutputContext = struct {
};
pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) {
- %%self.sources.append(SourceFile {
+ self.sources.append(SourceFile {
.filename = filename,
.source = source,
- });
+ }) catch unreachable;
}
pub fn setCommandLineArgs(self: &TestCase, args: []const []const u8) {
@@ -222,7 +222,7 @@ pub const CompareOutputContext = struct {
cli_args: []const []const u8) -> &RunCompareOutputStep
{
const allocator = context.b.allocator;
- const ptr = %%allocator.create(RunCompareOutputStep);
+ const ptr = allocator.create(RunCompareOutputStep) catch unreachable;
*ptr = RunCompareOutputStep {
.context = context,
.exe_path = exe_path,
@@ -244,14 +244,14 @@ pub const CompareOutputContext = struct {
var args = ArrayList([]const u8).init(b.allocator);
defer args.deinit();
- %%args.append(full_exe_path);
+ args.append(full_exe_path) catch unreachable;
for (self.cli_args) |arg| {
- %%args.append(arg);
+ args.append(arg) catch unreachable;
}
warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
- const child = %%os.ChildProcess.init(args.toSliceConst(), b.allocator);
+ const child = os.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable;
defer child.deinit();
child.stdin_behavior = StdIo.Ignore;
@@ -267,8 +267,8 @@ pub const CompareOutputContext = struct {
var stdout_file_in_stream = io.FileInStream.init(&??child.stdout);
var stderr_file_in_stream = io.FileInStream.init(&??child.stderr);
- %%stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size);
- %%stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size);
+ stdout_file_in_stream.stream.readAllBuffer(&stdout, max_stdout_size) catch unreachable;
+ stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable;
const term = child.wait() catch |err| {
debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
@@ -313,7 +313,7 @@ pub const CompareOutputContext = struct {
name: []const u8) -> &DebugSafetyRunStep
{
const allocator = context.b.allocator;
- const ptr = %%allocator.create(DebugSafetyRunStep);
+ const ptr = allocator.create(DebugSafetyRunStep) catch unreachable;
*ptr = DebugSafetyRunStep {
.context = context,
.exe_path = exe_path,
@@ -333,7 +333,7 @@ pub const CompareOutputContext = struct {
warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
- const child = %%os.ChildProcess.init([][]u8{full_exe_path}, b.allocator);
+ const child = os.ChildProcess.init([][]u8{full_exe_path}, b.allocator) catch unreachable;
defer child.deinit();
child.env_map = &b.env_map;
@@ -416,11 +416,11 @@ pub const CompareOutputContext = struct {
pub fn addCase(self: &CompareOutputContext, case: &const TestCase) {
const b = self.b;
- const root_src = %%os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename);
+ const root_src = os.path.join(b.allocator, b.cache_root, case.sources.items[0].filename) catch unreachable;
switch (case.special) {
Special.Asm => {
- const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "assemble-and-link {}", case.name);
+ const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", case.name) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
return;
@@ -430,7 +430,7 @@ pub const CompareOutputContext = struct {
exe.addAssemblyFile(root_src);
for (case.sources.toSliceConst()) |src_file| {
- const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
+ const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable;
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
exe.step.dependOn(&write_src.step);
}
@@ -443,8 +443,8 @@ pub const CompareOutputContext = struct {
},
Special.None => {
for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast}) |mode| {
- const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "{} {} ({})",
- "compare-output", case.name, @tagName(mode));
+ const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})",
+ "compare-output", case.name, @tagName(mode)) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
continue;
@@ -457,7 +457,7 @@ pub const CompareOutputContext = struct {
}
for (case.sources.toSliceConst()) |src_file| {
- const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
+ const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable;
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
exe.step.dependOn(&write_src.step);
}
@@ -470,7 +470,7 @@ pub const CompareOutputContext = struct {
}
},
Special.DebugSafety => {
- const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "safety {}", case.name);
+ const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", case.name) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
return;
@@ -482,7 +482,7 @@ pub const CompareOutputContext = struct {
}
for (case.sources.toSliceConst()) |src_file| {
- const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
+ const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable;
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
exe.step.dependOn(&write_src.step);
}
@@ -515,14 +515,14 @@ pub const CompileErrorContext = struct {
};
pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) {
- %%self.sources.append(SourceFile {
+ self.sources.append(SourceFile {
.filename = filename,
.source = source,
- });
+ }) catch unreachable;
}
pub fn addExpectedError(self: &TestCase, text: []const u8) {
- %%self.expected_errors.append(text);
+ self.expected_errors.append(text) catch unreachable;
}
};
@@ -538,7 +538,7 @@ pub const CompileErrorContext = struct {
case: &const TestCase, build_mode: Mode) -> &CompileCmpOutputStep
{
const allocator = context.b.allocator;
- const ptr = %%allocator.create(CompileCmpOutputStep);
+ const ptr = allocator.create(CompileCmpOutputStep) catch unreachable;
*ptr = CompileCmpOutputStep {
.step = build.Step.init("CompileCmpOutput", allocator, make),
.context = context,
@@ -555,25 +555,25 @@ pub const CompileErrorContext = struct {
const self = @fieldParentPtr(CompileCmpOutputStep, "step", step);
const b = self.context.b;
- const root_src = %%os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename);
- const obj_path = %%os.path.join(b.allocator, b.cache_root, "test.o");
+ const root_src = os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename) catch unreachable;
+ const obj_path = os.path.join(b.allocator, b.cache_root, "test.o") catch unreachable;
var zig_args = ArrayList([]const u8).init(b.allocator);
- %%zig_args.append(b.zig_exe);
+ zig_args.append(b.zig_exe) catch unreachable;
- %%zig_args.append(if (self.case.is_exe) "build-exe" else "build-obj");
- %%zig_args.append(b.pathFromRoot(root_src));
+ zig_args.append(if (self.case.is_exe) "build-exe" else "build-obj") catch unreachable;
+ zig_args.append(b.pathFromRoot(root_src)) catch unreachable;
- %%zig_args.append("--name");
- %%zig_args.append("test");
+ zig_args.append("--name") catch unreachable;
+ zig_args.append("test") catch unreachable;
- %%zig_args.append("--output");
- %%zig_args.append(b.pathFromRoot(obj_path));
+ zig_args.append("--output") catch unreachable;
+ zig_args.append(b.pathFromRoot(obj_path)) catch unreachable;
switch (self.build_mode) {
Mode.Debug => {},
- Mode.ReleaseSafe => %%zig_args.append("--release-safe"),
- Mode.ReleaseFast => %%zig_args.append("--release-fast"),
+ Mode.ReleaseSafe => zig_args.append("--release-safe") catch unreachable,
+ Mode.ReleaseFast => zig_args.append("--release-fast") catch unreachable,
}
warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
@@ -582,7 +582,7 @@ pub const CompileErrorContext = struct {
printInvocation(zig_args.toSliceConst());
}
- const child = %%os.ChildProcess.init(zig_args.toSliceConst(), b.allocator);
+ const child = os.ChildProcess.init(zig_args.toSliceConst(), b.allocator) catch unreachable;
defer child.deinit();
child.env_map = &b.env_map;
@@ -598,8 +598,8 @@ pub const CompileErrorContext = struct {
var stdout_file_in_stream = io.FileInStream.init(&??child.stdout);
var stderr_file_in_stream = io.FileInStream.init(&??child.stderr);
- %%stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size);
- %%stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size);
+ stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable;
+ stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
const term = child.wait() catch |err| {
debug.panic("Unable to spawn {}: {}\n", zig_args.items[0], @errorName(err));
@@ -660,7 +660,7 @@ pub const CompileErrorContext = struct {
pub fn create(self: &CompileErrorContext, name: []const u8, source: []const u8,
expected_lines: ...) -> &TestCase
{
- const tc = %%self.b.allocator.create(TestCase);
+ const tc = self.b.allocator.create(TestCase) catch unreachable;
*tc = TestCase {
.name = name,
.sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
@@ -697,8 +697,8 @@ pub const CompileErrorContext = struct {
const b = self.b;
for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast}) |mode| {
- const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "compile-error {} ({})",
- case.name, @tagName(mode));
+ const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {} ({})",
+ case.name, @tagName(mode)) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
continue;
@@ -708,7 +708,7 @@ pub const CompileErrorContext = struct {
self.step.dependOn(&compile_and_cmp_errors.step);
for (case.sources.toSliceConst()) |src_file| {
- const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
+ const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable;
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
compile_and_cmp_errors.step.dependOn(&write_src.step);
}
@@ -740,17 +740,17 @@ pub const BuildExamplesContext = struct {
}
var zig_args = ArrayList([]const u8).init(b.allocator);
- const rel_zig_exe = %%os.path.relative(b.allocator, b.build_root, b.zig_exe);
- %%zig_args.append(rel_zig_exe);
- %%zig_args.append("build");
+ const rel_zig_exe = os.path.relative(b.allocator, b.build_root, b.zig_exe) catch unreachable;
+ zig_args.append(rel_zig_exe) catch unreachable;
+ zig_args.append("build") catch unreachable;
- %%zig_args.append("--build-file");
- %%zig_args.append(b.pathFromRoot(build_file));
+ zig_args.append("--build-file") catch unreachable;
+ zig_args.append(b.pathFromRoot(build_file)) catch unreachable;
- %%zig_args.append("test");
+ zig_args.append("test") catch unreachable;
if (b.verbose) {
- %%zig_args.append("--verbose");
+ zig_args.append("--verbose") catch unreachable;
}
const run_cmd = b.addCommand(null, b.env_map, zig_args.toSliceConst());
@@ -765,8 +765,8 @@ pub const BuildExamplesContext = struct {
const b = self.b;
for ([]Mode{Mode.Debug, Mode.ReleaseSafe, Mode.ReleaseFast}) |mode| {
- const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "build {} ({})",
- root_src, @tagName(mode));
+ const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})",
+ root_src, @tagName(mode)) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
continue;
@@ -804,14 +804,14 @@ pub const TranslateCContext = struct {
};
pub fn addSourceFile(self: &TestCase, filename: []const u8, source: []const u8) {
- %%self.sources.append(SourceFile {
+ self.sources.append(SourceFile {
.filename = filename,
.source = source,
- });
+ }) catch unreachable;
}
pub fn addExpectedLine(self: &TestCase, text: []const u8) {
- %%self.expected_lines.append(text);
+ self.expected_lines.append(text) catch unreachable;
}
};
@@ -824,7 +824,7 @@ pub const TranslateCContext = struct {
pub fn create(context: &TranslateCContext, name: []const u8, case: &const TestCase) -> &TranslateCCmpOutputStep {
const allocator = context.b.allocator;
- const ptr = %%allocator.create(TranslateCCmpOutputStep);
+ const ptr = allocator.create(TranslateCCmpOutputStep) catch unreachable;
*ptr = TranslateCCmpOutputStep {
.step = build.Step.init("ParseCCmpOutput", allocator, make),
.context = context,
@@ -840,13 +840,13 @@ pub const TranslateCContext = struct {
const self = @fieldParentPtr(TranslateCCmpOutputStep, "step", step);
const b = self.context.b;
- const root_src = %%os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename);
+ const root_src = os.path.join(b.allocator, b.cache_root, self.case.sources.items[0].filename) catch unreachable;
var zig_args = ArrayList([]const u8).init(b.allocator);
- %%zig_args.append(b.zig_exe);
+ zig_args.append(b.zig_exe) catch unreachable;
- %%zig_args.append("translate-c");
- %%zig_args.append(b.pathFromRoot(root_src));
+ zig_args.append("translate-c") catch unreachable;
+ zig_args.append(b.pathFromRoot(root_src)) catch unreachable;
warn("Test {}/{} {}...", self.test_index+1, self.context.test_index, self.name);
@@ -854,7 +854,7 @@ pub const TranslateCContext = struct {
printInvocation(zig_args.toSliceConst());
}
- const child = %%os.ChildProcess.init(zig_args.toSliceConst(), b.allocator);
+ const child = os.ChildProcess.init(zig_args.toSliceConst(), b.allocator) catch unreachable;
defer child.deinit();
child.env_map = &b.env_map;
@@ -870,8 +870,8 @@ pub const TranslateCContext = struct {
var stdout_file_in_stream = io.FileInStream.init(&??child.stdout);
var stderr_file_in_stream = io.FileInStream.init(&??child.stderr);
- %%stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size);
- %%stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size);
+ stdout_file_in_stream.stream.readAllBuffer(&stdout_buf, max_stdout_size) catch unreachable;
+ stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
const term = child.wait() catch |err| {
debug.panic("Unable to spawn {}: {}\n", zig_args.toSliceConst()[0], @errorName(err));
@@ -933,7 +933,7 @@ pub const TranslateCContext = struct {
pub fn create(self: &TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8,
source: []const u8, expected_lines: ...) -> &TestCase
{
- const tc = %%self.b.allocator.create(TestCase);
+ const tc = self.b.allocator.create(TestCase) catch unreachable;
*tc = TestCase {
.name = name,
.sources = ArrayList(TestCase.SourceFile).init(self.b.allocator),
@@ -966,7 +966,7 @@ pub const TranslateCContext = struct {
pub fn addCase(self: &TranslateCContext, case: &const TestCase) {
const b = self.b;
- const annotated_case_name = %%fmt.allocPrint(self.b.allocator, "translate-c {}", case.name);
+ const annotated_case_name = fmt.allocPrint(self.b.allocator, "translate-c {}", case.name) catch unreachable;
if (self.test_filter) |filter| {
if (mem.indexOf(u8, annotated_case_name, filter) == null)
return;
@@ -976,7 +976,7 @@ pub const TranslateCContext = struct {
self.step.dependOn(&translate_c_and_cmp.step);
for (case.sources.toSliceConst()) |src_file| {
- const expanded_src_path = %%os.path.join(b.allocator, b.cache_root, src_file.filename);
+ const expanded_src_path = os.path.join(b.allocator, b.cache_root, src_file.filename) catch unreachable;
const write_src = b.addWriteFile(expanded_src_path, src_file.source);
translate_c_and_cmp.step.dependOn(&write_src.step);
}