blob: e18ea2e9d785c48960aded2357275a6936b5604d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
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
---
|