1#unittest {
2	name: "Vector class.";
3	result: 69;
4};
5
6class Vector {
7	public var x=0;
8	public var y=0;
9	public var z=0;
10
11	public func init (a, b, c) {
12		if (!a) a = 0;
13		if (!b) b = 0;
14		if (!c) c = 0;
15		x = a; y = b; z = c;
16	}
17
18	public func + (v) {
19		if (v is Int) {
20			return Vector(x+v, y+v, z+v);
21		} else if (v is Vector) {
22			return Vector(x+v.x, y+v.y, z+v.z);
23		}
24		return null;
25	}
26
27	public func - (v) {
28		if (v is Int) {
29			return Vector(x-v, y-v, z-v);
30		} else if (v is Vector) {
31			return Vector(x-v.x, y-v.y, z-v.z);
32		}
33		return null;
34	}
35
36	public func * (v) {
37		if (v is Int) {
38			return Vector(x*v, y*v, z*v);
39		} else if (v is Vector) {
40			return Vector(x*v.x, y*v.y, z*v.z);
41		}
42		return null;
43	}
44
45	public func / (v) {
46		if (v is Int) {
47			return Vector(x/v, y/v, z/v);
48		} else if (v is Vector) {
49			return Vector(x/v.x, y/v.y, z/v.z);
50		}
51		return null;
52	}
53
54	public func neg() {
55		return Vector(-x, -y, -z);
56	}
57
58	public func sum() {
59		return x+y+z;
60	}
61
62	public func String() {
63		return "[" + x.String() + "," + y.String() + "," + z.String() + "]";
64	}
65}
66
67func main() {
68	var v1 = Vector(1,2,3);		// 1,2,3 (6)
69	var v2 = Vector(4,5,6);		// 4,5,6 (15)
70	var v3 = v1 + v2;			// 5,7,9
71	var v4 = v2 - v1;			// 3,3,3
72	var v5 = -v4;				// -3,-3,-3
73	var v6 = v4 / v5;			// -1,-1,-1
74	var v7 = v3 + v6;			// 4,6,8 (18)
75	var v8 = v4 * v1;			// 3,6,9 (18)
76	var v9 = v1 + 2;			// 3,4,5 (12)
77
78	// just trigger this code in order in order to trigger internal test
79	var test = v9.String();
80	if (test != "[3,4,5]") return false;
81
82	return v1.sum() + v2.sum() + v7.sum() + v8.sum() + v9.sum();
83}