Merge pull request #10906 from topolarity/cbe-array-support
stage2 CBE: Implement 2D array support
This commit is contained in:
@@ -436,6 +436,38 @@ test "array 2D const double ptr" {
|
||||
try testArray2DConstDoublePtr(&rect_2d_vertexes[0][0]);
|
||||
}
|
||||
|
||||
test "array 2D const double ptr with offset" {
|
||||
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;
|
||||
|
||||
const rect_2d_vertexes = [_][2]f32{
|
||||
[_]f32{ 3.0, 4.239 },
|
||||
[_]f32{ 1.0, 2.0 },
|
||||
};
|
||||
try testArray2DConstDoublePtr(&rect_2d_vertexes[1][0]);
|
||||
}
|
||||
|
||||
test "array 3D const double ptr with offset" {
|
||||
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_3d_vertexes = [_][2][2]f32{
|
||||
[_][2]f32{
|
||||
[_]f32{ 3.0, 4.239 },
|
||||
[_]f32{ 3.5, 7.2 },
|
||||
},
|
||||
[_][2]f32{
|
||||
[_]f32{ 3.0, 4.239 },
|
||||
[_]f32{ 1.0, 2.0 },
|
||||
},
|
||||
};
|
||||
try testArray2DConstDoublePtr(&rect_3d_vertexes[1][1][0]);
|
||||
}
|
||||
|
||||
fn testArray2DConstDoublePtr(ptr: *const f32) !void {
|
||||
const ptr2 = @ptrCast([*]const f32, ptr);
|
||||
try expect(ptr2[0] == 1.0);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
const mem = std.mem;
|
||||
|
||||
@@ -12,6 +13,10 @@ fn initStaticArray() [10]i32 {
|
||||
}
|
||||
const static_array = initStaticArray();
|
||||
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;
|
||||
|
||||
try expect(static_array[0] == 1);
|
||||
try expect(static_array[4] == 2);
|
||||
try expect(static_array[7] == 3);
|
||||
|
||||
Reference in New Issue
Block a user