zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 66777ccd7d3744670fe58d451f982f29d65612ac (tree)
parent 4664f793dc3fed2254863a5b6efc302c095890cb
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Mon, 26 Dec 2016 02:42:31 -0500

IR: port more tests

Diffstat:
Dtest/cases/namespace_depends_on_compile_var/index.zig | 17-----------------
Dtest/cases/pub_enum/index.zig | 19-------------------
Dtest/cases/pub_enum/other.zig | 6------
Rtest/cases/namespace_depends_on_compile_var/a.zig -> test/cases3/namespace_depends_on_compile_var/a.zig | 0
Rtest/cases/namespace_depends_on_compile_var/b.zig -> test/cases3/namespace_depends_on_compile_var/b.zig | 0
Atest/cases3/namespace_depends_on_compile_var/index.zig | 19+++++++++++++++++++
Atest/cases3/pub_enum/index.zig | 23+++++++++++++++++++++++
Atest/cases3/pub_enum/other.zig | 6++++++
Mtest/self_hosted3.zig | 2++
9 files changed, 50 insertions(+), 42 deletions(-)

diff --git a/test/cases/namespace_depends_on_compile_var/index.zig b/test/cases/namespace_depends_on_compile_var/index.zig @@ -1,17 +0,0 @@ -const assert = @import("std").debug.assert; - -fn namespaceDependsOnCompileVar() { - @setFnTest(this, true); - - if (some_namespace.a_bool) { - assert(some_namespace.a_bool); - } else { - assert(!some_namespace.a_bool); - } -} -const some_namespace = switch(@compileVar("os")) { - linux => @import("a.zig"), - else => @import("b.zig"), -}; - - diff --git a/test/cases/pub_enum/index.zig b/test/cases/pub_enum/index.zig @@ -1,19 +0,0 @@ -const assert = @import("std").debug.assert; -const other = @import("other.zig"); - -fn pubEnum() { - @setFnTest(this, true); - - pubEnumTest(other.APubEnum.Two); -} -fn pubEnumTest(foo: other.APubEnum) { - assert(foo == other.APubEnum.Two); -} - -fn castWithImportedSymbol() { - @setFnTest(this, true); - - assert(other.size_t(42) == 42); -} - - diff --git a/test/cases/pub_enum/other.zig b/test/cases/pub_enum/other.zig @@ -1,6 +0,0 @@ -pub enum APubEnum { - One, - Two, - Three, -} -pub const size_t = u64; diff --git a/test/cases/namespace_depends_on_compile_var/a.zig b/test/cases3/namespace_depends_on_compile_var/a.zig diff --git a/test/cases/namespace_depends_on_compile_var/b.zig b/test/cases3/namespace_depends_on_compile_var/b.zig diff --git a/test/cases3/namespace_depends_on_compile_var/index.zig b/test/cases3/namespace_depends_on_compile_var/index.zig @@ -0,0 +1,19 @@ +fn namespaceDependsOnCompileVar() { + @setFnTest(this); + + if (some_namespace.a_bool) { + assert(some_namespace.a_bool); + } else { + assert(!some_namespace.a_bool); + } +} +const some_namespace = switch(@compileVar("os")) { + Os.linux => @import("cases3/namespace_depends_on_compile_var/a.zig"), + else => @import("cases3/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/cases3/pub_enum/index.zig b/test/cases3/pub_enum/index.zig @@ -0,0 +1,23 @@ +const other = @import("cases3/pub_enum/other.zig"); + +fn pubEnum() { + @setFnTest(this); + + pubEnumTest(other.APubEnum.Two); +} +fn pubEnumTest(foo: other.APubEnum) { + assert(foo == other.APubEnum.Two); +} + +fn castWithImportedSymbol() { + @setFnTest(this); + + assert(other.size_t(42) == 42); +} + + +// TODO const assert = @import("std").debug.assert; +fn assert(ok: bool) { + if (!ok) + @unreachable(); +} diff --git a/test/cases3/pub_enum/other.zig b/test/cases3/pub_enum/other.zig @@ -0,0 +1,6 @@ +pub const APubEnum = enum { + One, + Two, + Three, +}; +pub const size_t = u64; diff --git a/test/self_hosted3.zig b/test/self_hosted3.zig @@ -17,7 +17,9 @@ const test_if = @import("cases3/if.zig"); const test_import = @import("cases3/import.zig"); const test_math = @import("cases3/math.zig"); const test_misc = @import("cases3/misc.zig"); +const test_namespace_depends_on_compile_var = @import("cases3/namespace_depends_on_compile_var/index.zig"); const test_null = @import("cases3/null.zig"); +const test_pub_enum = @import("cases3/pub_enum/index.zig"); const test_sizeof_and_typeof = @import("cases3/sizeof_and_typeof.zig"); const test_struct = @import("cases3/struct.zig"); const test_struct_contains_slice_of_itself = @import("cases3/struct_contains_slice_of_itself.zig");