|
| 1 | + |
| 2 | +// --- tests --- |
| 3 | + |
| 4 | +fn test_operations( |
| 5 | + y: i32, a: bool, b: bool, |
| 6 | + ptr: &i32, res: Result<i32, ()>) -> Result<(), ()> |
| 7 | +{ |
| 8 | + let mut x: i32; |
| 9 | + |
| 10 | + // simple assignment |
| 11 | + x = y; // $ Operation Op== Operands=2 AssignmentOperation BinaryExpr |
| 12 | + |
| 13 | + // comparison operations |
| 14 | + x == y; // $ Operation Op=== Operands=2 BinaryExpr |
| 15 | + x != y; // $ Operation Op=!= Operands=2 BinaryExpr |
| 16 | + x < y; // $ Operation Op=< Operands=2 BinaryExpr |
| 17 | + x <= y; // $ Operation Op=<= Operands=2 BinaryExpr |
| 18 | + x > y; // $ Operation Op=> Operands=2 BinaryExpr |
| 19 | + x >= y; // $ Operation Op=>= Operands=2 BinaryExpr |
| 20 | + |
| 21 | + // arithmetic operations |
| 22 | + x + y; // $ Operation Op=+ Operands=2 BinaryExpr |
| 23 | + x - y; // $ Operation Op=- Operands=2 BinaryExpr |
| 24 | + x * y; // $ Operation Op=* Operands=2 BinaryExpr |
| 25 | + x / y; // $ Operation Op=/ Operands=2 BinaryExpr |
| 26 | + x % y; // $ Operation Op=% Operands=2 BinaryExpr |
| 27 | + x += y; // $ Operation Op=+= Operands=2 AssignmentOperation BinaryExpr |
| 28 | + x -= y; // $ Operation Op=-= Operands=2 AssignmentOperation BinaryExpr |
| 29 | + x *= y; // $ Operation Op=*= Operands=2 AssignmentOperation BinaryExpr |
| 30 | + x /= y; // $ Operation Op=/= Operands=2 AssignmentOperation BinaryExpr |
| 31 | + x %= y; // $ Operation Op=%= Operands=2 AssignmentOperation BinaryExpr |
| 32 | + -x; // $ Operation Op=- Operands=1 PrefixExpr |
| 33 | + |
| 34 | + // logical operations |
| 35 | + a && b; // $ Operation Op=&& Operands=2 BinaryExpr LogicalOperation |
| 36 | + a || b; // $ Operation Op=|| Operands=2 BinaryExpr LogicalOperation |
| 37 | + !a; // $ Operation Op=! Operands=1 PrefixExpr LogicalOperation |
| 38 | + |
| 39 | + // bitwise operations |
| 40 | + x & y; // $ Operation Op=& Operands=2 BinaryExpr |
| 41 | + x | y; // $ Operation Op=| Operands=2 BinaryExpr |
| 42 | + x ^ y; // $ Operation Op=^ Operands=2 BinaryExpr |
| 43 | + x << y; // $ Operation Op=<< Operands=2 BinaryExpr |
| 44 | + x >> y; // $ Operation Op=>> Operands=2 BinaryExpr |
| 45 | + x &= y; // $ Operation Op=&= Operands=2 AssignmentOperation BinaryExpr |
| 46 | + x |= y; // $ Operation Op=|= Operands=2 AssignmentOperation BinaryExpr |
| 47 | + x ^= y; // $ Operation Op=^= Operands=2 AssignmentOperation BinaryExpr |
| 48 | + x <<= y; // $ Operation Op=<<= Operands=2 AssignmentOperation BinaryExpr |
| 49 | + x >>= y; // $ Operation Op=>>= Operands=2 AssignmentOperation BinaryExpr |
| 50 | + |
| 51 | + // miscellaneous expressions that might be operations |
| 52 | + *ptr; // $ Operation Op=* Operands=1 PrefixExpr |
| 53 | + &x; // $ RefExpr |
| 54 | + res?; |
| 55 | + |
| 56 | + return Ok(()); |
| 57 | +} |
0 commit comments