mirror of
https://github.com/ziglang/zig.git
synced 2025-02-10 06:30:18 +00:00
Port more behavior tests
This commit is contained in:
parent
a94267b290
commit
25e4b16e25
@ -9,12 +9,16 @@ test {
|
||||
_ = @import("behavior/bitcast.zig");
|
||||
_ = @import("behavior/bitreverse.zig");
|
||||
_ = @import("behavior/byteswap.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/bool.zig");
|
||||
_ = @import("behavior/bugs/394.zig");
|
||||
_ = @import("behavior/bugs/624.zig");
|
||||
_ = @import("behavior/bugs/655.zig");
|
||||
_ = @import("behavior/bugs/656.zig");
|
||||
_ = @import("behavior/bugs/679.zig");
|
||||
_ = @import("behavior/bugs/704.zig");
|
||||
_ = @import("behavior/bugs/1025.zig");
|
||||
_ = @import("behavior/bugs/1076.zig");
|
||||
_ = @import("behavior/bugs/1111.zig");
|
||||
_ = @import("behavior/bugs/1277.zig");
|
||||
_ = @import("behavior/bugs/1310.zig");
|
||||
@ -27,149 +31,145 @@ test {
|
||||
_ = @import("behavior/bugs/2006.zig");
|
||||
_ = @import("behavior/bugs/2346.zig");
|
||||
_ = @import("behavior/bugs/2578.zig");
|
||||
_ = @import("behavior/bugs/2692.zig");
|
||||
_ = @import("behavior/bugs/2889.zig");
|
||||
_ = @import("behavior/bugs/3007.zig");
|
||||
_ = @import("behavior/bugs/3046.zig");
|
||||
_ = @import("behavior/bugs/3112.zig");
|
||||
_ = @import("behavior/bugs/3367.zig");
|
||||
_ = @import("behavior/bugs/3586.zig");
|
||||
_ = @import("behavior/bugs/4560.zig");
|
||||
_ = @import("behavior/bugs/4769_a.zig");
|
||||
_ = @import("behavior/bugs/4769_b.zig");
|
||||
_ = @import("behavior/bugs/4954.zig");
|
||||
_ = @import("behavior/bugs/6850.zig");
|
||||
_ = @import("behavior/bugs/7250.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
_ = @import("behavior/cast.zig");
|
||||
_ = @import("behavior/comptime_memory.zig");
|
||||
_ = @import("behavior/defer.zig");
|
||||
_ = @import("behavior/enum.zig");
|
||||
_ = @import("behavior/error.zig");
|
||||
_ = @import("behavior/fn.zig");
|
||||
_ = @import("behavior/fn_delegation.zig");
|
||||
_ = @import("behavior/fn_in_struct_in_comptime.zig");
|
||||
_ = @import("behavior/for.zig");
|
||||
_ = @import("behavior/generics.zig");
|
||||
_ = @import("behavior/hasdecl.zig");
|
||||
_ = @import("behavior/hasfield.zig");
|
||||
_ = @import("behavior/if.zig");
|
||||
_ = @import("behavior/import.zig");
|
||||
_ = @import("behavior/incomplete_struct_param_tld.zig");
|
||||
_ = @import("behavior/int_div.zig");
|
||||
_ = @import("behavior/inttoptr.zig");
|
||||
_ = @import("behavior/ir_block_deps.zig");
|
||||
_ = @import("behavior/member_func.zig");
|
||||
_ = @import("behavior/namespace_depends_on_compile_var.zig");
|
||||
_ = @import("behavior/null.zig");
|
||||
_ = @import("behavior/optional.zig");
|
||||
_ = @import("behavior/prefetch.zig");
|
||||
_ = @import("behavior/pointers.zig");
|
||||
_ = @import("behavior/pub_enum.zig");
|
||||
_ = @import("behavior/ptrcast.zig");
|
||||
_ = @import("behavior/reflection.zig");
|
||||
_ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
|
||||
_ = @import("behavior/slice.zig");
|
||||
_ = @import("behavior/slice_sentinel_comptime.zig");
|
||||
_ = @import("behavior/struct.zig");
|
||||
_ = @import("behavior/src.zig");
|
||||
_ = @import("behavior/this.zig");
|
||||
_ = @import("behavior/truncate.zig");
|
||||
_ = @import("behavior/try.zig");
|
||||
_ = @import("behavior/tuple.zig");
|
||||
_ = @import("behavior/type.zig");
|
||||
_ = @import("behavior/type_info.zig");
|
||||
_ = @import("behavior/undefined.zig");
|
||||
_ = @import("behavior/underscore.zig");
|
||||
_ = @import("behavior/union.zig");
|
||||
_ = @import("behavior/usingnamespace.zig");
|
||||
_ = @import("behavior/var_args.zig");
|
||||
_ = @import("behavior/int_div.zig");
|
||||
_ = @import("behavior/void.zig");
|
||||
_ = @import("behavior/while.zig");
|
||||
|
||||
// tests that don't pass for stage1
|
||||
if (builtin.zig_backend != .stage1) {
|
||||
_ = @import("behavior/decltest.zig");
|
||||
}
|
||||
|
||||
if (builtin.zig_backend != .stage2_arm and builtin.zig_backend != .stage2_x86_64 and builtin.zig_backend != .stage2_aarch64) {
|
||||
// Tests that pass (partly) for stage1, llvm backend, C backend, wasm backend.
|
||||
_ = @import("behavior/bugs/624.zig");
|
||||
_ = @import("behavior/bugs/704.zig");
|
||||
_ = @import("behavior/bugs/1076.zig");
|
||||
_ = @import("behavior/bugs/2692.zig");
|
||||
_ = @import("behavior/bugs/2889.zig");
|
||||
_ = @import("behavior/bugs/3046.zig");
|
||||
_ = @import("behavior/bugs/3586.zig");
|
||||
_ = @import("behavior/bugs/4560.zig");
|
||||
_ = @import("behavior/bugs/4769_a.zig");
|
||||
_ = @import("behavior/bugs/4769_b.zig");
|
||||
_ = @import("behavior/bugs/4954.zig");
|
||||
_ = @import("behavior/byval_arg_var.zig");
|
||||
_ = @import("behavior/call.zig");
|
||||
_ = @import("behavior/defer.zig");
|
||||
_ = @import("behavior/enum.zig");
|
||||
_ = @import("behavior/error.zig");
|
||||
_ = @import("behavior/fn.zig");
|
||||
_ = @import("behavior/for.zig");
|
||||
_ = @import("behavior/generics.zig");
|
||||
_ = @import("behavior/if.zig");
|
||||
_ = @import("behavior/import.zig");
|
||||
_ = @import("behavior/incomplete_struct_param_tld.zig");
|
||||
_ = @import("behavior/inttoptr.zig");
|
||||
_ = @import("behavior/member_func.zig");
|
||||
_ = @import("behavior/null.zig");
|
||||
_ = @import("behavior/pointers.zig");
|
||||
_ = @import("behavior/ptrcast.zig");
|
||||
_ = @import("behavior/ref_var_in_if_after_if_2nd_switch_prong.zig");
|
||||
_ = @import("behavior/src.zig");
|
||||
_ = @import("behavior/this.zig");
|
||||
_ = @import("behavior/try.zig");
|
||||
_ = @import("behavior/type_info.zig");
|
||||
_ = @import("behavior/undefined.zig");
|
||||
_ = @import("behavior/underscore.zig");
|
||||
_ = @import("behavior/union.zig");
|
||||
_ = @import("behavior/usingnamespace.zig");
|
||||
_ = @import("behavior/void.zig");
|
||||
_ = @import("behavior/while.zig");
|
||||
if (builtin.zig_backend != .stage2_arm and
|
||||
builtin.zig_backend != .stage2_x86_64 and
|
||||
builtin.zig_backend != .stage2_aarch64 and
|
||||
builtin.zig_backend != .stage2_wasm)
|
||||
{
|
||||
// Tests that pass for stage1, llvm backend, C backend
|
||||
_ = @import("behavior/bugs/9584.zig");
|
||||
_ = @import("behavior/cast_int.zig");
|
||||
_ = @import("behavior/eval.zig");
|
||||
_ = @import("behavior/int128.zig");
|
||||
_ = @import("behavior/merge_error_sets.zig");
|
||||
_ = @import("behavior/translate_c_macros.zig");
|
||||
|
||||
if (builtin.zig_backend != .stage2_wasm) {
|
||||
// Tests that pass for stage1, llvm backend, C backend
|
||||
_ = @import("behavior/bugs/9584.zig");
|
||||
_ = @import("behavior/cast_int.zig");
|
||||
_ = @import("behavior/eval.zig");
|
||||
_ = @import("behavior/int128.zig");
|
||||
_ = @import("behavior/merge_error_sets.zig");
|
||||
_ = @import("behavior/translate_c_macros.zig");
|
||||
if (builtin.zig_backend != .stage2_c) {
|
||||
// Tests that pass for stage1 and the llvm backend.
|
||||
_ = @import("behavior/atomics.zig");
|
||||
_ = @import("behavior/floatop.zig");
|
||||
_ = @import("behavior/math.zig");
|
||||
_ = @import("behavior/maximum_minimum.zig");
|
||||
_ = @import("behavior/popcount.zig");
|
||||
_ = @import("behavior/saturating_arithmetic.zig");
|
||||
_ = @import("behavior/sizeof_and_typeof.zig");
|
||||
_ = @import("behavior/switch.zig");
|
||||
_ = @import("behavior/widening.zig");
|
||||
|
||||
if (builtin.zig_backend != .stage2_c) {
|
||||
// Tests that pass for stage1 and the llvm backend.
|
||||
_ = @import("behavior/atomics.zig");
|
||||
_ = @import("behavior/floatop.zig");
|
||||
_ = @import("behavior/math.zig");
|
||||
_ = @import("behavior/maximum_minimum.zig");
|
||||
_ = @import("behavior/popcount.zig");
|
||||
_ = @import("behavior/saturating_arithmetic.zig");
|
||||
_ = @import("behavior/sizeof_and_typeof.zig");
|
||||
_ = @import("behavior/switch.zig");
|
||||
_ = @import("behavior/widening.zig");
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// Tests that only pass for the stage1 backend.
|
||||
if (builtin.os.tag != .wasi) {
|
||||
_ = @import("behavior/asm.zig");
|
||||
_ = @import("behavior/async_fn.zig");
|
||||
}
|
||||
_ = @import("behavior/await_struct.zig");
|
||||
_ = @import("behavior/bugs/421.zig");
|
||||
_ = @import("behavior/bugs/529.zig");
|
||||
_ = @import("behavior/bugs/718.zig");
|
||||
_ = @import("behavior/bugs/726.zig");
|
||||
_ = @import("behavior/bugs/828.zig");
|
||||
_ = @import("behavior/bugs/920.zig");
|
||||
_ = @import("behavior/bugs/1120.zig");
|
||||
_ = @import("behavior/bugs/1421.zig");
|
||||
_ = @import("behavior/bugs/1442.zig");
|
||||
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
// Tests that only pass for the stage1 backend.
|
||||
if (builtin.os.tag != .wasi) {
|
||||
_ = @import("behavior/asm.zig");
|
||||
_ = @import("behavior/async_fn.zig");
|
||||
}
|
||||
_ = @import("behavior/await_struct.zig");
|
||||
_ = @import("behavior/bugs/421.zig");
|
||||
_ = @import("behavior/bugs/529.zig");
|
||||
_ = @import("behavior/bugs/718.zig");
|
||||
_ = @import("behavior/bugs/726.zig");
|
||||
_ = @import("behavior/bugs/828.zig");
|
||||
_ = @import("behavior/bugs/920.zig");
|
||||
_ = @import("behavior/bugs/1120.zig");
|
||||
_ = @import("behavior/bugs/1421.zig");
|
||||
_ = @import("behavior/bugs/1607.zig");
|
||||
_ = @import("behavior/bugs/1851.zig");
|
||||
_ = @import("behavior/bugs/2114.zig");
|
||||
_ = @import("behavior/bugs/3384.zig");
|
||||
_ = @import("behavior/bugs/3742.zig");
|
||||
_ = @import("behavior/bugs/3779.zig");
|
||||
_ = @import("behavior/bugs/4328.zig");
|
||||
_ = @import("behavior/bugs/5398.zig");
|
||||
_ = @import("behavior/bugs/5413.zig");
|
||||
_ = @import("behavior/bugs/5474.zig");
|
||||
_ = @import("behavior/bugs/5487.zig");
|
||||
_ = @import("behavior/bugs/6456.zig");
|
||||
_ = @import("behavior/bugs/6781.zig");
|
||||
_ = @import("behavior/bugs/7003.zig");
|
||||
_ = @import("behavior/bugs/7027.zig");
|
||||
_ = @import("behavior/bugs/7047.zig");
|
||||
_ = @import("behavior/bugs/10147.zig");
|
||||
_ = @import("behavior/const_slice_child.zig");
|
||||
_ = @import("behavior/export_self_referential_type_info.zig");
|
||||
_ = @import("behavior/field_parent_ptr.zig");
|
||||
_ = @import("behavior/misc.zig");
|
||||
_ = @import("behavior/muladd.zig");
|
||||
_ = @import("behavior/select.zig");
|
||||
_ = @import("behavior/shuffle.zig");
|
||||
_ = @import("behavior/struct_contains_null_ptr_itself.zig");
|
||||
_ = @import("behavior/struct_contains_slice_of_itself.zig");
|
||||
_ = @import("behavior/switch_prong_err_enum.zig");
|
||||
_ = @import("behavior/switch_prong_implicit_cast.zig");
|
||||
_ = @import("behavior/typename.zig");
|
||||
_ = @import("behavior/union_with_members.zig");
|
||||
_ = @import("behavior/vector.zig");
|
||||
if (builtin.target.cpu.arch == .wasm32) {
|
||||
_ = @import("behavior/wasm.zig");
|
||||
}
|
||||
_ = @import("behavior/bugs/1607.zig");
|
||||
_ = @import("behavior/bugs/1851.zig");
|
||||
_ = @import("behavior/bugs/2114.zig");
|
||||
_ = @import("behavior/bugs/3384.zig");
|
||||
_ = @import("behavior/bugs/3742.zig");
|
||||
_ = @import("behavior/bugs/3779.zig");
|
||||
_ = @import("behavior/bugs/4328.zig");
|
||||
_ = @import("behavior/bugs/5398.zig");
|
||||
_ = @import("behavior/bugs/5413.zig");
|
||||
_ = @import("behavior/bugs/5474.zig");
|
||||
_ = @import("behavior/bugs/5487.zig");
|
||||
_ = @import("behavior/bugs/6456.zig");
|
||||
_ = @import("behavior/bugs/6781.zig");
|
||||
_ = @import("behavior/bugs/7003.zig");
|
||||
_ = @import("behavior/bugs/7027.zig");
|
||||
_ = @import("behavior/bugs/7047.zig");
|
||||
_ = @import("behavior/bugs/10147.zig");
|
||||
_ = @import("behavior/const_slice_child.zig");
|
||||
_ = @import("behavior/export_self_referential_type_info.zig");
|
||||
_ = @import("behavior/field_parent_ptr.zig");
|
||||
_ = @import("behavior/misc.zig");
|
||||
_ = @import("behavior/muladd.zig");
|
||||
_ = @import("behavior/select.zig");
|
||||
_ = @import("behavior/shuffle.zig");
|
||||
_ = @import("behavior/struct_contains_null_ptr_itself.zig");
|
||||
_ = @import("behavior/struct_contains_slice_of_itself.zig");
|
||||
_ = @import("behavior/switch_prong_err_enum.zig");
|
||||
_ = @import("behavior/switch_prong_implicit_cast.zig");
|
||||
_ = @import("behavior/typename.zig");
|
||||
_ = @import("behavior/union_with_members.zig");
|
||||
_ = @import("behavior/vector.zig");
|
||||
if (builtin.target.cpu.arch == .wasm32) {
|
||||
_ = @import("behavior/wasm.zig");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,8 +180,6 @@ fn noop4() align(4) void {}
|
||||
test "function alignment" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
// function alignment is a compile error on wasm32/wasm64
|
||||
@ -199,7 +197,6 @@ test "implicitly decreasing fn alignment" {
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
@ -226,8 +223,6 @@ test "@alignCast functions" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
// function alignment is a compile error on wasm32/wasm64
|
||||
@ -250,7 +245,6 @@ test "generic function with align param" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_llvm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
|
@ -49,7 +49,7 @@ fn getArrayLen(a: []const u32) usize {
|
||||
|
||||
test "array init with mult" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
const a = 'a';
|
||||
var i: [8]u8 = [2]u8{ a, 'b' } ** 4;
|
||||
@ -112,7 +112,7 @@ test "array len field" {
|
||||
|
||||
test "array with sentinels" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest(is_ct: bool) !void {
|
||||
@ -179,7 +179,8 @@ fn plusOne(x: u32) u32 {
|
||||
|
||||
test "single-item pointer to array indexing and slicing" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
try testSingleItemPtrArrayIndexSlice();
|
||||
comptime try testSingleItemPtrArrayIndexSlice();
|
||||
@ -205,7 +206,8 @@ fn doSomeMangling(array: *[4]u8) void {
|
||||
|
||||
test "implicit cast zero sized array ptr to slice" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
var b = "".*;
|
||||
|
@ -117,7 +117,6 @@ fn first4KeysOfHomeRow() []const u8 {
|
||||
test "return string from function" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu"));
|
||||
}
|
||||
@ -231,7 +230,6 @@ test "compile time global reinterpret" {
|
||||
|
||||
test "cast undefined" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const array: [100]u8 = undefined;
|
||||
const slice = @as([]const u8, &array);
|
||||
@ -303,7 +301,6 @@ test "call function pointer in struct" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, f3(true), "a"));
|
||||
@ -382,7 +379,6 @@ fn testMemcpyMemset() !void {
|
||||
test "variable is allowed to be a pointer to an opaque type" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
var x: i32 = 1234;
|
||||
@ -425,7 +421,6 @@ test "array 2D const double ptr" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
|
||||
const rect_2d_vertexes = [_][1]f32{
|
||||
@ -476,7 +471,6 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void {
|
||||
test "double implicit cast in same expression" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var x = @as(i32, @as(u16, nine()));
|
||||
try expect(x == 9);
|
||||
|
@ -1,8 +1,13 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const mem = std.mem;
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "comptime code should not modify constant data" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testCastPtrOfArrayToSliceAndPtr();
|
||||
comptime try testCastPtrOfArrayToSliceAndPtr();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const Union = union(enum) {
|
||||
Text: []const u8,
|
||||
@ -6,6 +7,8 @@ const Union = union(enum) {
|
||||
};
|
||||
|
||||
test "const error union field alignment" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
|
||||
var union_or_err: anyerror!Union = Union{ .Color = 1234 };
|
||||
try std.testing.expect((union_or_err catch unreachable).Color == 1234);
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
fn foo(a: []u8) void {
|
||||
_ = a;
|
||||
}
|
||||
|
||||
test "address of 0 length array" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var pt: [0]u8 = undefined;
|
||||
foo(&pt);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const source = "A-";
|
||||
|
||||
@ -26,6 +27,10 @@ fn parseNote() ?i32 {
|
||||
}
|
||||
|
||||
test "fixed" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const result = parseNote();
|
||||
try std.testing.expect(result.? == 9);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
const SomeStruct = struct {
|
||||
@ -12,7 +13,10 @@ fn couldFail() anyerror!i32 {
|
||||
var some_struct: SomeStruct = undefined;
|
||||
|
||||
test "fixed" {
|
||||
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
some_struct = SomeStruct{
|
||||
.field = couldFail() catch @as(i32, 0),
|
||||
|
@ -1,3 +1,5 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const NoteParams = struct {};
|
||||
|
||||
const Container = struct {
|
||||
@ -5,6 +7,9 @@ const Container = struct {
|
||||
};
|
||||
|
||||
test "fixed" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var ctr = Container{
|
||||
.params = NoteParams{},
|
||||
};
|
||||
|
@ -1,6 +1,10 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
test "fixed" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var s: S = .{
|
||||
.a = 1,
|
||||
.b = .{
|
||||
|
@ -1,8 +1,14 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
fn f(buf: []u8) void {
|
||||
_ = &buf[@sizeOf(u32)];
|
||||
}
|
||||
|
||||
test "crash" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var buf: [4096]u8 = undefined;
|
||||
f(&buf);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
const TestContext = struct {
|
||||
@ -19,6 +20,9 @@ fn MemoryPool(comptime T: type) type {
|
||||
}
|
||||
|
||||
test "foo" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var allocator = ContextAllocator{ .n = 10 };
|
||||
try expect(allocator.n == 10);
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const xxx = struct {
|
||||
pub fn bar(self: *xxx) void {
|
||||
_ = self;
|
||||
}
|
||||
};
|
||||
test "bug 704" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x: xxx = undefined;
|
||||
x.bar();
|
||||
}
|
||||
|
@ -1,8 +1,13 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
var result: []const u8 = "wrong";
|
||||
|
||||
test "pass string literal byvalue to a generic var param" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
start();
|
||||
blowUpStack(10);
|
||||
|
||||
|
@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual;
|
||||
const expectError = std.testing.expectError;
|
||||
|
||||
test "break and continue inside loop inside defer expression" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
testBreakContInDefer(10);
|
||||
comptime testBreakContInDefer(10);
|
||||
}
|
||||
@ -21,6 +24,9 @@ fn testBreakContInDefer(x: usize) void {
|
||||
}
|
||||
|
||||
test "defer and labeled break" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var i = @as(usize, 0);
|
||||
|
||||
blk: {
|
||||
@ -32,6 +38,9 @@ test "defer and labeled break" {
|
||||
}
|
||||
|
||||
test "errdefer does not apply to fn inside fn" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (testNestedFnErrDefer()) |_| @panic("expected error") else |e| try expect(e == error.Bad);
|
||||
}
|
||||
|
||||
@ -47,6 +56,10 @@ fn testNestedFnErrDefer() anyerror!void {
|
||||
}
|
||||
|
||||
test "return variable while defer expression in scope to modify it" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
try expect(notNull().? == 1);
|
||||
|
@ -11,6 +11,9 @@ fn shouldEqual(n: Number, expected: u3) !void {
|
||||
}
|
||||
|
||||
test "enum to int" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try shouldEqual(Number.Zero, 0);
|
||||
try shouldEqual(Number.One, 1);
|
||||
try shouldEqual(Number.Two, 2);
|
||||
@ -24,6 +27,9 @@ fn testIntToEnumEval(x: i32) !void {
|
||||
const IntToEnumNumber = enum { Zero, One, Two, Three, Four };
|
||||
|
||||
test "int to enum" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testIntToEnumEval(3);
|
||||
}
|
||||
|
||||
@ -553,6 +559,9 @@ const ValueCount257 = enum {
|
||||
};
|
||||
|
||||
test "enum sizes" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
try expect(@sizeOf(ValueCount1) == 0);
|
||||
try expect(@sizeOf(ValueCount2) == 1);
|
||||
@ -562,6 +571,9 @@ test "enum sizes" {
|
||||
}
|
||||
|
||||
test "enum literal equality" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const x = .hi;
|
||||
const y = .ok;
|
||||
const z = .hi;
|
||||
@ -571,6 +583,9 @@ test "enum literal equality" {
|
||||
}
|
||||
|
||||
test "enum literal cast to enum" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Color = enum { Auto, Off, On };
|
||||
|
||||
var color1: Color = .Auto;
|
||||
@ -579,6 +594,9 @@ test "enum literal cast to enum" {
|
||||
}
|
||||
|
||||
test "peer type resolution with enum literal" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Items = enum { one, two };
|
||||
|
||||
try expect(Items.two == .two);
|
||||
@ -603,11 +621,19 @@ fn testEnumWithSpecifiedTagValues(x: MultipleChoice) !void {
|
||||
}
|
||||
|
||||
test "enum with specified tag values" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testEnumWithSpecifiedTagValues(MultipleChoice.C);
|
||||
comptime try testEnumWithSpecifiedTagValues(MultipleChoice.C);
|
||||
}
|
||||
|
||||
test "non-exhaustive enum" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const E = enum(u8) { a, b, _ };
|
||||
|
||||
@ -649,6 +675,9 @@ test "non-exhaustive enum" {
|
||||
}
|
||||
|
||||
test "empty non-exhaustive enum" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const E = enum(u8) { _ };
|
||||
|
||||
@ -668,6 +697,10 @@ test "empty non-exhaustive enum" {
|
||||
}
|
||||
|
||||
test "single field non-exhaustive enum" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const E = enum(u8) { a, _ };
|
||||
fn doTheTest(y: u8) !void {
|
||||
@ -708,6 +741,9 @@ const EnumWithTagValues = enum(u4) {
|
||||
D = 1 << 3,
|
||||
};
|
||||
test "enum with tag values don't require parens" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(@enumToInt(EnumWithTagValues.C) == 0b0100);
|
||||
}
|
||||
|
||||
@ -724,11 +760,18 @@ const MultipleChoice2 = enum(u32) {
|
||||
};
|
||||
|
||||
test "cast integer literal to enum" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(@intToEnum(MultipleChoice2, 0) == MultipleChoice2.Unspecified1);
|
||||
try expect(@intToEnum(MultipleChoice2, 40) == MultipleChoice2.B);
|
||||
}
|
||||
|
||||
test "enum with specified and unspecified tag values" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
|
||||
comptime try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2.D);
|
||||
}
|
||||
@ -752,6 +795,9 @@ const Small2 = enum(u2) { One, Two };
|
||||
const Small = enum(u2) { One, Two, Three, Four };
|
||||
|
||||
test "set enum tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
var x = Small.One;
|
||||
x = Small.Two;
|
||||
@ -765,6 +811,9 @@ test "set enum tag type" {
|
||||
}
|
||||
|
||||
test "casting enum to its tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testCastEnumTag(Small2.Two);
|
||||
comptime try testCastEnumTag(Small2.Two);
|
||||
}
|
||||
@ -774,6 +823,9 @@ fn testCastEnumTag(value: Small2) !void {
|
||||
}
|
||||
|
||||
test "enum with 1 field but explicit tag type should still have the tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Enum = enum(u8) {
|
||||
B = 2,
|
||||
};
|
||||
@ -781,6 +833,9 @@ test "enum with 1 field but explicit tag type should still have the tag type" {
|
||||
}
|
||||
|
||||
test "signed integer as enum tag" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const SignedEnum = enum(i2) {
|
||||
A0 = -1,
|
||||
A1 = 0,
|
||||
@ -793,6 +848,9 @@ test "signed integer as enum tag" {
|
||||
}
|
||||
|
||||
test "enum with one member and custom tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const E = enum(u2) {
|
||||
One,
|
||||
};
|
||||
@ -804,6 +862,9 @@ test "enum with one member and custom tag type" {
|
||||
}
|
||||
|
||||
test "enum with one member and u1 tag type @enumToInt" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Enum = enum(u1) {
|
||||
Test,
|
||||
};
|
||||
@ -811,6 +872,9 @@ test "enum with one member and u1 tag type @enumToInt" {
|
||||
}
|
||||
|
||||
test "enum with comptime_int tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Enum = enum(comptime_int) {
|
||||
One = 3,
|
||||
Two = 2,
|
||||
@ -820,6 +884,9 @@ test "enum with comptime_int tag type" {
|
||||
}
|
||||
|
||||
test "enum with one member default to u0 tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const E0 = enum { X };
|
||||
comptime try expect(Tag(E0) == u0);
|
||||
}
|
||||
@ -836,11 +903,17 @@ fn doALoopThing(id: EnumWithOneMember) void {
|
||||
}
|
||||
|
||||
test "comparison operator on enum with one member is comptime known" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
doALoopThing(EnumWithOneMember.Eof);
|
||||
}
|
||||
|
||||
const State = enum { Start };
|
||||
test "switch on enum with one member is comptime known" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var state = State.Start;
|
||||
switch (state) {
|
||||
State.Start => return,
|
||||
@ -849,6 +922,9 @@ test "switch on enum with one member is comptime known" {
|
||||
}
|
||||
|
||||
test "method call on an enum" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const E = enum {
|
||||
one,
|
||||
@ -885,6 +961,10 @@ test "enum value allocation" {
|
||||
}
|
||||
|
||||
test "enum literal casting to tagged union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Arch = union(enum) {
|
||||
x86_64,
|
||||
arm: Arm32,
|
||||
@ -930,6 +1010,11 @@ test "exporting enum type and value" {
|
||||
}
|
||||
|
||||
test "constant enum initialization with differing sizes" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
|
||||
try test3_1(test3_foo);
|
||||
try test3_2(test3_bar);
|
||||
}
|
||||
@ -970,6 +1055,9 @@ fn test3_2(f: Test3Foo) !void {
|
||||
test "@tagName" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
|
||||
comptime try expect(mem.eql(u8, testEnumTagNameBare(BareNumber.Three), "Three"));
|
||||
@ -984,6 +1072,9 @@ const BareNumber = enum { One, Two, Three };
|
||||
test "@tagName non-exhaustive enum" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
|
||||
comptime try expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
|
||||
@ -993,6 +1084,9 @@ const NonExhaustive = enum(u8) { A, B, _ };
|
||||
test "@tagName is null-terminated" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest(n: BareNumber) !void {
|
||||
@ -1006,6 +1100,9 @@ test "@tagName is null-terminated" {
|
||||
test "tag name with assigned enum values" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const LocalFoo = enum(u8) {
|
||||
A = 1,
|
||||
@ -1016,11 +1113,18 @@ test "tag name with assigned enum values" {
|
||||
}
|
||||
|
||||
test "@tagName on enum literals" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
|
||||
comptime try expect(mem.eql(u8, @tagName(.FooBar), "FooBar"));
|
||||
}
|
||||
|
||||
test "enum literal casting to optional" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var bar: ?Bar = undefined;
|
||||
bar = .B;
|
||||
|
||||
@ -1045,6 +1149,9 @@ const bit_field_1 = BitFieldOfEnums{
|
||||
|
||||
test "bit field access with enum fields" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var data = bit_field_1;
|
||||
try expect(getA(&data) == A.Two);
|
||||
@ -1073,6 +1180,9 @@ fn getC(data: *const BitFieldOfEnums) C {
|
||||
}
|
||||
|
||||
test "enum literal in array literal" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Items = enum { one, two };
|
||||
const array = [_]Items{ .one, .two };
|
||||
|
||||
|
@ -6,12 +6,18 @@ const expectEqual = std.testing.expectEqual;
|
||||
const mem = std.mem;
|
||||
|
||||
test "error values" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const a = @errorToInt(error.err1);
|
||||
const b = @errorToInt(error.err2);
|
||||
try expect(a != b);
|
||||
}
|
||||
|
||||
test "redefinition of error values allowed" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
shouldBeNotEqual(error.AnError, error.SecondError);
|
||||
}
|
||||
fn shouldBeNotEqual(a: anyerror, b: anyerror) void {
|
||||
@ -19,6 +25,10 @@ fn shouldBeNotEqual(a: anyerror, b: anyerror) void {
|
||||
}
|
||||
|
||||
test "error binary operator" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const a = errBinaryOperatorG(true) catch 3;
|
||||
const b = errBinaryOperatorG(false) catch 3;
|
||||
try expect(a == 3);
|
||||
@ -29,6 +39,9 @@ fn errBinaryOperatorG(x: bool) anyerror!isize {
|
||||
}
|
||||
|
||||
test "empty error union" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const x = error{} || error{};
|
||||
_ = x;
|
||||
}
|
||||
@ -48,10 +61,18 @@ pub fn baz() anyerror!i32 {
|
||||
}
|
||||
|
||||
test "error wrapping" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect((baz() catch unreachable) == 15);
|
||||
}
|
||||
|
||||
test "unwrap simple value from error" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const i = unwrapSimpleValueFromErrorDo() catch unreachable;
|
||||
try expect(i == 13);
|
||||
}
|
||||
@ -60,6 +81,10 @@ fn unwrapSimpleValueFromErrorDo() anyerror!isize {
|
||||
}
|
||||
|
||||
test "error return in assignment" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
doErrReturnInAssignment() catch unreachable;
|
||||
}
|
||||
|
||||
@ -73,12 +98,19 @@ fn makeANonErr() anyerror!i32 {
|
||||
}
|
||||
|
||||
test "syntax: optional operator in front of error union operator" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
try expect(?(anyerror!i32) == ?(anyerror!i32));
|
||||
}
|
||||
}
|
||||
|
||||
test "widen cast integer payload of error union function call" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn errorable() !u64 {
|
||||
var x = @as(u64, try number());
|
||||
@ -93,12 +125,19 @@ test "widen cast integer payload of error union function call" {
|
||||
}
|
||||
|
||||
test "debug info for optional error set" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const SomeError = error{Hello};
|
||||
var a_local_variable: ?SomeError = null;
|
||||
_ = a_local_variable;
|
||||
}
|
||||
|
||||
test "implicit cast to optional to error union to return result loc" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn entry() !void {
|
||||
var x: Foo = undefined;
|
||||
@ -118,6 +157,9 @@ test "implicit cast to optional to error union to return result loc" {
|
||||
}
|
||||
|
||||
test "error: fn returning empty error set can be passed as fn returning any error" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
entry();
|
||||
comptime entry();
|
||||
}
|
||||
@ -482,6 +524,9 @@ test "error union comptime caching" {
|
||||
test "@errorName" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(mem.eql(u8, @errorName(error.AnError), "AnError"));
|
||||
try expect(mem.eql(u8, @errorName(error.ALongerErrorName), "ALongerErrorName"));
|
||||
@ -494,6 +539,9 @@ fn gimmeItBroke() anyerror {
|
||||
test "@errorName sentinel length matches slice length" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const name = testBuiltinErrorName(error.FooBar);
|
||||
const length: usize = 6;
|
||||
|
@ -5,6 +5,9 @@ const expect = testing.expect;
|
||||
const expectEqual = testing.expectEqual;
|
||||
|
||||
test "params" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(testParamsAdd(22, 11) == 33);
|
||||
}
|
||||
fn testParamsAdd(a: i32, b: i32) i32 {
|
||||
@ -12,6 +15,9 @@ fn testParamsAdd(a: i32, b: i32) i32 {
|
||||
}
|
||||
|
||||
test "local variables" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
testLocVars(2);
|
||||
}
|
||||
fn testLocVars(b: i32) void {
|
||||
@ -20,6 +26,9 @@ fn testLocVars(b: i32) void {
|
||||
}
|
||||
|
||||
test "mutable local variables" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var zero: i32 = 0;
|
||||
try expect(zero == 0);
|
||||
|
||||
@ -31,6 +40,9 @@ test "mutable local variables" {
|
||||
}
|
||||
|
||||
test "separate block scopes" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
const no_conflict: i32 = 5;
|
||||
try expect(no_conflict == 5);
|
||||
@ -47,10 +59,16 @@ fn @"weird function name"() i32 {
|
||||
return 1234;
|
||||
}
|
||||
test "weird function name" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(@"weird function name"() == 1234);
|
||||
}
|
||||
|
||||
test "assign inline fn to const variable" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const a = inlineFn;
|
||||
a();
|
||||
}
|
||||
@ -68,6 +86,9 @@ fn outer(y: u32) *const fn (u32) u32 {
|
||||
}
|
||||
|
||||
test "return inner function which references comptime variable of outer function" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
|
||||
var func = outer(10);
|
||||
@ -76,6 +97,9 @@ test "return inner function which references comptime variable of outer function
|
||||
|
||||
test "discard the result of a function that returns a struct" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn entry() void {
|
||||
_ = func();
|
||||
@ -97,6 +121,9 @@ test "discard the result of a function that returns a struct" {
|
||||
test "inline function call that calls optional function pointer, return pointer at callsite interacts correctly with callsite return type" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
field: u32,
|
||||
@ -129,6 +156,9 @@ test "inline function call that calls optional function pointer, return pointer
|
||||
}
|
||||
|
||||
test "implicit cast function unreachable return" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
wantsFnWithVoid(fnWithUnreachable);
|
||||
}
|
||||
|
||||
@ -143,6 +173,8 @@ fn fnWithUnreachable() noreturn {
|
||||
test "extern struct with stdcallcc fn pointer" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = extern struct {
|
||||
ptr: *const fn () callconv(if (builtin.target.cpu.arch == .i386) .Stdcall else .C) i32,
|
||||
@ -170,10 +202,16 @@ fn fComplexCallconvRet(x: u32) callconv(blk: {
|
||||
}
|
||||
|
||||
test "function with complex callconv and return type expressions" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(fComplexCallconvRet(3).x == 9);
|
||||
}
|
||||
|
||||
test "pass by non-copying value" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(addPointCoords(Point{ .x = 1, .y = 2 }) == 3);
|
||||
}
|
||||
|
||||
@ -187,6 +225,10 @@ fn addPointCoords(pt: Point) i32 {
|
||||
}
|
||||
|
||||
test "pass by non-copying value through var arg" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect((try addPointCoordsVar(Point{ .x = 1, .y = 2 })) == 3);
|
||||
}
|
||||
|
||||
@ -196,6 +238,9 @@ fn addPointCoordsVar(pt: anytype) !i32 {
|
||||
}
|
||||
|
||||
test "pass by non-copying value as method" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var pt = Point2{ .x = 1, .y = 2 };
|
||||
try expect(pt.addPointCoords() == 3);
|
||||
}
|
||||
@ -210,6 +255,9 @@ const Point2 = struct {
|
||||
};
|
||||
|
||||
test "pass by non-copying value as method, which is generic" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var pt = Point3{ .x = 1, .y = 2 };
|
||||
try expect(pt.addPointCoords(i32) == 3);
|
||||
}
|
||||
@ -225,6 +273,9 @@ const Point3 = struct {
|
||||
};
|
||||
|
||||
test "pass by non-copying value as method, at comptime" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
var pt = Point2{ .x = 1, .y = 2 };
|
||||
try expect(pt.addPointCoords() == 3);
|
||||
@ -232,6 +283,9 @@ test "pass by non-copying value as method, at comptime" {
|
||||
}
|
||||
|
||||
test "implicit cast fn call result to optional in field result" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn entry() !void {
|
||||
var x = Foo{
|
||||
@ -255,6 +309,10 @@ test "implicit cast fn call result to optional in field result" {
|
||||
}
|
||||
|
||||
test "void parameters" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
try voidFun(1, void{}, 2, {});
|
||||
}
|
||||
@ -267,6 +325,9 @@ fn voidFun(a: i32, b: void, c: i32, d: void) !void {
|
||||
}
|
||||
|
||||
test "call function with empty string" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
acceptsString("");
|
||||
}
|
||||
|
||||
@ -301,6 +362,9 @@ fn fn4() u32 {
|
||||
}
|
||||
|
||||
test "number literal as an argument" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try numberLiteralArg(3);
|
||||
comptime try numberLiteralArg(3);
|
||||
}
|
||||
@ -311,6 +375,10 @@ fn numberLiteralArg(a: anytype) !void {
|
||||
|
||||
test "function call with anon list literal" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
try consumeVec(.{ 9, 8, 7 });
|
||||
@ -327,6 +395,9 @@ test "function call with anon list literal" {
|
||||
}
|
||||
|
||||
test "ability to give comptime types and non comptime types to same parameter" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var x: i32 = 1;
|
||||
|
@ -5,6 +5,9 @@ const expectEqual = std.testing.expectEqual;
|
||||
const mem = std.mem;
|
||||
|
||||
test "continue in for loop" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const array = [_]i32{ 1, 2, 3, 4, 5 };
|
||||
var sum: i32 = 0;
|
||||
for (array) |x| {
|
||||
@ -18,6 +21,9 @@ test "continue in for loop" {
|
||||
}
|
||||
|
||||
test "break from outer for loop" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testBreakOuter();
|
||||
comptime try testBreakOuter();
|
||||
}
|
||||
@ -35,6 +41,9 @@ fn testBreakOuter() !void {
|
||||
}
|
||||
|
||||
test "continue outer for loop" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testContinueOuter();
|
||||
comptime try testContinueOuter();
|
||||
}
|
||||
@ -52,6 +61,9 @@ fn testContinueOuter() !void {
|
||||
}
|
||||
|
||||
test "ignore lval with underscore (for loop)" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
for ([_]void{}) |_, i| {
|
||||
_ = i;
|
||||
for ([_]void{}) |_, j| {
|
||||
@ -63,7 +75,10 @@ test "ignore lval with underscore (for loop)" {
|
||||
}
|
||||
|
||||
test "basic for loop" {
|
||||
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const expected_result = [_]u8{ 9, 8, 7, 6, 0, 1, 2, 3 } ** 3;
|
||||
|
||||
@ -104,6 +119,10 @@ test "basic for loop" {
|
||||
}
|
||||
|
||||
test "for with null and T peer types and inferred result location type" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest(slice: []const u8) !void {
|
||||
if (for (slice) |item| {
|
||||
@ -121,6 +140,9 @@ test "for with null and T peer types and inferred result location type" {
|
||||
}
|
||||
|
||||
test "2 break statements and an else" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn entry(t: bool, f: bool) !void {
|
||||
var buf: [10]u8 = undefined;
|
||||
|
@ -5,6 +5,9 @@ const expect = testing.expect;
|
||||
const expectEqual = testing.expectEqual;
|
||||
|
||||
test "one param, explicit comptime" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x: usize = 0;
|
||||
x += checkSize(i32);
|
||||
x += checkSize(bool);
|
||||
@ -17,6 +20,9 @@ fn checkSize(comptime T: type) usize {
|
||||
}
|
||||
|
||||
test "simple generic fn" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(max(i32, 3, -1) == 3);
|
||||
try expect(max(u8, 1, 100) == 100);
|
||||
if (builtin.zig_backend == .stage1) {
|
||||
@ -37,6 +43,9 @@ fn add(comptime a: i32, b: i32) i32 {
|
||||
|
||||
const the_max = max(u32, 1234, 5678);
|
||||
test "compile time generic eval" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(the_max == 5678);
|
||||
}
|
||||
|
||||
@ -53,12 +62,20 @@ fn sameButWithFloats(a: f64, b: f64) f64 {
|
||||
}
|
||||
|
||||
test "fn with comptime args" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(gimmeTheBigOne(1234, 5678) == 5678);
|
||||
try expect(shouldCallSameInstance(34, 12) == 34);
|
||||
try expect(sameButWithFloats(0.43, 0.49) == 0.49);
|
||||
}
|
||||
|
||||
test "anytype params" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(max_i32(12, 34) == 34);
|
||||
try expect(max_f64(1.2, 3.4) == 3.4);
|
||||
comptime {
|
||||
@ -80,6 +97,10 @@ fn max_f64(a: f64, b: f64) f64 {
|
||||
}
|
||||
|
||||
test "type constructed by comptime function call" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var l: SimpleList(10) = undefined;
|
||||
l.array[0] = 10;
|
||||
l.array[1] = 11;
|
||||
@ -99,6 +120,9 @@ fn SimpleList(comptime L: usize) type {
|
||||
}
|
||||
|
||||
test "function with return type type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var list: List(i32) = undefined;
|
||||
var list2: List(i32) = undefined;
|
||||
list.length = 10;
|
||||
@ -120,6 +144,9 @@ pub fn SmallList(comptime T: type, comptime STATIC_SIZE: usize) type {
|
||||
}
|
||||
|
||||
test "const decls in struct" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(GenericDataThing(3).count_plus_one == 4);
|
||||
}
|
||||
fn GenericDataThing(comptime count: isize) type {
|
||||
@ -129,6 +156,9 @@ fn GenericDataThing(comptime count: isize) type {
|
||||
}
|
||||
|
||||
test "use generic param in generic param" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(aGenericFn(i32, 3, 4) == 7);
|
||||
}
|
||||
fn aGenericFn(comptime T: type, comptime a: T, b: T) T {
|
||||
@ -136,6 +166,9 @@ fn aGenericFn(comptime T: type, comptime a: T, b: T) T {
|
||||
}
|
||||
|
||||
test "generic fn with implicit cast" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(getFirstByte(u8, &[_]u8{13}) == 13);
|
||||
try expect(getFirstByte(u16, &[_]u16{
|
||||
0,
|
||||
@ -150,6 +183,9 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {
|
||||
}
|
||||
|
||||
test "generic fn keeps non-generic parameter types" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const A = 128;
|
||||
|
||||
const S = struct {
|
||||
@ -165,8 +201,10 @@ test "generic fn keeps non-generic parameter types" {
|
||||
}
|
||||
|
||||
test "array of generic fns" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try expect(foos[0](true));
|
||||
try expect(!foos[1](true));
|
||||
}
|
||||
@ -185,7 +223,8 @@ fn foo2(arg: anytype) bool {
|
||||
|
||||
test "generic struct" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
var a1 = GenNode(i32){
|
||||
.value = 13,
|
||||
.next = null,
|
||||
|
@ -4,6 +4,9 @@ const expect = std.testing.expect;
|
||||
const expectEqual = std.testing.expectEqual;
|
||||
|
||||
test "if statements" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
shouldBeEqual(1, 1);
|
||||
firstEqlThird(2, 1, 2);
|
||||
}
|
||||
@ -27,6 +30,9 @@ fn firstEqlThird(a: i32, b: i32, c: i32) void {
|
||||
}
|
||||
|
||||
test "else if expression" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(elseIfExpressionF(1) == 1);
|
||||
}
|
||||
fn elseIfExpressionF(c: u8) u8 {
|
||||
@ -44,6 +50,10 @@ var global_with_val: anyerror!u32 = 0;
|
||||
var global_with_err: anyerror!u32 = error.SomeError;
|
||||
|
||||
test "unwrap mutable global var" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (global_with_val) |v| {
|
||||
try expect(v == 0);
|
||||
} else |_| {
|
||||
@ -57,6 +67,9 @@ test "unwrap mutable global var" {
|
||||
}
|
||||
|
||||
test "labeled break inside comptime if inside runtime if" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var answer: i32 = 0;
|
||||
var c = true;
|
||||
if (c) {
|
||||
@ -68,6 +81,9 @@ test "labeled break inside comptime if inside runtime if" {
|
||||
}
|
||||
|
||||
test "const result loc, runtime if cond, else unreachable" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Num = enum { One, Two };
|
||||
|
||||
var t = true;
|
||||
@ -76,6 +92,10 @@ test "const result loc, runtime if cond, else unreachable" {
|
||||
}
|
||||
|
||||
test "if copies its payload" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var tmp: ?i32 = 10;
|
||||
|
@ -1,3 +1,4 @@
|
||||
const builtin = @import("builtin");
|
||||
const expect = @import("std").testing.expect;
|
||||
|
||||
const A = struct {
|
||||
@ -21,6 +22,8 @@ fn foo(a: A) i32 {
|
||||
}
|
||||
|
||||
test "incomplete struct param top level declaration" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
const a = A{
|
||||
.b = B{
|
||||
.c = C{ .x = 13 },
|
||||
|
@ -3,6 +3,8 @@ const builtin = @import("builtin");
|
||||
test "casting integer address to function pointer" {
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
addressToFunction();
|
||||
comptime addressToFunction();
|
||||
@ -14,6 +16,10 @@ fn addressToFunction() void {
|
||||
}
|
||||
|
||||
test "mutate through ptr initialized with constant intToPtr value" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
forceCompilerAnalyzeBranchHardCodedPtrDereference(false);
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,9 @@ const HasFuncs = struct {
|
||||
|
||||
test "standard field calls" {
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(HasFuncs.one(0) == 1);
|
||||
try expect(HasFuncs.two(0) == 2);
|
||||
@ -69,6 +72,9 @@ test "standard field calls" {
|
||||
|
||||
test "@field field calls" {
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(@field(HasFuncs, "one")(0) == 1);
|
||||
try expect(@field(HasFuncs, "two")(0) == 2);
|
||||
|
@ -29,6 +29,10 @@ test "optional type" {
|
||||
}
|
||||
|
||||
test "test maybe object and get a pointer to the inner value" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var maybe_bool: ?bool = true;
|
||||
|
||||
if (maybe_bool) |*b| {
|
||||
@ -45,6 +49,10 @@ test "rhs maybe unwrap return" {
|
||||
}
|
||||
|
||||
test "maybe return" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try maybeReturnImpl();
|
||||
comptime try maybeReturnImpl();
|
||||
}
|
||||
@ -61,6 +69,10 @@ fn foo(x: ?i32) ?bool {
|
||||
}
|
||||
|
||||
test "test null runtime" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testTestNullRuntime(null);
|
||||
}
|
||||
fn testTestNullRuntime(x: ?i32) !void {
|
||||
@ -69,6 +81,9 @@ fn testTestNullRuntime(x: ?i32) !void {
|
||||
}
|
||||
|
||||
test "optional void" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try optionalVoidImpl();
|
||||
comptime try optionalVoidImpl();
|
||||
}
|
||||
@ -89,6 +104,9 @@ fn bar(x: ?void) ?void {
|
||||
const Empty = struct {};
|
||||
|
||||
test "optional struct{}" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
_ = try optionalEmptyStructImpl();
|
||||
_ = comptime try optionalEmptyStructImpl();
|
||||
}
|
||||
@ -107,17 +125,25 @@ fn baz(x: ?Empty) ?Empty {
|
||||
}
|
||||
|
||||
test "null with default unwrap" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const x: i32 = null orelse 1;
|
||||
try expect(x == 1);
|
||||
}
|
||||
|
||||
test "optional pointer to 0 bit type null value at runtime" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const EmptyStruct = struct {};
|
||||
var x: ?*EmptyStruct = null;
|
||||
try expect(x == null);
|
||||
}
|
||||
|
||||
test "if var maybe pointer" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(shouldBeAPlus1(Particle{
|
||||
.a = 14,
|
||||
.b = 1,
|
||||
@ -159,6 +185,9 @@ const here_is_a_null_literal = SillyStruct{ .context = null };
|
||||
test "unwrap optional which is field of global var" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
struct_with_optional.field = null;
|
||||
if (struct_with_optional.field) |payload| {
|
||||
|
@ -17,6 +17,10 @@ fn testDerefPtr() !void {
|
||||
}
|
||||
|
||||
test "pointer arithmetic" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var ptr: [*]const u8 = "abcd";
|
||||
|
||||
try expect(ptr[0] == 'a');
|
||||
@ -61,6 +65,10 @@ test "initialize const optional C pointer to null" {
|
||||
}
|
||||
|
||||
test "assigning integer to C pointer" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x: i32 = 0;
|
||||
var y: i32 = 1;
|
||||
var ptr: [*c]u8 = 0;
|
||||
@ -75,6 +83,10 @@ test "assigning integer to C pointer" {
|
||||
}
|
||||
|
||||
test "C pointer comparison and arithmetic" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var ptr1: [*c]u32 = 0;
|
||||
@ -133,6 +145,10 @@ test "peer type resolution with C pointers" {
|
||||
}
|
||||
|
||||
test "implicit casting between C pointer and optional non-C pointer" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var slice: []const u8 = "aoeu";
|
||||
const opt_many_ptr: ?[*]const u8 = slice.ptr;
|
||||
var ptr_opt_many_ptr = &opt_many_ptr;
|
||||
@ -172,6 +188,9 @@ test "compare equality of optional and non-optional pointer" {
|
||||
test "allowzero pointer and slice" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var ptr = @intToPtr([*]allowzero i32, 0);
|
||||
var opt_ptr: ?[*]allowzero i32 = ptr;
|
||||
|
@ -1,9 +1,14 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
const mem = std.mem;
|
||||
|
||||
var ok: bool = false;
|
||||
test "reference a variable in an if after an if in the 2nd switch prong" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try foo(true, Num.Two, false, "aoeu");
|
||||
try expect(!ok);
|
||||
try foo(false, Num.One, false, "aoeu");
|
||||
|
@ -248,7 +248,6 @@ test "result location zero sized array inside struct field implicit cast to slic
|
||||
test "runtime safety lets us slice from len..len" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var an_array = [_]u8{ 1, 2, 3 };
|
||||
try expect(mem.eql(u8, sliceFromLenToLen(an_array[0..], 3, 3), ""));
|
||||
|
@ -1,7 +1,10 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "@src" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest;
|
||||
|
||||
try doTheTest();
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,8 @@ const StructFoo = struct {
|
||||
|
||||
test "structs" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
var foo: StructFoo = undefined;
|
||||
@memset(@ptrCast([*]u8, &foo), 0, @sizeOf(StructFoo));
|
||||
@ -248,7 +249,8 @@ test "usingnamespace within struct scope" {
|
||||
|
||||
test "struct field init with catch" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 or builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
@ -310,7 +312,6 @@ test "struct point to self" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
var root: Node = undefined;
|
||||
root.val.x = 1;
|
||||
@ -350,7 +351,6 @@ test "return empty struct from fn" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
_ = testReturnEmptyStructFromFn();
|
||||
}
|
||||
@ -364,7 +364,6 @@ test "pass slice of empty struct to fn" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
try expect(testPassSliceOfEmptyStructToFn(&[_]EmptyStruct2{EmptyStruct2{}}) == 1);
|
||||
}
|
||||
@ -409,7 +408,6 @@ test "align 1 field before self referential align 8 field as slice return type"
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
const result = alloc(Expr);
|
||||
try expect(result.len == 0);
|
||||
@ -670,7 +668,6 @@ test "default struct initialization fields" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
a: i32 = 1234,
|
||||
@ -936,7 +933,6 @@ test "anonymous struct literal syntax" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
|
||||
|
||||
const S = struct {
|
||||
const Point = struct {
|
||||
|
@ -1,4 +1,5 @@
|
||||
const expect = @import("std").testing.expect;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const module = @This();
|
||||
|
||||
@ -20,10 +21,16 @@ fn add(x: i32, y: i32) i32 {
|
||||
}
|
||||
|
||||
test "this refer to module call private fn" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(module.add(1, 2) == 3);
|
||||
}
|
||||
|
||||
test "this refer to container" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var pt: Point(i32) = undefined;
|
||||
pt.x = 12;
|
||||
pt.y = 34;
|
||||
|
@ -1,6 +1,12 @@
|
||||
const expect = @import("std").testing.expect;
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "try on error union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try tryOnErrorUnionImpl();
|
||||
comptime try tryOnErrorUnionImpl();
|
||||
}
|
||||
@ -19,6 +25,9 @@ fn returnsTen() anyerror!i32 {
|
||||
}
|
||||
|
||||
test "try without vars" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const result1 = if (failIfTrue(true)) 1 else |_| @as(i32, 2);
|
||||
try expect(result1 == 2);
|
||||
|
||||
@ -35,6 +44,9 @@ fn failIfTrue(ok: bool) anyerror!void {
|
||||
}
|
||||
|
||||
test "try then not executed with assignment" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (failIfTrue(true)) {
|
||||
unreachable;
|
||||
} else |err| {
|
||||
|
@ -186,6 +186,10 @@ fn testErrorSet() !void {
|
||||
}
|
||||
|
||||
test "type info: enum info" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testEnum();
|
||||
comptime try testEnum();
|
||||
}
|
||||
@ -249,6 +253,9 @@ fn testUnion() !void {
|
||||
}
|
||||
|
||||
test "type info: struct info" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testStruct();
|
||||
comptime try testStruct();
|
||||
}
|
||||
@ -439,6 +446,10 @@ test "type info for async frames" {
|
||||
}
|
||||
|
||||
test "Declarations are returned in declaration order" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const a = 1;
|
||||
const b = 2;
|
||||
|
@ -16,6 +16,8 @@ test "init static array to undefined" {
|
||||
// This test causes `initStaticArray()` to be codegen'd, and the
|
||||
// C backend does not yet support returning arrays, so it fails
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(static_array[0] == 1);
|
||||
try expect(static_array[4] == 2);
|
||||
@ -43,6 +45,9 @@ fn setFooX(foo: *Foo) void {
|
||||
}
|
||||
|
||||
test "assign undefined to struct" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
var foo: Foo = undefined;
|
||||
setFooX(&foo);
|
||||
@ -56,6 +61,9 @@ test "assign undefined to struct" {
|
||||
}
|
||||
|
||||
test "assign undefined to struct with method" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
var foo: Foo = undefined;
|
||||
foo.setFooXMethod();
|
||||
@ -69,6 +77,9 @@ test "assign undefined to struct with method" {
|
||||
}
|
||||
|
||||
test "type name of undefined" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const x = undefined;
|
||||
try expect(mem.eql(u8, @typeName(@TypeOf(x)), "@Type(.Undefined)"));
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "ignore lval with underscore" {
|
||||
@ -6,6 +7,10 @@ test "ignore lval with underscore" {
|
||||
}
|
||||
|
||||
test "ignore lval with underscore (while loop)" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
while (optionalReturnError()) |_| {
|
||||
while (optionalReturnError()) |_| {
|
||||
break;
|
||||
|
@ -10,6 +10,10 @@ const Foo = union {
|
||||
};
|
||||
|
||||
test "basic unions" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var foo = Foo{ .int = 1 };
|
||||
try expect(foo.int == 1);
|
||||
foo = Foo{ .float = 12.34 };
|
||||
@ -17,6 +21,10 @@ test "basic unions" {
|
||||
}
|
||||
|
||||
test "init union with runtime value" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var foo: Foo = undefined;
|
||||
|
||||
setFloat(&foo, 12.34);
|
||||
@ -35,6 +43,9 @@ fn setInt(foo: *Foo, x: i32) void {
|
||||
}
|
||||
|
||||
test "comptime union field access" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
var foo = Foo{ .int = 0 };
|
||||
try expect(foo.int == 0);
|
||||
@ -50,6 +61,10 @@ const FooExtern = extern union {
|
||||
};
|
||||
|
||||
test "basic extern unions" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var foo = FooExtern{ .int = 1 };
|
||||
try expect(foo.int == 1);
|
||||
foo.float = 12.34;
|
||||
@ -61,10 +76,16 @@ const ExternPtrOrInt = extern union {
|
||||
int: u64,
|
||||
};
|
||||
test "extern union size" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime try expect(@sizeOf(ExternPtrOrInt) == 8);
|
||||
}
|
||||
|
||||
test "0-sized extern union definition" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const U = extern union {
|
||||
a: void,
|
||||
const f = 1;
|
||||
@ -94,6 +115,9 @@ const err = @as(anyerror!Agg, Agg{
|
||||
const array = [_]Value{ v1, v2, v1, v2 };
|
||||
|
||||
test "unions embedded in aggregate types" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
switch (array[1]) {
|
||||
Value.Array => |arr| try expect(arr[4] == 3),
|
||||
else => unreachable,
|
||||
@ -105,6 +129,9 @@ test "unions embedded in aggregate types" {
|
||||
}
|
||||
|
||||
test "access a member of tagged union with conflicting enum tag name" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Bar = union(enum) {
|
||||
A: A,
|
||||
B: B,
|
||||
@ -117,6 +144,10 @@ test "access a member of tagged union with conflicting enum tag name" {
|
||||
}
|
||||
|
||||
test "constant tagged union with payload" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var empty = TaggedUnionWithPayload{ .Empty = {} };
|
||||
var full = TaggedUnionWithPayload{ .Full = 13 };
|
||||
shouldBeEmpty(empty);
|
||||
@ -143,6 +174,9 @@ const TaggedUnionWithPayload = union(enum) {
|
||||
};
|
||||
|
||||
test "union alignment" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime {
|
||||
try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf([9]u8));
|
||||
try expect(@alignOf(AlignTestTaggedUnion) >= @alignOf(u64));
|
||||
@ -162,11 +196,18 @@ const Payload = union(Letter) {
|
||||
};
|
||||
|
||||
test "union with specified enum tag" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try doTest();
|
||||
comptime try doTest();
|
||||
}
|
||||
|
||||
test "packed union generates correctly aligned LLVM type" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage1) return error.SkipZigTest;
|
||||
|
||||
const U = packed union {
|
||||
@ -204,6 +245,10 @@ fn testComparison() !void {
|
||||
}
|
||||
|
||||
test "comparison between union and enum literal" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testComparison();
|
||||
comptime try testComparison();
|
||||
}
|
||||
@ -215,6 +260,10 @@ const TheUnion = union(TheTag) {
|
||||
C: i32,
|
||||
};
|
||||
test "cast union to tag type of union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testCastUnionToTag();
|
||||
comptime try testCastUnionToTag();
|
||||
}
|
||||
@ -225,12 +274,19 @@ fn testCastUnionToTag() !void {
|
||||
}
|
||||
|
||||
test "union field access gives the enum values" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(TheUnion.A == TheTag.A);
|
||||
try expect(TheUnion.B == TheTag.B);
|
||||
try expect(TheUnion.C == TheTag.C);
|
||||
}
|
||||
|
||||
test "cast tag type of union to union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x: Value2 = Letter2.B;
|
||||
try expect(@as(Letter2, x) == Letter2.B);
|
||||
}
|
||||
@ -242,6 +298,10 @@ const Value2 = union(Letter2) {
|
||||
};
|
||||
|
||||
test "implicit cast union to its tag type" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x: Value2 = Letter2.B;
|
||||
try expect(x == Letter2.B);
|
||||
try giveMeLetterB(x);
|
||||
@ -258,6 +318,10 @@ pub const PackThis = union(enum) {
|
||||
};
|
||||
|
||||
test "constant packed union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try testConstPackedUnion(&[_]PackThis{PackThis{ .StringLiteral = 1 }});
|
||||
}
|
||||
|
||||
@ -272,6 +336,10 @@ const MultipleChoice = union(enum(u32)) {
|
||||
D = 1000,
|
||||
};
|
||||
test "simple union(enum(u32))" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x = MultipleChoice.C;
|
||||
try expect(x == MultipleChoice.C);
|
||||
try expect(@enumToInt(@as(Tag(MultipleChoice), x)) == 60);
|
||||
@ -282,6 +350,9 @@ const PackedPtrOrInt = packed union {
|
||||
int: u64,
|
||||
};
|
||||
test "packed union size" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime try expect(@sizeOf(PackedPtrOrInt) == 8);
|
||||
}
|
||||
|
||||
@ -289,10 +360,17 @@ const ZeroBits = union {
|
||||
OnlyField: void,
|
||||
};
|
||||
test "union with only 1 field which is void should be zero bits" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime try expect(@sizeOf(ZeroBits) == 0);
|
||||
}
|
||||
|
||||
test "tagged union initialization with runtime void" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(testTaggedUnionInit({}));
|
||||
}
|
||||
|
||||
@ -309,6 +387,10 @@ fn testTaggedUnionInit(x: anytype) bool {
|
||||
pub const UnionEnumNoPayloads = union(enum) { A, B };
|
||||
|
||||
test "tagged union with no payloads" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const a = UnionEnumNoPayloads{ .B = {} };
|
||||
switch (a) {
|
||||
Tag(UnionEnumNoPayloads).A => @panic("wrong"),
|
||||
@ -317,6 +399,10 @@ test "tagged union with no payloads" {
|
||||
}
|
||||
|
||||
test "union with only 1 field casted to its enum type" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Literal = union(enum) {
|
||||
Number: f64,
|
||||
Bool: bool,
|
||||
@ -334,6 +420,9 @@ test "union with only 1 field casted to its enum type" {
|
||||
}
|
||||
|
||||
test "union with one member defaults to u0 tag type" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const U0 = union(enum) {
|
||||
X: u32,
|
||||
};
|
||||
@ -348,6 +437,10 @@ const Foo1 = union(enum) {
|
||||
var glbl: Foo1 = undefined;
|
||||
|
||||
test "global union with single field is correctly initialized" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
|
||||
@ -365,6 +458,10 @@ pub const FooUnion = union(enum) {
|
||||
var glbl_array: [2]FooUnion = undefined;
|
||||
|
||||
test "initialize global array of union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
@ -375,6 +472,10 @@ test "initialize global array of union" {
|
||||
}
|
||||
|
||||
test "update the tag value for zero-sized unions" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = union(enum) {
|
||||
U0: void,
|
||||
U1: void,
|
||||
@ -386,6 +487,10 @@ test "update the tag value for zero-sized unions" {
|
||||
}
|
||||
|
||||
test "union initializer generates padding only if needed" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const U = union(enum) {
|
||||
A: u24,
|
||||
};
|
||||
@ -395,6 +500,10 @@ test "union initializer generates padding only if needed" {
|
||||
}
|
||||
|
||||
test "runtime tag name with single field" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const U = union(enum) {
|
||||
A: i32,
|
||||
};
|
||||
@ -404,6 +513,10 @@ test "runtime tag name with single field" {
|
||||
}
|
||||
|
||||
test "method call on an empty union" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const MyUnion = union(MyUnionTag) {
|
||||
pub const MyUnionTag = enum { X1, X2 };
|
||||
@ -441,6 +554,10 @@ const FooNoVoid = union(enum) {
|
||||
const Baz = enum { A, B, C, D };
|
||||
|
||||
test "tagged union type" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const foo1 = TaggedFoo{ .One = 13 };
|
||||
const foo2 = TaggedFoo{
|
||||
.Two = Point{
|
||||
@ -460,6 +577,10 @@ test "tagged union type" {
|
||||
}
|
||||
|
||||
test "tagged union as return value" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
switch (returnAnInt(13)) {
|
||||
TaggedFoo.One => |value| try expect(value == 13),
|
||||
else => unreachable,
|
||||
@ -471,6 +592,10 @@ fn returnAnInt(x: i32) TaggedFoo {
|
||||
}
|
||||
|
||||
test "tagged union with all void fields but a meaningful tag" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
const B = union(enum) {
|
||||
c: C,
|
||||
@ -496,6 +621,9 @@ test "tagged union with all void fields but a meaningful tag" {
|
||||
|
||||
test "union(enum(u32)) with specified and unspecified tag values" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime try expect(Tag(Tag(MultipleChoice2)) == u32);
|
||||
try testEnumWithSpecifiedAndUnspecifiedTagValues(MultipleChoice2{ .C = 123 });
|
||||
@ -558,6 +686,10 @@ const PartialInstWithPayload = union(enum) {
|
||||
};
|
||||
|
||||
test "union with only 1 field casted to its enum type which has enum value specified" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const Literal = union(enum) {
|
||||
Number: f64,
|
||||
Bool: bool,
|
||||
@ -638,6 +770,10 @@ fn Setter(attr: Attribute) type {
|
||||
}
|
||||
|
||||
test "return union init with void payload" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn entry() !void {
|
||||
try expect(func().state == State.one);
|
||||
@ -948,6 +1084,9 @@ test "union enum type gets a separate scope" {
|
||||
test "global variable struct contains union initialized to non-most-aligned field" {
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const T = struct {
|
||||
const U = union(enum) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
const A = struct {
|
||||
@ -10,6 +11,9 @@ const C = struct {
|
||||
};
|
||||
|
||||
test "basic usingnamespace" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try std.testing.expect(C.B == bool);
|
||||
}
|
||||
|
||||
@ -20,6 +24,9 @@ fn Foo(comptime T: type) type {
|
||||
}
|
||||
|
||||
test "usingnamespace inside a generic struct" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const std2 = Foo(std);
|
||||
const testing2 = Foo(std.testing);
|
||||
try std2.testing.expect(true);
|
||||
@ -31,11 +38,17 @@ usingnamespace struct {
|
||||
};
|
||||
|
||||
test "usingnamespace does not redeclare an imported variable" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
comptime try std.testing.expect(@This().foo == 42);
|
||||
}
|
||||
|
||||
usingnamespace @import("usingnamespace/foo.zig");
|
||||
test "usingnamespace omits mixing in private functions" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(@This().privateFunction());
|
||||
try expect(!@This().printText());
|
||||
}
|
||||
@ -44,10 +57,16 @@ fn privateFunction() bool {
|
||||
}
|
||||
|
||||
test {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
_ = @import("usingnamespace/import_segregation.zig");
|
||||
}
|
||||
|
||||
usingnamespace @import("usingnamespace/a.zig");
|
||||
test "two files usingnamespace import each other" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(@This().ok());
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
const expect = @import("std").testing.expect;
|
||||
const builtin = @import("builtin");
|
||||
|
||||
const Foo = struct {
|
||||
a: void,
|
||||
@ -18,6 +19,9 @@ test "compare void with void compile time known" {
|
||||
}
|
||||
|
||||
test "iterate over a void slice" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var j: usize = 0;
|
||||
for (times(10)) |_, i| {
|
||||
try expect(i == j);
|
||||
@ -30,11 +34,18 @@ fn times(n: usize) []const void {
|
||||
}
|
||||
|
||||
test "void optional" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x: ?void = {};
|
||||
try expect(x != null);
|
||||
}
|
||||
|
||||
test "void array as a local variable initializer" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var x = [_]void{{}} ** 1004;
|
||||
_ = x[0];
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
|
||||
test "while loop" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
var i: i32 = 0;
|
||||
while (i < 4) {
|
||||
i += 1;
|
||||
@ -19,6 +23,9 @@ fn whileLoop2() i32 {
|
||||
}
|
||||
|
||||
test "static eval while" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
try expect(static_eval_while_number == 1);
|
||||
}
|
||||
const static_eval_while_number = staticWhileLoop1();
|
||||
@ -98,6 +105,10 @@ fn testBreakOuter() void {
|
||||
}
|
||||
|
||||
test "while copies its payload" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn doTheTest() !void {
|
||||
var tmp: ?i32 = 10;
|
||||
@ -131,6 +142,10 @@ fn runContinueAndBreakTest() !void {
|
||||
}
|
||||
|
||||
test "while with optional as condition" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
numbers_left = 10;
|
||||
var sum: i32 = 0;
|
||||
while (getNumberOrNull()) |value| {
|
||||
@ -140,6 +155,10 @@ test "while with optional as condition" {
|
||||
}
|
||||
|
||||
test "while with optional as condition with else" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
numbers_left = 10;
|
||||
var sum: i32 = 0;
|
||||
var got_else: i32 = 0;
|
||||
@ -154,6 +173,10 @@ test "while with optional as condition with else" {
|
||||
}
|
||||
|
||||
test "while with error union condition" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
numbers_left = 10;
|
||||
var sum: i32 = 0;
|
||||
var got_else: i32 = 0;
|
||||
@ -182,6 +205,10 @@ test "while on bool with else result follow break prong" {
|
||||
}
|
||||
|
||||
test "while on optional with else result follow else prong" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const result = while (returnNull()) |value| {
|
||||
break value;
|
||||
} else @as(i32, 2);
|
||||
@ -189,6 +216,10 @@ test "while on optional with else result follow else prong" {
|
||||
}
|
||||
|
||||
test "while on optional with else result follow break prong" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const result = while (returnOptional(10)) |value| {
|
||||
break value;
|
||||
} else @as(i32, 2);
|
||||
@ -215,6 +246,10 @@ fn returnTrue() bool {
|
||||
}
|
||||
|
||||
test "return with implicit cast from while loop" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
returnWithImplicitCastFromWhileLoopTest() catch unreachable;
|
||||
}
|
||||
fn returnWithImplicitCastFromWhileLoopTest() anyerror!void {
|
||||
@ -224,6 +259,10 @@ fn returnWithImplicitCastFromWhileLoopTest() anyerror!void {
|
||||
}
|
||||
|
||||
test "while on error union with else result follow else prong" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const result = while (returnError()) |value| {
|
||||
break value;
|
||||
} else |_| @as(i32, 2);
|
||||
@ -231,6 +270,10 @@ test "while on error union with else result follow else prong" {
|
||||
}
|
||||
|
||||
test "while on error union with else result follow break prong" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const result = while (returnSuccess(10)) |value| {
|
||||
break value;
|
||||
} else |_| @as(i32, 2);
|
||||
@ -253,6 +296,10 @@ test "while bool 2 break statements and an else" {
|
||||
}
|
||||
|
||||
test "while optional 2 break statements and an else" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
|
||||
const S = struct {
|
||||
fn entry(opt_t: ?bool, f: bool) !void {
|
||||
var ok = false;
|
||||
|
Loading…
Reference in New Issue
Block a user