mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
add tests for fixed stage1 bugs
Closes #10357 Closes #11236 Closes #11615 Closes #12055
This commit is contained in:
parent
0588595128
commit
60614b2a85
@ -930,6 +930,16 @@ test "optional error set return type" {
|
||||
try expect(E.A == S.foo(false).?);
|
||||
}
|
||||
|
||||
test "optional error set function parameter" {
|
||||
const S = struct {
|
||||
fn doTheTest(a: ?anyerror) !void {
|
||||
try std.testing.expect(a.? == error.OutOfMemory);
|
||||
}
|
||||
};
|
||||
try S.doTheTest(error.OutOfMemory);
|
||||
try comptime S.doTheTest(error.OutOfMemory);
|
||||
}
|
||||
|
||||
test "returning an error union containing a type with no runtime bits" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
|
13
test/cases/compile_errors/error_union_field_default_init.zig
Normal file
13
test/cases/compile_errors/error_union_field_default_init.zig
Normal file
@ -0,0 +1,13 @@
|
||||
const Input = struct {
|
||||
value: u32 = @as(error{}!u32, 0),
|
||||
};
|
||||
export fn foo() void {
|
||||
var x: Input = Input{};
|
||||
_ = &x;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
//:2:18: error: expected type 'u32', found 'error{}!u32'
|
||||
//:2:18: note: cannot convert error union to payload type
|
||||
//:2:18: note: consider using 'try', 'catch', or 'if'
|
16
test/cases/compile_errors/type_error_union_field_type.zig
Normal file
16
test/cases/compile_errors/type_error_union_field_type.zig
Normal file
@ -0,0 +1,16 @@
|
||||
fn CreateType() !type {
|
||||
return struct {};
|
||||
}
|
||||
const MyType = CreateType();
|
||||
const TestType = struct {
|
||||
my_type: MyType,
|
||||
};
|
||||
comptime {
|
||||
_ = @sizeOf(TestType) + 1;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
//:6:14: error: expected type 'type', found 'error{}!type'
|
||||
//:6:14: note: cannot convert error union to payload type
|
||||
//:6:14: note: consider using 'try', 'catch', or 'if'
|
17
test/cases/translate_c/align() attribute.c
Normal file
17
test/cases/translate_c/align() attribute.c
Normal file
@ -0,0 +1,17 @@
|
||||
__attribute__ ((aligned(128)))
|
||||
extern char my_array[16];
|
||||
__attribute__ ((aligned(128)))
|
||||
void my_fn(void) { }
|
||||
void other_fn(void) {
|
||||
char ARR[16] __attribute__ ((aligned (16)));
|
||||
}
|
||||
|
||||
// translate-c
|
||||
// c_frontend=clang
|
||||
//
|
||||
// pub extern var my_array: [16]u8 align(128);
|
||||
// pub export fn my_fn() align(128) void {}
|
||||
// pub export fn other_fn() void {
|
||||
// var ARR: [16]u8 align(16) = undefined;
|
||||
// _ = &ARR;
|
||||
// }
|
@ -764,27 +764,6 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
|
||||
\\};
|
||||
});
|
||||
|
||||
// Test case temporarily disabled:
|
||||
// https://github.com/ziglang/zig/issues/12055
|
||||
if (false) {
|
||||
cases.add("align() attribute",
|
||||
\\__attribute__ ((aligned(128)))
|
||||
\\extern char my_array[16];
|
||||
\\__attribute__ ((aligned(128)))
|
||||
\\void my_fn(void) { }
|
||||
\\void other_fn(void) {
|
||||
\\ char ARR[16] __attribute__ ((aligned (16)));
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
\\pub extern var my_array: [16]u8 align(128);
|
||||
\\pub export fn my_fn() align(128) void {}
|
||||
\\pub export fn other_fn() void {
|
||||
\\ var ARR: [16]u8 align(16) = undefined;
|
||||
\\ _ = &ARR;
|
||||
\\}
|
||||
});
|
||||
}
|
||||
|
||||
cases.add("linksection() attribute",
|
||||
\\// Use the "segment,section" format to make this test pass when
|
||||
\\// targeting the mach-o binary format
|
||||
|
Loading…
Reference in New Issue
Block a user