//! returns: 0 //! Nested boolean expressions preserve operand order and skipped effects. /// Append the operand's position to the evaluation trace. fn operand(trace: &mut u32, position: u32, value: bool) -> bool { set *trace = *trace * 10 + position; return value; } /// Check both nested operator orders for every input combination. @default fn main() -> u32 { for bits in 0..8 { let a = bits & 1 <> 0; let b = bits & 2 <> 0; let c = bits & 4 <> 0; let mut trace: u32 = 0; let first = operand(&mut trace, 1, a) and (operand(&mut trace, 2, b) or operand(&mut trace, 3, c)); assert first == (a and (b or c)); assert trace == (1 if not a else 12 if b else 123); set trace = 0; let second = operand(&mut trace, 1, a) or (operand(&mut trace, 2, b) and operand(&mut trace, 3, c)); assert second == (a or (b and c)); assert trace == (1 if a else 12 if not b else 123); } return 0; }