aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/align.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-01-17 18:52:53 +0100
committerJakub Konka <kubkon@jakubkonka.com>2022-01-17 20:24:14 +0100
commit9b715cb46250cbdd610f081b976b2e161df57218 (patch)
treea7abebac48b64772c079a8ccf81d093f37eeb2fa /test/behavior/align.zig
parent79628d48a4429818bddef2e86e2d7073d1955302 (diff)
downloadzig-9b715cb46250cbdd610f081b976b2e161df57218.tar.gz
zig-9b715cb46250cbdd610f081b976b2e161df57218.zip
stage2: implement airArrayToSlice for x86_64
* implement `genSetStack` for `ptr_stack_offset` * handle `ptr_add` * implement storing from register into pointer in register * split alignment and array tests into those that pass on x86_64 and those that do not * pass more tests on x86_64
Diffstat (limited to 'test/behavior/align.zig')
-rw-r--r--test/behavior/align.zig95
1 files changed, 0 insertions, 95 deletions
diff --git a/test/behavior/align.zig b/test/behavior/align.zig
index 77d2eea6a8..0fa96acc6d 100644
--- a/test/behavior/align.zig
+++ b/test/behavior/align.zig
@@ -3,36 +3,6 @@ const expect = std.testing.expect;
const builtin = @import("builtin");
const native_arch = builtin.target.cpu.arch;
-var foo: u8 align(4) = 100;
-
-test "global variable alignment" {
- comptime try expect(@typeInfo(@TypeOf(&foo)).Pointer.alignment == 4);
- comptime try expect(@TypeOf(&foo) == *align(4) u8);
- {
- const slice = @as(*[1]u8, &foo)[0..];
- comptime try expect(@TypeOf(slice) == *align(4) [1]u8);
- }
- {
- var runtime_zero: usize = 0;
- const slice = @as(*[1]u8, &foo)[runtime_zero..];
- comptime try expect(@TypeOf(slice) == []align(4) u8);
- }
-}
-
-test "default alignment allows unspecified in type syntax" {
- try expect(*u32 == *align(@alignOf(u32)) u32);
-}
-
-test "implicitly decreasing pointer alignment" {
- const a: u32 align(4) = 3;
- const b: u32 align(8) = 4;
- try expect(addUnaligned(&a, &b) == 7);
-}
-
-fn addUnaligned(a: *align(1) const u32, b: *align(1) const u32) u32 {
- return a.* + b.*;
-}
-
test "implicitly decreasing slice alignment" {
const a: u32 align(4) = 3;
const b: u32 align(8) = 4;
@@ -42,18 +12,6 @@ fn addUnalignedSlice(a: []align(1) const u32, b: []align(1) const u32) u32 {
return a[0] + b[0];
}
-test "@alignCast pointers" {
- var x: u32 align(4) = 1;
- expectsOnly1(&x);
- try expect(x == 2);
-}
-fn expectsOnly1(x: *align(1) u32) void {
- expects4(@alignCast(4, x));
-}
-fn expects4(x: *align(4) u32) void {
- x.* += 1;
-}
-
test "specifying alignment allows pointer cast" {
try testBytesAlign(0x33);
}
@@ -76,62 +34,9 @@ fn sliceExpects4(slice: []align(4) u32) void {
slice[0] += 1;
}
-test "alignment of structs" {
- try expect(@alignOf(struct {
- a: i32,
- b: *i32,
- }) == @alignOf(usize));
-}
-
test "return error union with 128-bit integer" {
try expect(3 == try give());
}
fn give() anyerror!u128 {
return 3;
}
-
-test "alignment of >= 128-bit integer type" {
- try expect(@alignOf(u128) == 16);
- try expect(@alignOf(u129) == 16);
-}
-
-test "alignment of struct with 128-bit field" {
- try expect(@alignOf(struct {
- x: u128,
- }) == 16);
-
- comptime {
- try expect(@alignOf(struct {
- x: u128,
- }) == 16);
- }
-}
-
-test "size of extern struct with 128-bit field" {
- try expect(@sizeOf(extern struct {
- x: u128,
- y: u8,
- }) == 32);
-
- comptime {
- try expect(@sizeOf(extern struct {
- x: u128,
- y: u8,
- }) == 32);
- }
-}
-
-test "@ptrCast preserves alignment of bigger source" {
- var x: u32 align(16) = 1234;
- const ptr = @ptrCast(*u8, &x);
- try expect(@TypeOf(ptr) == *align(16) u8);
-}
-
-test "alignstack" {
- try expect(fnWithAlignedStack() == 1234);
-}
-
-fn fnWithAlignedStack() i32 {
- @setAlignStack(256);
- return 1234;
-}