To check the final result, to make sure that conditions and actions are correctly associated, we can use a truth table
if test_1 then statement(s)_1; elsif test_2 then statement(s)_2; elsif test_3 then statement(s)_3; else statement(s)_4; end if;
test_1 | test_2 | test_3 | s_1 | s_2 | s_3 | s_4 |
---|---|---|---|---|---|---|
F | F | F | * | |||
F | F | T | * | |||
F | T | F | * | |||
F | T | T | * | |||
T | F | F | * | |||
T | F | T | * | |||
T | T | F | * | |||
T | T | T | * |
if test_1 then if test_2 then statement(s)_1; else statement(s)_2; end if; else if test_3 then statement(s)_3; else statement(s)_4; end if; end if;
test_1 | test_2 | test_3 | s_1 | s_2 | s_3 | s_4 |
---|---|---|---|---|---|---|
F | F | F | * | |||
F | F | T | * | |||
F | T | F | * | |||
F | T | T | * | |||
T | F | F | * | |||
T | F | T | * | |||
T | T | F | * | |||
T | T | T | * |