v2 / vlib / v / tests / global_fixed_arr_init_test.v
48 lines · 41 sloc · 725 bytes · 66946738fbcdad4ce810a04a868b4d0f05cf55b2
Raw
1@[has_globals]
2module main
3
4type Mat4 = [16]f32
5
6pub fn mat4(x0 f32, x1 f32, x2 f32, x3 f32, x4 f32, x5 f32, x6 f32, x7 f32, x8 f32, x9 f32, x10 f32, x11 f32, x12 f32, x13 f32, x14 f32, x15 f32) Mat4 {
7 return [
8 x0,
9 x1,
10 x2,
11 x3,
12 x4,
13 x5,
14 x6,
15 x7,
16 x8,
17 x9,
18 x10,
19 x11,
20 x12,
21 x13,
22 x14,
23 x15,
24 ]!
25}
26
27pub fn unit_m4() Mat4 {
28 return mat4(f32(1), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
29}
30
31struct GameObject {
32mut:
33 rot Mat4 = unit_m4()
34 transform Mat4 = [f32(1), 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]!
35}
36
37__global (
38 p GameObject
39)
40
41fn test_main() {
42 println(p)
43 assert p.rot[0] == f32(1)
44 assert p.rot[15] == f32(1)
45
46 assert p.transform[0] == f32(1)
47 assert p.transform[15] == f32(1)
48}
49