v2 / vlib / v / tests / aliases / alias_with_op_overloading_test.v
22 lines · 18 sloc · 290 bytes · 19a7fbcf28b7ab9cf87a4ab7e45f0b08014cbe83
Raw
1module main
2
3import math.vec
4
5type Vector3 = vec.Vec3[f32]
6
7pub fn calc(a Vector3, b Vector3) Vector3 {
8 f := a.normalize()
9 return f * a + a * f
10}
11
12fn test_main() {
13 a := Vector3{
14 x: 1
15 y: 2
16 z: 3
17 }
18 t := calc(a, a)
19 assert int(t.x) == 0
20 assert int(t.y) == 2
21 assert int(t.z) == 4
22}
23