From 3b5e26b7f7e4b37cf9357d058f32c0ad08ed7338 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 5 Jan 2017 03:57:48 -0500 Subject: [PATCH] self hosted tests import std library --- test/cases/array.zig | 35 ++------- test/cases/atomics.zig | 8 +- test/cases/bool.zig | 8 +- test/cases/cast.zig | 20 ++--- test/cases/const_slice_child.zig | 8 +- test/cases/defer.zig | 8 +- test/cases/enum.zig | 12 +-- test/cases/enum_with_members.zig | 70 ++--------------- test/cases/error.zig | 30 ++------ test/cases/eval.zig | 10 +-- test/cases/fn.zig | 10 +-- test/cases/for.zig | 27 ++----- test/cases/generics.zig | 9 +-- test/cases/goto.zig | 8 +- test/cases/if.zig | 8 +- test/cases/import.zig | 7 +- test/cases/ir_block_deps.zig | 8 +- test/cases/math.zig | 9 +-- test/cases/misc.zig | 76 +++++-------------- .../index.zig | 8 +- test/cases/null.zig | 9 +-- test/cases/pub_enum/index.zig | 8 +- test/cases/sizeof_and_typeof.zig | 8 +- test/cases/struct.zig | 9 +-- .../cases/struct_contains_slice_of_itself.zig | 8 +- test/cases/switch.zig | 9 +-- test/cases/switch_prong_err_enum.zig | 8 +- test/cases/switch_prong_implicit_cast.zig | 8 +- test/cases/this.zig | 8 +- test/cases/while.zig | 10 +-- 30 files changed, 100 insertions(+), 364 deletions(-) diff --git a/test/cases/array.zig b/test/cases/array.zig index 7839db9bb9..f29d36b680 100644 --- a/test/cases/array.zig +++ b/test/cases/array.zig @@ -1,3 +1,6 @@ +const assert = @import("std").debug.assert; +const str = @import("std").str; + fn arrays() { @setFnTest(this); @@ -60,32 +63,10 @@ fn nestedArrays() { const array_of_strings = [][]u8 {"hello", "this", "is", "my", "thing"}; for (array_of_strings) |s, i| { - if (i == 0) assert(memeql(s, "hello")); - if (i == 1) assert(memeql(s, "this")); - if (i == 2) assert(memeql(s, "is")); - if (i == 3) assert(memeql(s, "my")); - if (i == 4) assert(memeql(s, "thing")); + if (i == 0) assert(str.eql(s, "hello")); + if (i == 1) assert(str.eql(s, "this")); + if (i == 2) assert(str.eql(s, "is")); + if (i == 3) assert(str.eql(s, "my")); + if (i == 4) assert(str.eql(s, "thing")); } } - - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - -// TODO import from std.str -pub fn memeql(a: []const u8, b: []const u8) -> bool { - sliceEql(u8, a, b) -} - -// TODO import from std.str -pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { - if (a.len != b.len) return false; - for (a) |item, index| { - if (b[index] != item) return false; - } - return true; -} diff --git a/test/cases/atomics.zig b/test/cases/atomics.zig index 8b68ce3101..2b232bbf69 100644 --- a/test/cases/atomics.zig +++ b/test/cases/atomics.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn cmpxchg() { @setFnTest(this); @@ -13,9 +15,3 @@ fn fence() { @fence(AtomicOrder.SeqCst); x = 5678; } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/bool.zig b/test/cases/bool.zig index 2ae4247d24..2f5c7d42e7 100644 --- a/test/cases/bool.zig +++ b/test/cases/bool.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn boolLiterals() { @setFnTest(this); @@ -28,9 +30,3 @@ fn boolCmp() { fn testBoolCmp(a: bool, b: bool) -> bool { a == b } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/cast.zig b/test/cases/cast.zig index 02c9016e22..e4cae8fc0d 100644 --- a/test/cases/cast.zig +++ b/test/cases/cast.zig @@ -1,14 +1,10 @@ -//fn intToPtrCast() { -// @setFnTest(this); -// -// const x = isize(13); -// const y = (&u8)(x); -// const z = usize(y); -// assert(z == 13); -//} +const assert = @import("std").debug.assert; -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); +fn intToPtrCast() { + @setFnTest(this); + + const x = isize(13); + const y = (&u8)(x); + const z = usize(y); + assert(z == 13); } diff --git a/test/cases/const_slice_child.zig b/test/cases/const_slice_child.zig index afbb635f78..277da4be2b 100644 --- a/test/cases/const_slice_child.zig +++ b/test/cases/const_slice_child.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + var argv: &&const u8 = undefined; fn constSliceChild() { @@ -41,9 +43,3 @@ fn streql(a: []const u8, b: []const u8) -> bool { } return true; } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/defer.zig b/test/cases/defer.zig index f95ea06414..4bff9fab81 100644 --- a/test/cases/defer.zig +++ b/test/cases/defer.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + var result: [3]u8 = undefined; var index: usize = undefined; @@ -49,9 +51,3 @@ fn mixingNormalAndMaybeDefers() { assert(result[1] == 'b'); assert(result[2] == 'a'); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/enum.zig b/test/cases/enum.zig index 5d8ce4a321..37ba0fe4ec 100644 --- a/test/cases/enum.zig +++ b/test/cases/enum.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn enumType() { @setFnTest(this); @@ -111,13 +113,3 @@ const IntToEnumNumber = enum { Three, Four, }; - - -// TODO import from std -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - - - diff --git a/test/cases/enum_with_members.zig b/test/cases/enum_with_members.zig index 2c7256ca32..9be2d0f749 100644 --- a/test/cases/enum_with_members.zig +++ b/test/cases/enum_with_members.zig @@ -1,11 +1,15 @@ +const assert = @import("std").debug.assert; +const str = @import("std").str; +const io = @import("std").io; + const ET = enum { SINT: i32, UINT: u32, pub fn print(a: &ET, buf: []u8) -> %usize { return switch (*a) { - ET.SINT => |x| { bufPrintInt(i32, buf, x) }, - ET.UINT => |x| { bufPrintInt(u32, buf, x) }, + ET.SINT => |x| { io.bufPrintInt(i32, buf, x) }, + ET.UINT => |x| { io.bufPrintInt(u32, buf, x) }, } } }; @@ -18,66 +22,8 @@ fn enumWithMembers() { var buf: [20]u8 = undefined; assert(%%a.print(buf) == 3); - assert(memeql(buf[0...3], "-42")); + assert(str.eql(buf[0...3], "-42")); assert(%%b.print(buf) == 2); - assert(memeql(buf[0...2], "42")); -} - -// TODO all the below should be imported from std - -const max_u64_base10_digits = 20; -pub fn bufPrintInt(inline T: type, out_buf: []u8, x: T) -> usize { - if (T.is_signed) bufPrintSigned(T, out_buf, x) else bufPrintUnsigned(T, out_buf, x) -} - -fn bufPrintSigned(inline T: type, out_buf: []u8, x: T) -> usize { - const uint = @intType(false, T.bit_count); - if (x < 0) { - out_buf[0] = '-'; - return 1 + bufPrintUnsigned(uint, out_buf[1...], uint(-(x + 1)) + 1); - } else { - return bufPrintUnsigned(uint, out_buf, uint(x)); - } -} - -fn bufPrintUnsigned(inline T: type, out_buf: []u8, x: T) -> usize { - var buf: [max_u64_base10_digits]u8 = undefined; - var a = x; - var index: usize = buf.len; - - while (true) { - const digit = a % 10; - index -= 1; - buf[index] = '0' + u8(digit); - a /= 10; - if (a == 0) - break; - } - - const len = buf.len - index; - - @memcpy(&out_buf[0], &buf[index], len); - - return len; -} - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - -// TODO import from std.str -pub fn memeql(a: []const u8, b: []const u8) -> bool { - sliceEql(u8, a, b) -} - -// TODO import from std.str -pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { - if (a.len != b.len) return false; - for (a) |item, index| { - if (b[index] != item) return false; - } - return true; + assert(str.eql(buf[0...2], "42")); } diff --git a/test/cases/error.zig b/test/cases/error.zig index 3d978132f5..14c4011445 100644 --- a/test/cases/error.zig +++ b/test/cases/error.zig @@ -1,3 +1,6 @@ +const assert = @import("std").debug.assert; +const str = @import("std").str; + pub fn foo() -> %i32 { const x = %return bar(); return x + 1 @@ -25,8 +28,8 @@ fn gimmeItBroke() -> []const u8 { fn errorName() { @setFnTest(this); - assert(memeql(@errorName(error.AnError), "AnError")); - assert(memeql(@errorName(error.ALongerErrorName), "ALongerErrorName")); + assert(str.eql(@errorName(error.AnError), "AnError")); + assert(str.eql(@errorName(error.ALongerErrorName), "ALongerErrorName")); } error AnError; error ALongerErrorName; @@ -97,26 +100,3 @@ fn doErrReturnInAssignment() -> %void { fn makeANonErr() -> %i32 { return 1; } - - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - -// TODO import from std.str -pub fn memeql(a: []const u8, b: []const u8) -> bool { - sliceEql(u8, a, b) -} - -// TODO import from std.str -pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { - if (a.len != b.len) return false; - for (a) |item, index| { - if (b[index] != item) return false; - } - return true; -} - diff --git a/test/cases/eval.zig b/test/cases/eval.zig index 01add0dab5..a414fe91ca 100644 --- a/test/cases/eval.zig +++ b/test/cases/eval.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn compileTimeRecursion() { @setFnTest(this); @@ -159,11 +161,3 @@ fn staticallyInitializedArrayLiteral() { assert(y[3] == 4); } const st_init_arr_lit_x = []u8{1,2,3,4}; - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - diff --git a/test/cases/fn.zig b/test/cases/fn.zig index 7e693221f2..b8d801824e 100644 --- a/test/cases/fn.zig +++ b/test/cases/fn.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn params() { @setFnTest(this); @@ -98,11 +100,3 @@ fn fn1() -> u32 {5} fn fn2() -> u32 {6} fn fn3() -> u32 {7} fn fn4() -> u32 {8} - - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/for.zig b/test/cases/for.zig index c72ce68d87..27ace9e063 100644 --- a/test/cases/for.zig +++ b/test/cases/for.zig @@ -1,3 +1,7 @@ +const std = @import("std"); +const assert = std.debug.assert; +const str = std.str; + fn continueInForLoop() { @setFnTest(this); @@ -20,31 +24,10 @@ fn forLoopWithPointerElemVar() { var target: [source.len]u8 = undefined; @memcpy(&target[0], &source[0], source.len); mangleString(target); - assert(memeql(target, "bcdefgh")); + assert(str.eql(target, "bcdefgh")); } fn mangleString(s: []u8) { for (s) |*c| { *c += 1; } } - - -// TODO import from std.str -pub fn memeql(a: []const u8, b: []const u8) -> bool { - sliceEql(u8, a, b) -} - -// TODO import from std.str -pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { - if (a.len != b.len) return false; - for (a) |item, index| { - if (b[index] != item) return false; - } - return true; -} - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/generics.zig b/test/cases/generics.zig index 92dc1fcbfc..0d526266d6 100644 --- a/test/cases/generics.zig +++ b/test/cases/generics.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn simpleGenericFn() { @setFnTest(this); @@ -138,10 +140,3 @@ fn getByte(ptr: ?&u8) -> u8 {*??ptr} fn getFirstByte(inline T: type, mem: []T) -> u8 { getByte((&u8)(&mem[0])) } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - diff --git a/test/cases/goto.zig b/test/cases/goto.zig index 7931966e74..155aa5cdbe 100644 --- a/test/cases/goto.zig +++ b/test/cases/goto.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn gotoAndLabels() { @setFnTest(this); @@ -37,9 +39,3 @@ entry: defer it_worked = true; if (b) goto exit; } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/if.zig b/test/cases/if.zig index 9786a6c125..a3681a4634 100644 --- a/test/cases/if.zig +++ b/test/cases/if.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn ifStatements() { @setFnTest(this); @@ -38,9 +40,3 @@ fn elseIfExpressionF(c: u8) -> u8 { u8(2) } } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/import.zig b/test/cases/import.zig index fbcb5c860c..6787afecf9 100644 --- a/test/cases/import.zig +++ b/test/cases/import.zig @@ -1,3 +1,4 @@ +const assert = @import("std").debug.assert; const a_namespace = @import("cases/import/a_namespace.zig"); fn callFnViaNamespaceLookup() { @@ -5,9 +6,3 @@ fn callFnViaNamespaceLookup() { assert(a_namespace.foo() == 1234); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/ir_block_deps.zig b/test/cases/ir_block_deps.zig index a63f24cdf7..9ba03b8031 100644 --- a/test/cases/ir_block_deps.zig +++ b/test/cases/ir_block_deps.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn foo(id: u64) -> %i32 { return switch (id) { 1 => getErrInt(), @@ -19,9 +21,3 @@ fn irBlockDeps() { assert(%%foo(1) == 0); assert(%%foo(2) == 0); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/math.zig b/test/cases/math.zig index 187c971a00..a85d752660 100644 --- a/test/cases/math.zig +++ b/test/cases/math.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn exactDivision() { @setFnTest(this); @@ -175,10 +177,3 @@ fn binaryNot() { fn testBinaryNot(x: u16) { assert(~x == 0b0101010101010101); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - diff --git a/test/cases/misc.zig b/test/cases/misc.zig index ba0aa7fdfa..4f25cb90d5 100644 --- a/test/cases/misc.zig +++ b/test/cases/misc.zig @@ -1,3 +1,7 @@ +const assert = @import("std").debug.assert; +const str = @import("std").str; +const cstr = @import("std").cstr; + // normal comment /// this is a documentation comment /// doc comment line 2 @@ -137,7 +141,7 @@ fn first4KeysOfHomeRow() -> []const u8 { fn ReturnStringFromFunction() { @setFnTest(this); - assert(memeql(first4KeysOfHomeRow(), "aoeu")); + assert(str.eql(first4KeysOfHomeRow(), "aoeu")); } const g1 : i32 = 1233 + 1; @@ -203,31 +207,31 @@ fn emptyFn() {} fn hexEscape() { @setFnTest(this); - assert(memeql("\x68\x65\x6c\x6c\x6f", "hello")); + assert(str.eql("\x68\x65\x6c\x6c\x6f", "hello")); } fn stringConcatenation() { @setFnTest(this); - assert(memeql("OK" ++ " IT " ++ "WORKED", "OK IT WORKED")); + assert(str.eql("OK" ++ " IT " ++ "WORKED", "OK IT WORKED")); } fn arrayMultOperator() { @setFnTest(this); - assert(memeql("ab" ** 5, "ababababab")); + assert(str.eql("ab" ** 5, "ababababab")); } fn stringEscapes() { @setFnTest(this); - assert(memeql("\"", "\x22")); - assert(memeql("\'", "\x27")); - assert(memeql("\n", "\x0a")); - assert(memeql("\r", "\x0d")); - assert(memeql("\t", "\x09")); - assert(memeql("\\", "\x5c")); - assert(memeql("\u1234\u0069", "\xe1\x88\xb4\x69")); + assert(str.eql("\"", "\x22")); + assert(str.eql("\'", "\x27")); + assert(str.eql("\n", "\x0a")); + assert(str.eql("\r", "\x0d")); + assert(str.eql("\t", "\x09")); + assert(str.eql("\\", "\x5c")); + assert(str.eql("\u1234\u0069", "\xe1\x88\xb4\x69")); } fn multilineString() { @@ -239,7 +243,7 @@ fn multilineString() { \\three ; const s2 = "one\ntwo)\nthree"; - assert(memeql(s1, s2)); + assert(str.eql(s1, s2)); } fn multilineCString() { @@ -251,7 +255,7 @@ fn multilineCString() { c\\three ; const s2 = c"one\ntwo)\nthree"; - assert(cstrcmp(s1, s2) == 0); + assert(cstr.cmp(s1, s2) == 0); } @@ -337,8 +341,8 @@ fn pointerDereferencing() { fn callResultOfIfElseExpression() { @setFnTest(this); - assert(memeql(f2(true), "a")); - assert(memeql(f2(false), "b")); + assert(str.eql(f2(true), "a")); + assert(str.eql(f2(false), "b")); } fn f2(x: bool) -> []u8 { return (if (x) fA else fB)(); @@ -442,7 +446,7 @@ fn cStringConcatenation() { const a = c"OK" ++ c" IT " ++ c"WORKED"; const b = c"OK IT WORKED"; - const len = cstrlen(b); + const len = cstr.len(b); const len_with_null = len + 1; {var i: u32 = 0; while (i < len_with_null; i += 1) { assert(a[i] == b[i]); @@ -486,43 +490,3 @@ const test_pointer_to_void_return_type_x = void{}; fn testPointerToVoidReturnType2() -> &const void { return &test_pointer_to_void_return_type_x; } - -// TODO import from std.cstr -pub fn cstrlen(ptr: &const u8) -> usize { - var count: usize = 0; - while (ptr[count] != 0; count += 1) {} - return count; -} - -// TODO import from std.str -pub fn memeql(a: []const u8, b: []const u8) -> bool { - sliceEql(u8, a, b) -} - -// TODO import from std.str -pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool { - if (a.len != b.len) return false; - for (a) |item, index| { - if (b[index] != item) return false; - } - return true; -} - -// TODO import from std.cstr -pub fn cstrcmp(a: &const u8, b: &const u8) -> i8 { - var index: usize = 0; - while (a[index] == b[index] && a[index] != 0; index += 1) {} - return if (a[index] > b[index]) { - 1 - } else if (a[index] < b[index]) { - -1 - } else { - i8(0) - }; -} - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/namespace_depends_on_compile_var/index.zig b/test/cases/namespace_depends_on_compile_var/index.zig index 682806be3b..9bc8f781e7 100644 --- a/test/cases/namespace_depends_on_compile_var/index.zig +++ b/test/cases/namespace_depends_on_compile_var/index.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn namespaceDependsOnCompileVar() { @setFnTest(this); @@ -11,9 +13,3 @@ const some_namespace = switch(@compileVar("os")) { Os.linux => @import("cases/namespace_depends_on_compile_var/a.zig"), else => @import("cases/namespace_depends_on_compile_var/b.zig"), }; - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/null.zig b/test/cases/null.zig index 223770eea2..96f754c476 100644 --- a/test/cases/null.zig +++ b/test/cases/null.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn nullableType() { @setFnTest(this); @@ -97,10 +99,3 @@ fn foo(x: ?i32) -> ?bool { const value = ?return x; return value > 1234; } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} - diff --git a/test/cases/pub_enum/index.zig b/test/cases/pub_enum/index.zig index 39892d1e87..889ce30bba 100644 --- a/test/cases/pub_enum/index.zig +++ b/test/cases/pub_enum/index.zig @@ -1,4 +1,5 @@ const other = @import("cases/pub_enum/other.zig"); +const assert = @import("std").debug.assert; fn pubEnum() { @setFnTest(this); @@ -14,10 +15,3 @@ fn castWithImportedSymbol() { assert(other.size_t(42) == 42); } - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/sizeof_and_typeof.zig b/test/cases/sizeof_and_typeof.zig index 0d65bfc8ca..734406c7c2 100644 --- a/test/cases/sizeof_and_typeof.zig +++ b/test/cases/sizeof_and_typeof.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn sizeofAndTypeOf() { @setFnTest(this); @@ -6,9 +8,3 @@ fn sizeofAndTypeOf() { } const x: u16 = 13; const z: @typeOf(x) = 19; - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/struct.zig b/test/cases/struct.zig index 6198127ebe..efe476d808 100644 --- a/test/cases/struct.zig +++ b/test/cases/struct.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + const StructWithNoFields = struct { fn add(a: i32, b: i32) -> i32 { a + b } }; @@ -206,10 +208,3 @@ fn passSliceOfEmptyStructToFn() { fn testPassSliceOfEmptyStructToFn(slice: []EmptyStruct2) -> usize { slice.len } - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/struct_contains_slice_of_itself.zig b/test/cases/struct_contains_slice_of_itself.zig index 8c5739413a..281b4542e1 100644 --- a/test/cases/struct_contains_slice_of_itself.zig +++ b/test/cases/struct_contains_slice_of_itself.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + const Node = struct { payload: i32, children: []Node, @@ -40,9 +42,3 @@ fn structContainsSliceOfItself() { assert(root.children[2].children[0].payload == 31); assert(root.children[2].children[1].payload == 32); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/switch.zig b/test/cases/switch.zig index ff65d7540f..801ce52b13 100644 --- a/test/cases/switch.zig +++ b/test/cases/switch.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn switchWithNumbers() { @setFnTest(this); @@ -127,10 +129,3 @@ fn switchWithMultipleExpressions() { fn returnsFive() -> i32 { 5 } - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/switch_prong_err_enum.zig b/test/cases/switch_prong_err_enum.zig index ac721a6707..7c7296166f 100644 --- a/test/cases/switch_prong_err_enum.zig +++ b/test/cases/switch_prong_err_enum.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + var read_count: u64 = 0; fn readOnce() -> %u64 { @@ -25,9 +27,3 @@ fn switchProngReturnsErrorEnum() { %%doThing(17); assert(read_count == 1); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/switch_prong_implicit_cast.zig b/test/cases/switch_prong_implicit_cast.zig index b4e243d88d..7ec047ca2f 100644 --- a/test/cases/switch_prong_implicit_cast.zig +++ b/test/cases/switch_prong_implicit_cast.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + const FormValue = enum { One, Two: bool, @@ -22,9 +24,3 @@ fn switchProngImplicitCast() { }; assert(result); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/this.zig b/test/cases/this.zig index 48ad31c93f..f3c231de0a 100644 --- a/test/cases/this.zig +++ b/test/cases/this.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + const module = this; fn Point(inline T: type) -> type { @@ -49,9 +51,3 @@ fn thisReferToFn() { assert(factorial(5) == 120); } - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -} diff --git a/test/cases/while.zig b/test/cases/while.zig index 4b4c3ffc26..e5e10e5568 100644 --- a/test/cases/while.zig +++ b/test/cases/while.zig @@ -1,3 +1,5 @@ +const assert = @import("std").debug.assert; + fn whileLoop() { @setFnTest(this); @@ -72,11 +74,3 @@ fn whileWithContinueExpr() { }} assert(sum == 40); } - - - -// TODO const assert = @import("std").debug.assert; -fn assert(ok: bool) { - if (!ok) - @unreachable(); -}