summaryrefslogtreecommitdiff
path: root/tests/control-flow/bug691514.vala
blob: 4f60c77028f76cbc4ac4b52a256c890175dcb82c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public string[] test() throws Error {
	return { null, "1" };
}

void main() {
	string t = (true ? "1" : "2") ?? "3";
	assert (t == "1");

	t = (false ? "1" : "2") ?? "3";
	assert (t == "2");

	t = (true ? null : "2") ?? "3";
	assert (t == "3");

	t = (false ? "1" : null) ?? "3";
	assert (t == "3");

	t = test()[0] ?? "2";
	assert (t == "2");

	t = test()[1] ?? "2";
	assert (t == "1");
}