summaryrefslogtreecommitdiff
path: root/tests/semantic/assignment-element-getter-setter.vala
blob: 8399dc0d6b75c3dc8f0ab0bbfd2f95f0ed65150c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
[Compact]
public class Foo<G> {
	public G[] elements;

	public Foo () {
		elements = new G[] { null };
	}

	public G get (int idx) {
		return elements[idx];
	}

	public void set (int idx, G val) {
		elements[idx] = val;
	}
}

void main () {
	var foo = new Foo<int> ();

	foo[0] = 23;
	assert (foo[0] == 23);

	foo[0] += 42;
	assert (foo[0] == 65);

	foo[0] *= 2;
	assert (foo[0] == 130);

	foo[0] /= 5;
	assert (foo[0] == 26);

	foo[0] -= 4711;
	assert (foo[0] == -4685);
}