79 lines
1.2 KiB
Raku
79 lines
1.2 KiB
Raku
name: arith-lazy-1
|
|
description:
|
|
Check that only one side of ternary operator is evaluated
|
|
stdin:
|
|
x=i+=2
|
|
y=j+=2
|
|
typeset -i i=1 j=1
|
|
echo $((1 ? 20 : (x+=2)))
|
|
echo $i,$x
|
|
echo $((0 ? (y+=2) : 30))
|
|
echo $j,$y
|
|
expected-stdout:
|
|
20
|
|
1,i+=2
|
|
30
|
|
1,j+=2
|
|
---
|
|
|
|
name: arith-lazy-2
|
|
description:
|
|
Check that assignments not done on non-evaluated side of ternary
|
|
operator
|
|
stdin:
|
|
x=i+=2
|
|
y=j+=2
|
|
typeset -i i=1 j=1
|
|
echo $((1 ? 20 : (x+=2)))
|
|
echo $i,$x
|
|
echo $((0 ? (y+=2) : 30))
|
|
echo $i,$y
|
|
expected-stdout:
|
|
20
|
|
1,i+=2
|
|
30
|
|
1,j+=2
|
|
---
|
|
|
|
name: arith-ternary-prec-1
|
|
description:
|
|
Check precidance of ternary operator vs assignment
|
|
stdin:
|
|
typeset -i x=2
|
|
y=$((1 ? 20 : x+=2))
|
|
expected-exit: e != 0
|
|
expected-stderr-pattern:
|
|
/.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
|
|
---
|
|
|
|
name: arith-ternary-prec-2
|
|
description:
|
|
Check precidance of ternary operator vs assignment
|
|
stdin:
|
|
typeset -i x=2
|
|
echo $((0 ? x+=2 : 20))
|
|
expected-stdout:
|
|
20
|
|
---
|
|
|
|
name: arith-div-assoc-1
|
|
description:
|
|
Check associativity of division operator
|
|
stdin:
|
|
echo $((20 / 2 / 2))
|
|
expected-stdout:
|
|
5
|
|
---
|
|
|
|
name: arith-assop-assoc-1
|
|
description:
|
|
Check associativity of assignment-operator operator
|
|
stdin:
|
|
typeset -i i=1 j=2 k=3
|
|
echo $((i += j += k))
|
|
echo $i,$j,$k
|
|
expected-stdout:
|
|
6
|
|
6,5,3
|
|
---
|