IR: port more tests

This commit is contained in:
Andrew Kelley 2016-12-26 02:42:31 -05:00
parent 4664f793dc
commit 66777ccd7d
8 changed files with 46 additions and 38 deletions

View File

@ -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"),
};

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -1,6 +1,6 @@
pub enum APubEnum {
pub const APubEnum = enum {
One,
Two,
Three,
}
};
pub const size_t = u64;

View File

@ -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");