authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-26 02:42:31-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-12-26 02:47:52-05:00
log66777ccd7d3744670fe58d451f982f29d65612ac
tree1e0244ecf56bedf8c0ad29b9c8d95791f4491871
parent4664f793dc3fed2254863a5b6efc302c095890cb

IR: port more tests


11 files changed, 52 insertions(+), 44 deletions(-)

test/cases/namespace_depends_on_compile_var/a.zig deleted-1
......@@ -1 +0,0 @@
1pub const a_bool = true;
test/cases/namespace_depends_on_compile_var/b.zig deleted-1
......@@ -1 +0,0 @@
1pub const a_bool = false;
test/cases/namespace_depends_on_compile_var/index.zig deleted-17
......@@ -1,17 +0,0 @@
1const assert = @import("std").debug.assert;
2
3fn namespaceDependsOnCompileVar() {
4 @setFnTest(this, true);
5
6 if (some_namespace.a_bool) {
7 assert(some_namespace.a_bool);
8 } else {
9 assert(!some_namespace.a_bool);
10 }
11}
12const some_namespace = switch(@compileVar("os")) {
13 linux => @import("a.zig"),
14 else => @import("b.zig"),
15};
16
17
test/cases/pub_enum/index.zig deleted-19
......@@ -1,19 +0,0 @@
1const assert = @import("std").debug.assert;
2const other = @import("other.zig");
3
4fn pubEnum() {
5 @setFnTest(this, true);
6
7 pubEnumTest(other.APubEnum.Two);
8}
9fn pubEnumTest(foo: other.APubEnum) {
10 assert(foo == other.APubEnum.Two);
11}
12
13fn castWithImportedSymbol() {
14 @setFnTest(this, true);
15
16 assert(other.size_t(42) == 42);
17}
18
19
test/cases/pub_enum/other.zig deleted-6
......@@ -1,6 +0,0 @@
1pub enum APubEnum {
2 One,
3 Two,
4 Three,
5}
6pub const size_t = u64;
test/cases3/namespace_depends_on_compile_var/a.zig created+1
......@@ -0,0 +1 @@
1pub const a_bool = true;
test/cases3/namespace_depends_on_compile_var/b.zig created+1
......@@ -0,0 +1 @@
1pub const a_bool = false;
test/cases3/namespace_depends_on_compile_var/index.zig created+19
......@@ -0,0 +1,19 @@
1fn namespaceDependsOnCompileVar() {
2 @setFnTest(this);
3
4 if (some_namespace.a_bool) {
5 assert(some_namespace.a_bool);
6 } else {
7 assert(!some_namespace.a_bool);
8 }
9}
10const some_namespace = switch(@compileVar("os")) {
11 Os.linux => @import("cases3/namespace_depends_on_compile_var/a.zig"),
12 else => @import("cases3/namespace_depends_on_compile_var/b.zig"),
13};
14
15// TODO const assert = @import("std").debug.assert;
16fn assert(ok: bool) {
17 if (!ok)
18 @unreachable();
19}
test/cases3/pub_enum/index.zig created+23
......@@ -0,0 +1,23 @@
1const other = @import("cases3/pub_enum/other.zig");
2
3fn pubEnum() {
4 @setFnTest(this);
5
6 pubEnumTest(other.APubEnum.Two);
7}
8fn pubEnumTest(foo: other.APubEnum) {
9 assert(foo == other.APubEnum.Two);
10}
11
12fn castWithImportedSymbol() {
13 @setFnTest(this);
14
15 assert(other.size_t(42) == 42);
16}
17
18
19// TODO const assert = @import("std").debug.assert;
20fn assert(ok: bool) {
21 if (!ok)
22 @unreachable();
23}
test/cases3/pub_enum/other.zig created+6
......@@ -0,0 +1,6 @@
1pub const APubEnum = enum {
2 One,
3 Two,
4 Three,
5};
6pub const size_t = u64;
test/self_hosted3.zig+2
......@@ -17,7 +17,9 @@ const test_if = @import("cases3/if.zig");
1717const test_import = @import("cases3/import.zig");
1818const test_math = @import("cases3/math.zig");
1919const test_misc = @import("cases3/misc.zig");
20const test_namespace_depends_on_compile_var = @import("cases3/namespace_depends_on_compile_var/index.zig");
2021const test_null = @import("cases3/null.zig");
22const test_pub_enum = @import("cases3/pub_enum/index.zig");
2123const test_sizeof_and_typeof = @import("cases3/sizeof_and_typeof.zig");
2224const test_struct = @import("cases3/struct.zig");
2325const test_struct_contains_slice_of_itself = @import("cases3/struct_contains_slice_of_itself.zig");