authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-05 03:57:48-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-05 03:57:48-05:00
log3b5e26b7f7e4b37cf9357d058f32c0ad08ed7338
tree3e62f38dbdee624eb7ac8780e8f2735b3945484d
parentee09eb7f5461aa9e2374a6adbfbf130bfc0ebf21

self hosted tests import std library


30 files changed, 100 insertions(+), 364 deletions(-)

test/cases/array.zig+8-27
......@@ -1,3 +1,6 @@
1const assert = @import("std").debug.assert;
2const str = @import("std").str;
3
14fn arrays() {
25 @setFnTest(this);
36
......@@ -60,32 +63,10 @@ fn nestedArrays() {
6063
6164 const array_of_strings = [][]u8 {"hello", "this", "is", "my", "thing"};
6265 for (array_of_strings) |s, i| {
63 if (i == 0) assert(memeql(s, "hello"));
64 if (i == 1) assert(memeql(s, "this"));
65 if (i == 2) assert(memeql(s, "is"));
66 if (i == 3) assert(memeql(s, "my"));
67 if (i == 4) assert(memeql(s, "thing"));
68 }
69}
70
71
72
73// TODO const assert = @import("std").debug.assert;
74fn assert(ok: bool) {
75 if (!ok)
76 @unreachable();
77}
78
79// TODO import from std.str
80pub fn memeql(a: []const u8, b: []const u8) -> bool {
81 sliceEql(u8, a, b)
82}
83
84// TODO import from std.str
85pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool {
86 if (a.len != b.len) return false;
87 for (a) |item, index| {
88 if (b[index] != item) return false;
66 if (i == 0) assert(str.eql(s, "hello"));
67 if (i == 1) assert(str.eql(s, "this"));
68 if (i == 2) assert(str.eql(s, "is"));
69 if (i == 3) assert(str.eql(s, "my"));
70 if (i == 4) assert(str.eql(s, "thing"));
8971 }
90 return true;
9172}
test/cases/atomics.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn cmpxchg() {
24 @setFnTest(this);
35
......@@ -13,9 +15,3 @@ fn fence() {
1315 @fence(AtomicOrder.SeqCst);
1416 x = 5678;
1517}
16
17// TODO const assert = @import("std").debug.assert;
18fn assert(ok: bool) {
19 if (!ok)
20 @unreachable();
21}
test/cases/bool.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn boolLiterals() {
24 @setFnTest(this);
35
......@@ -28,9 +30,3 @@ fn boolCmp() {
2830fn testBoolCmp(a: bool, b: bool) -> bool {
2931 a == b
3032}
31
32// TODO const assert = @import("std").debug.assert;
33fn assert(ok: bool) {
34 if (!ok)
35 @unreachable();
36}
test/cases/cast.zig+8-12
......@@ -1,14 +1,10 @@
1//fn intToPtrCast() {
2// @setFnTest(this);
3//
4// const x = isize(13);
5// const y = (&u8)(x);
6// const z = usize(y);
7// assert(z == 13);
8//}
1const assert = @import("std").debug.assert;
92
10// TODO const assert = @import("std").debug.assert;
11fn assert(ok: bool) {
12 if (!ok)
13 @unreachable();
3fn intToPtrCast() {
4 @setFnTest(this);
5
6 const x = isize(13);
7 const y = (&u8)(x);
8 const z = usize(y);
9 assert(z == 13);
1410}
test/cases/const_slice_child.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13var argv: &&const u8 = undefined;
24
35fn constSliceChild() {
......@@ -41,9 +43,3 @@ fn streql(a: []const u8, b: []const u8) -> bool {
4143 }
4244 return true;
4345}
44
45// TODO const assert = @import("std").debug.assert;
46fn assert(ok: bool) {
47 if (!ok)
48 @unreachable();
49}
test/cases/defer.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13var result: [3]u8 = undefined;
24var index: usize = undefined;
35
......@@ -49,9 +51,3 @@ fn mixingNormalAndMaybeDefers() {
4951 assert(result[1] == 'b');
5052 assert(result[2] == 'a');
5153}
52
53// TODO const assert = @import("std").debug.assert;
54fn assert(ok: bool) {
55 if (!ok)
56 @unreachable();
57}
test/cases/enum.zig+2-10
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn enumType() {
24 @setFnTest(this);
35
......@@ -111,13 +113,3 @@ const IntToEnumNumber = enum {
111113 Three,
112114 Four,
113115};
114
115
116// TODO import from std
117fn assert(ok: bool) {
118 if (!ok)
119 @unreachable();
120}
121
122
123
test/cases/enum_with_members.zig+8-62
......@@ -1,11 +1,15 @@
1const assert = @import("std").debug.assert;
2const str = @import("std").str;
3const io = @import("std").io;
4
15const ET = enum {
26 SINT: i32,
37 UINT: u32,
48
59 pub fn print(a: &ET, buf: []u8) -> %usize {
610 return switch (*a) {
7 ET.SINT => |x| { bufPrintInt(i32, buf, x) },
8 ET.UINT => |x| { bufPrintInt(u32, buf, x) },
11 ET.SINT => |x| { io.bufPrintInt(i32, buf, x) },
12 ET.UINT => |x| { io.bufPrintInt(u32, buf, x) },
913 }
1014 }
1115};
......@@ -18,66 +22,8 @@ fn enumWithMembers() {
1822 var buf: [20]u8 = undefined;
1923
2024 assert(%%a.print(buf) == 3);
21 assert(memeql(buf[0...3], "-42"));
25 assert(str.eql(buf[0...3], "-42"));
2226
2327 assert(%%b.print(buf) == 2);
24 assert(memeql(buf[0...2], "42"));
25}
26
27// TODO all the below should be imported from std
28
29const max_u64_base10_digits = 20;
30pub fn bufPrintInt(inline T: type, out_buf: []u8, x: T) -> usize {
31 if (T.is_signed) bufPrintSigned(T, out_buf, x) else bufPrintUnsigned(T, out_buf, x)
32}
33
34fn bufPrintSigned(inline T: type, out_buf: []u8, x: T) -> usize {
35 const uint = @intType(false, T.bit_count);
36 if (x < 0) {
37 out_buf[0] = '-';
38 return 1 + bufPrintUnsigned(uint, out_buf[1...], uint(-(x + 1)) + 1);
39 } else {
40 return bufPrintUnsigned(uint, out_buf, uint(x));
41 }
42}
43
44fn bufPrintUnsigned(inline T: type, out_buf: []u8, x: T) -> usize {
45 var buf: [max_u64_base10_digits]u8 = undefined;
46 var a = x;
47 var index: usize = buf.len;
48
49 while (true) {
50 const digit = a % 10;
51 index -= 1;
52 buf[index] = '0' + u8(digit);
53 a /= 10;
54 if (a == 0)
55 break;
56 }
57
58 const len = buf.len - index;
59
60 @memcpy(&out_buf[0], &buf[index], len);
61
62 return len;
63}
64
65// TODO const assert = @import("std").debug.assert;
66fn assert(ok: bool) {
67 if (!ok)
68 @unreachable();
69}
70
71// TODO import from std.str
72pub fn memeql(a: []const u8, b: []const u8) -> bool {
73 sliceEql(u8, a, b)
74}
75
76// TODO import from std.str
77pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool {
78 if (a.len != b.len) return false;
79 for (a) |item, index| {
80 if (b[index] != item) return false;
81 }
82 return true;
28 assert(str.eql(buf[0...2], "42"));
8329}
test/cases/error.zig+5-25
......@@ -1,3 +1,6 @@
1const assert = @import("std").debug.assert;
2const str = @import("std").str;
3
14pub fn foo() -> %i32 {
25 const x = %return bar();
36 return x + 1
......@@ -25,8 +28,8 @@ fn gimmeItBroke() -> []const u8 {
2528
2629fn errorName() {
2730 @setFnTest(this);
28 assert(memeql(@errorName(error.AnError), "AnError"));
29 assert(memeql(@errorName(error.ALongerErrorName), "ALongerErrorName"));
31 assert(str.eql(@errorName(error.AnError), "AnError"));
32 assert(str.eql(@errorName(error.ALongerErrorName), "ALongerErrorName"));
3033}
3134error AnError;
3235error ALongerErrorName;
......@@ -97,26 +100,3 @@ fn doErrReturnInAssignment() -> %void {
97100fn makeANonErr() -> %i32 {
98101 return 1;
99102}
100
101
102
103// TODO const assert = @import("std").debug.assert;
104fn assert(ok: bool) {
105 if (!ok)
106 @unreachable();
107}
108
109// TODO import from std.str
110pub fn memeql(a: []const u8, b: []const u8) -> bool {
111 sliceEql(u8, a, b)
112}
113
114// TODO import from std.str
115pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool {
116 if (a.len != b.len) return false;
117 for (a) |item, index| {
118 if (b[index] != item) return false;
119 }
120 return true;
121}
122
test/cases/eval.zig+2-8
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn compileTimeRecursion() {
24 @setFnTest(this);
35
......@@ -159,11 +161,3 @@ fn staticallyInitializedArrayLiteral() {
159161 assert(y[3] == 4);
160162}
161163const st_init_arr_lit_x = []u8{1,2,3,4};
162
163
164// TODO const assert = @import("std").debug.assert;
165fn assert(ok: bool) {
166 if (!ok)
167 @unreachable();
168}
169
test/cases/fn.zig+2-8
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn params() {
24 @setFnTest(this);
35
......@@ -98,11 +100,3 @@ fn fn1() -> u32 {5}
98100fn fn2() -> u32 {6}
99101fn fn3() -> u32 {7}
100102fn fn4() -> u32 {8}
101
102
103
104// TODO const assert = @import("std").debug.assert;
105fn assert(ok: bool) {
106 if (!ok)
107 @unreachable();
108}
test/cases/for.zig+5-22
......@@ -1,3 +1,7 @@
1const std = @import("std");
2const assert = std.debug.assert;
3const str = std.str;
4
15fn continueInForLoop() {
26 @setFnTest(this);
37
......@@ -20,31 +24,10 @@ fn forLoopWithPointerElemVar() {
2024 var target: [source.len]u8 = undefined;
2125 @memcpy(&target[0], &source[0], source.len);
2226 mangleString(target);
23 assert(memeql(target, "bcdefgh"));
27 assert(str.eql(target, "bcdefgh"));
2428}
2529fn mangleString(s: []u8) {
2630 for (s) |*c| {
2731 *c += 1;
2832 }
2933}
30
31
32// TODO import from std.str
33pub fn memeql(a: []const u8, b: []const u8) -> bool {
34 sliceEql(u8, a, b)
35}
36
37// TODO import from std.str
38pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool {
39 if (a.len != b.len) return false;
40 for (a) |item, index| {
41 if (b[index] != item) return false;
42 }
43 return true;
44}
45
46// TODO const assert = @import("std").debug.assert;
47fn assert(ok: bool) {
48 if (!ok)
49 @unreachable();
50}
test/cases/generics.zig+2-7
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn simpleGenericFn() {
24 @setFnTest(this);
35
......@@ -138,10 +140,3 @@ fn getByte(ptr: ?&u8) -> u8 {*??ptr}
138140fn getFirstByte(inline T: type, mem: []T) -> u8 {
139141 getByte((&u8)(&mem[0]))
140142}
141
142// TODO const assert = @import("std").debug.assert;
143fn assert(ok: bool) {
144 if (!ok)
145 @unreachable();
146}
147
test/cases/goto.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn gotoAndLabels() {
24 @setFnTest(this);
35
......@@ -37,9 +39,3 @@ entry:
3739 defer it_worked = true;
3840 if (b) goto exit;
3941}
40
41// TODO const assert = @import("std").debug.assert;
42fn assert(ok: bool) {
43 if (!ok)
44 @unreachable();
45}
test/cases/if.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn ifStatements() {
24 @setFnTest(this);
35
......@@ -38,9 +40,3 @@ fn elseIfExpressionF(c: u8) -> u8 {
3840 u8(2)
3941 }
4042}
41
42// TODO const assert = @import("std").debug.assert;
43fn assert(ok: bool) {
44 if (!ok)
45 @unreachable();
46}
test/cases/import.zig+1-6
......@@ -1,3 +1,4 @@
1const assert = @import("std").debug.assert;
12const a_namespace = @import("cases/import/a_namespace.zig");
23
34fn callFnViaNamespaceLookup() {
......@@ -5,9 +6,3 @@ fn callFnViaNamespaceLookup() {
56
67 assert(a_namespace.foo() == 1234);
78}
8
9// TODO const assert = @import("std").debug.assert;
10fn assert(ok: bool) {
11 if (!ok)
12 @unreachable();
13}
test/cases/ir_block_deps.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn foo(id: u64) -> %i32 {
24 return switch (id) {
35 1 => getErrInt(),
......@@ -19,9 +21,3 @@ fn irBlockDeps() {
1921 assert(%%foo(1) == 0);
2022 assert(%%foo(2) == 0);
2123}
22
23// TODO const assert = @import("std").debug.assert;
24fn assert(ok: bool) {
25 if (!ok)
26 @unreachable();
27}
test/cases/math.zig+2-7
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn exactDivision() {
24 @setFnTest(this);
35
......@@ -175,10 +177,3 @@ fn binaryNot() {
175177fn testBinaryNot(x: u16) {
176178 assert(~x == 0b0101010101010101);
177179}
178
179// TODO const assert = @import("std").debug.assert;
180fn assert(ok: bool) {
181 if (!ok)
182 @unreachable();
183}
184
test/cases/misc.zig+20-56
......@@ -1,3 +1,7 @@
1const assert = @import("std").debug.assert;
2const str = @import("std").str;
3const cstr = @import("std").cstr;
4
15// normal comment
26/// this is a documentation comment
37/// doc comment line 2
......@@ -137,7 +141,7 @@ fn first4KeysOfHomeRow() -> []const u8 {
137141fn ReturnStringFromFunction() {
138142 @setFnTest(this);
139143
140 assert(memeql(first4KeysOfHomeRow(), "aoeu"));
144 assert(str.eql(first4KeysOfHomeRow(), "aoeu"));
141145}
142146
143147const g1 : i32 = 1233 + 1;
......@@ -203,31 +207,31 @@ fn emptyFn() {}
203207fn hexEscape() {
204208 @setFnTest(this);
205209
206 assert(memeql("\x68\x65\x6c\x6c\x6f", "hello"));
210 assert(str.eql("\x68\x65\x6c\x6c\x6f", "hello"));
207211}
208212
209213fn stringConcatenation() {
210214 @setFnTest(this);
211215
212 assert(memeql("OK" ++ " IT " ++ "WORKED", "OK IT WORKED"));
216 assert(str.eql("OK" ++ " IT " ++ "WORKED", "OK IT WORKED"));
213217}
214218
215219fn arrayMultOperator() {
216220 @setFnTest(this);
217221
218 assert(memeql("ab" ** 5, "ababababab"));
222 assert(str.eql("ab" ** 5, "ababababab"));
219223}
220224
221225fn stringEscapes() {
222226 @setFnTest(this);
223227
224 assert(memeql("\"", "\x22"));
225 assert(memeql("\'", "\x27"));
226 assert(memeql("\n", "\x0a"));
227 assert(memeql("\r", "\x0d"));
228 assert(memeql("\t", "\x09"));
229 assert(memeql("\\", "\x5c"));
230 assert(memeql("\u1234\u0069", "\xe1\x88\xb4\x69"));
228 assert(str.eql("\"", "\x22"));
229 assert(str.eql("\'", "\x27"));
230 assert(str.eql("\n", "\x0a"));
231 assert(str.eql("\r", "\x0d"));
232 assert(str.eql("\t", "\x09"));
233 assert(str.eql("\\", "\x5c"));
234 assert(str.eql("\u1234\u0069", "\xe1\x88\xb4\x69"));
231235}
232236
233237fn multilineString() {
......@@ -239,7 +243,7 @@ fn multilineString() {
239243 \\three
240244 ;
241245 const s2 = "one\ntwo)\nthree";
242 assert(memeql(s1, s2));
246 assert(str.eql(s1, s2));
243247}
244248
245249fn multilineCString() {
......@@ -251,7 +255,7 @@ fn multilineCString() {
251255 c\\three
252256 ;
253257 const s2 = c"one\ntwo)\nthree";
254 assert(cstrcmp(s1, s2) == 0);
258 assert(cstr.cmp(s1, s2) == 0);
255259}
256260
257261
......@@ -337,8 +341,8 @@ fn pointerDereferencing() {
337341fn callResultOfIfElseExpression() {
338342 @setFnTest(this);
339343
340 assert(memeql(f2(true), "a"));
341 assert(memeql(f2(false), "b"));
344 assert(str.eql(f2(true), "a"));
345 assert(str.eql(f2(false), "b"));
342346}
343347fn f2(x: bool) -> []u8 {
344348 return (if (x) fA else fB)();
......@@ -442,7 +446,7 @@ fn cStringConcatenation() {
442446 const a = c"OK" ++ c" IT " ++ c"WORKED";
443447 const b = c"OK IT WORKED";
444448
445 const len = cstrlen(b);
449 const len = cstr.len(b);
446450 const len_with_null = len + 1;
447451 {var i: u32 = 0; while (i < len_with_null; i += 1) {
448452 assert(a[i] == b[i]);
......@@ -486,43 +490,3 @@ const test_pointer_to_void_return_type_x = void{};
486490fn testPointerToVoidReturnType2() -> &const void {
487491 return &test_pointer_to_void_return_type_x;
488492}
489
490// TODO import from std.cstr
491pub fn cstrlen(ptr: &const u8) -> usize {
492 var count: usize = 0;
493 while (ptr[count] != 0; count += 1) {}
494 return count;
495}
496
497// TODO import from std.str
498pub fn memeql(a: []const u8, b: []const u8) -> bool {
499 sliceEql(u8, a, b)
500}
501
502// TODO import from std.str
503pub fn sliceEql(inline T: type, a: []const T, b: []const T) -> bool {
504 if (a.len != b.len) return false;
505 for (a) |item, index| {
506 if (b[index] != item) return false;
507 }
508 return true;
509}
510
511// TODO import from std.cstr
512pub fn cstrcmp(a: &const u8, b: &const u8) -> i8 {
513 var index: usize = 0;
514 while (a[index] == b[index] && a[index] != 0; index += 1) {}
515 return if (a[index] > b[index]) {
516 1
517 } else if (a[index] < b[index]) {
518 -1
519 } else {
520 i8(0)
521 };
522}
523
524// TODO const assert = @import("std").debug.assert;
525fn assert(ok: bool) {
526 if (!ok)
527 @unreachable();
528}
test/cases/namespace_depends_on_compile_var/index.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn namespaceDependsOnCompileVar() {
24 @setFnTest(this);
35
......@@ -11,9 +13,3 @@ const some_namespace = switch(@compileVar("os")) {
1113 Os.linux => @import("cases/namespace_depends_on_compile_var/a.zig"),
1214 else => @import("cases/namespace_depends_on_compile_var/b.zig"),
1315};
14
15// TODO const assert = @import("std").debug.assert;
16fn assert(ok: bool) {
17 if (!ok)
18 @unreachable();
19}
test/cases/null.zig+2-7
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn nullableType() {
24 @setFnTest(this);
35
......@@ -97,10 +99,3 @@ fn foo(x: ?i32) -> ?bool {
9799 const value = ?return x;
98100 return value > 1234;
99101}
100
101// TODO const assert = @import("std").debug.assert;
102fn assert(ok: bool) {
103 if (!ok)
104 @unreachable();
105}
106
test/cases/pub_enum/index.zig+1-7
......@@ -1,4 +1,5 @@
11const other = @import("cases/pub_enum/other.zig");
2const assert = @import("std").debug.assert;
23
34fn pubEnum() {
45 @setFnTest(this);
......@@ -14,10 +15,3 @@ fn castWithImportedSymbol() {
1415
1516 assert(other.size_t(42) == 42);
1617}
17
18
19// TODO const assert = @import("std").debug.assert;
20fn assert(ok: bool) {
21 if (!ok)
22 @unreachable();
23}
test/cases/sizeof_and_typeof.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn sizeofAndTypeOf() {
24 @setFnTest(this);
35
......@@ -6,9 +8,3 @@ fn sizeofAndTypeOf() {
68}
79const x: u16 = 13;
810const z: @typeOf(x) = 19;
9
10// TODO const assert = @import("std").debug.assert;
11fn assert(ok: bool) {
12 if (!ok)
13 @unreachable();
14}
test/cases/struct.zig+2-7
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13const StructWithNoFields = struct {
24 fn add(a: i32, b: i32) -> i32 { a + b }
35};
......@@ -206,10 +208,3 @@ fn passSliceOfEmptyStructToFn() {
206208fn testPassSliceOfEmptyStructToFn(slice: []EmptyStruct2) -> usize {
207209 slice.len
208210}
209
210
211// TODO const assert = @import("std").debug.assert;
212fn assert(ok: bool) {
213 if (!ok)
214 @unreachable();
215}
test/cases/struct_contains_slice_of_itself.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13const Node = struct {
24 payload: i32,
35 children: []Node,
......@@ -40,9 +42,3 @@ fn structContainsSliceOfItself() {
4042 assert(root.children[2].children[0].payload == 31);
4143 assert(root.children[2].children[1].payload == 32);
4244}
43
44// TODO const assert = @import("std").debug.assert;
45fn assert(ok: bool) {
46 if (!ok)
47 @unreachable();
48}
test/cases/switch.zig+2-7
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn switchWithNumbers() {
24 @setFnTest(this);
35
......@@ -127,10 +129,3 @@ fn switchWithMultipleExpressions() {
127129fn returnsFive() -> i32 {
128130 5
129131}
130
131
132// TODO const assert = @import("std").debug.assert;
133fn assert(ok: bool) {
134 if (!ok)
135 @unreachable();
136}
test/cases/switch_prong_err_enum.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13var read_count: u64 = 0;
24
35fn readOnce() -> %u64 {
......@@ -25,9 +27,3 @@ fn switchProngReturnsErrorEnum() {
2527 %%doThing(17);
2628 assert(read_count == 1);
2729}
28
29// TODO const assert = @import("std").debug.assert;
30fn assert(ok: bool) {
31 if (!ok)
32 @unreachable();
33}
test/cases/switch_prong_implicit_cast.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13const FormValue = enum {
24 One,
35 Two: bool,
......@@ -22,9 +24,3 @@ fn switchProngImplicitCast() {
2224 };
2325 assert(result);
2426}
25
26// TODO const assert = @import("std").debug.assert;
27fn assert(ok: bool) {
28 if (!ok)
29 @unreachable();
30}
test/cases/this.zig+2-6
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13const module = this;
24
35fn Point(inline T: type) -> type {
......@@ -49,9 +51,3 @@ fn thisReferToFn() {
4951
5052 assert(factorial(5) == 120);
5153}
52
53// TODO const assert = @import("std").debug.assert;
54fn assert(ok: bool) {
55 if (!ok)
56 @unreachable();
57}
test/cases/while.zig+2-8
......@@ -1,3 +1,5 @@
1const assert = @import("std").debug.assert;
2
13fn whileLoop() {
24 @setFnTest(this);
35
......@@ -72,11 +74,3 @@ fn whileWithContinueExpr() {
7274 }}
7375 assert(sum == 40);
7476}
75
76
77
78// TODO const assert = @import("std").debug.assert;
79fn assert(ok: bool) {
80 if (!ok)
81 @unreachable();
82}