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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
name: integer-base-err-1
description:
Can't have 0 base (causes shell to exit)
expected-exit: e != 0
stdin:
typeset -i i
i=3
i=0#4
echo $i
expected-stderr-pattern:
/^.*:.*0#4.*\n$/
---
name: integer-base-err-2
description:
Can't have multiple bases in a `constant' (causes shell to exit)
(ksh88 fails this test)
expected-exit: e != 0
stdin:
typeset -i i
i=3
i=2#110#11
echo $i
expected-stderr-pattern:
/^.*:.*2#110#11.*\n$/
---
name: integer-base-err-3
description:
Syntax errors in expressions and effects on bases
(interactive so errors don't cause exits)
(ksh88 fails this test - shell exits, even with -i)
arguments: !-i!
stdin:
PS1= # minimize prompt hassles
typeset -i4 a=10
typeset -i a=2+
echo $a
typeset -i4 a=10
typeset -i2 a=2+
echo $a
expected-stderr-pattern:
/^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
expected-stdout:
4#22
4#22
---
name: integer-base-err-4
description:
Are invalid digits (according to base) errors?
(ksh93 fails this test)
expected-exit: e != 0
stdin:
typeset -i i;
i=3#4
expected-stderr-pattern:
/^([#\$] )?.*:.*3#4.*\n$/
---
name: integer-base-1
description:
Missing number after base is treated as 0.
stdin:
typeset -i i
i=3
i=2#
echo $i
expected-stdout:
0
---
name: integer-base-2
description:
Check `stickyness' of base in various situations
stdin:
typeset -i i=8
echo $i
echo ---------- A
typeset -i4 j=8
echo $j
echo ---------- B
typeset -i k=8
typeset -i4 k=8
echo $k
echo ---------- C
typeset -i4 l
l=3#10
echo $l
echo ---------- D
typeset -i m
m=3#10
echo $m
echo ---------- E
n=2#11
typeset -i n
echo $n
n=10
echo $n
echo ---------- F
typeset -i8 o=12
typeset -i4 o
echo $o
echo ---------- G
typeset -i p
let p=8#12
echo $p
expected-stdout:
8
---------- A
4#20
---------- B
4#20
---------- C
4#3
---------- D
3#10
---------- E
2#11
2#1010
---------- F
4#30
---------- G
8#12
---
name: integer-base-3
description:
More base parsing (hmm doesn't test much..)
stdin:
typeset -i aa
aa=1+12#10+2
echo $aa
typeset -i bb
bb=1+$aa
echo $bb
typeset -i bb
bb=$aa
echo $bb
typeset -i cc
cc=$aa
echo $cc
expected-stdout:
15
16
15
15
---
name: integer-base-4
description:
Check that things not declared as integers are not made integers,
also, check if base is not reset by -i with no arguments.
(ksh93 fails - prints 10#20 - go figure)
stdin:
xx=20
let xx=10
typeset -i | grep '^xx='
typeset -i4 a=10
typeset -i a=20
echo $a
expected-stdout:
4#110
---
name: integer-base-5
description:
More base stuff
stdin:
typeset -i4 a=3#10
echo $a
echo --
typeset -i j=3
j=~3
echo $j
echo --
typeset -i k=1
x[k=k+1]=3
echo $k
echo --
typeset -i l
for l in 1 2+3 4; do echo $l; done
expected-stdout:
4#3
--
-4
--
2
--
1
5
4
---
name: integer-base-6
description:
Even more base stuff
(ksh93 fails this test - prints 0)
stdin:
typeset -i7 i
i=
echo $i
expected-stdout:
7#0
---
name: integer-base-7
description:
Check that non-integer parameters don't get bases assigned
stdin:
echo $(( zz = 8#100 ))
echo $zz
expected-stdout:
64
64
---
|