Undefined decision examples

De Software testing
Ir para: navegação, pesquisa

Consider the following sequence of statements:

bool foo(int a_parameter) {
	while (true) { //An infinite loop
		a_parameter = 0;
	}
}

if (x < y and foo(y)) {
	compute(x, y);
}

The condition inside the if statement on line 6 will remain undefined because the loop at lines 2-4 will never end. Thus, the decision on line 7 evaluates to undefined.

References

  • <bib>mathur:2008, 419</bib>