summaryrefslogtreecommitdiff
path: root/tests/control-flow/coalesce-execution-order.vala
blob: f5404e57feb7fb2275ea13f4c59ad49b7fef9251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
string? get_foo () {
	assert (count == 0);
	return null;
}

string get_bar () {
	count++;
	assert (count == 1);
	return "bar";
}

int count;

void main () {
	count = 0;
	string? s = null;
	string foo = s ?? get_foo () ?? get_bar ();
	assert (foo == "bar");
}