mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 22:04:21 +00:00
- implements `airSlice`, `airBitAnd`, `airBitOr`, `airShr`. - got a basic design going for the `airErrorName` but for some reason it simply returns empty bytes. will investigate further. - only generating `.got.zig` entries when not compiling an object or shared library - reduced the total amount of ops a mnemonic can have to 3, simplifying the logic
66 lines
1.4 KiB
Zig
66 lines
1.4 KiB
Zig
const builtin = @import("builtin");
|
|
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
test "switch on empty enum" {
|
|
const E = enum {};
|
|
var e: E = undefined;
|
|
_ = &e;
|
|
switch (e) {}
|
|
}
|
|
|
|
test "switch on empty enum with a specified tag type" {
|
|
const E = enum(u8) {};
|
|
var e: E = undefined;
|
|
_ = &e;
|
|
switch (e) {}
|
|
}
|
|
|
|
test "switch on empty auto numbered tagged union" {
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
|
|
|
const U = union(enum(u8)) {};
|
|
var u: U = undefined;
|
|
_ = &u;
|
|
switch (u) {}
|
|
}
|
|
|
|
test "switch on empty tagged union" {
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
|
|
|
const E = enum {};
|
|
const U = union(E) {};
|
|
var u: U = undefined;
|
|
_ = &u;
|
|
switch (u) {}
|
|
}
|
|
|
|
test "empty union" {
|
|
const U = union {};
|
|
try expect(@sizeOf(U) == 0);
|
|
try expect(@alignOf(U) == 1);
|
|
}
|
|
|
|
test "empty extern union" {
|
|
const U = extern union {};
|
|
try expect(@sizeOf(U) == 0);
|
|
try expect(@alignOf(U) == 1);
|
|
}
|
|
|
|
test "empty union passed as argument" {
|
|
const U = union(enum) {
|
|
fn f(u: @This()) void {
|
|
switch (u) {}
|
|
}
|
|
};
|
|
U.f(@as(U, undefined));
|
|
}
|
|
|
|
test "empty enum passed as argument" {
|
|
const E = enum {
|
|
fn f(e: @This()) void {
|
|
switch (e) {}
|
|
}
|
|
};
|
|
E.f(@as(E, undefined));
|
|
}
|