Lines Matching defs:err_exit

20 function err_exit
26 alias err_exit='err_exit $LINENO'
31 tmp=$(mktemp -dt) || { err_exit mktemp -dt failed; exit 1; }
38 then err_exit 2+2!=4
41 then err_exit x+y!=z
44 then err_exit $x+$y!=$z
47 then err_exit "(x|y)!=z"
50 then err_exit "y>=z"
53 then err_exit "y+3!=z+2"
56 then err_exit "y<<2!=1<<3"
59 then err_exit "133%10!=3"
61 then err_exit 2.5!=2.5
65 ((d || 1)) || err_exit 'd=0; ((d||1))'
67 then err_exit "d++!=0"
70 then err_exit "--d!=0"
73 then err_exit '(d++,6)!=6 && d!=1'
77 then err_exit '(1?2+1:3*4+d++) !=3'
83 then err_exit 'for (( expr)) failed'
87 then err_exit 'for (( expr));... failed'
91 then err_exit 'for (( expr))... failed'
94 then err_exit '(( (i?0:1) )) failed'
97 then err_exit '( (1 || 1 && 0) != 1) failed'
100 then err_exit '(_=1)+(_x=0)-_ failed'
103 then err_exit '((3^6) != 5) failed'
107 then err_exit '(x=-x) != -1 failed'
111 then err_exit ' 1$(($i))3 failed'
120 then err_exit 'cos*cos +sin*sin > 1.01'
123 then err_exit 'cos*cos +sin*sin < .99'
126 then err_exit 'typecast not working in arithmetic evaluation'
131 then err_exit 'postincrement of floating point allowed'
135 then err_exit 'preincrement of floating point allowed'
140 then err_exit 'floating point allowed with % operator'
144 then err_exit '(( 4 * x/2 )) is not 0.25, with x=.125'
147 then err_exit '$(( pow(2,3) )) != 8'
151 then err_exit '$(( pow(2,(3)) )) != 8'
156 then err_exit 'two consecutive integer x=1 not working'
161 then err_exit "typeset -RZ2 leading 0 decimal not working [z=$z]"
165 then err_exit "typeset -RZ3 leading 0 decimal not working [z=$z]"
171 then err_exit "leading 0's in -Z not treated as decimal"
176 then err_exit "+= not working"
181 then err_exit "*= not working"
185 then err_exit "%= not working"
189 then err_exit "|= not working"
193 then err_exit "&= not working"
203 then err_exit "arithmetic using wrong scope"
209 then err_exit "constant index array arithmetic failure"
213 then err_exit "empty constant index array arithmetic failure"
217 then err_exit "variable subscript index array arithmetic failure"
222 then err_exit "nested subscript index array arithmetic failure"
231 then err_exit "constant associative array arithmetic failure"
235 then err_exit "variable subscript associative array arithmetic failure"
237 $SHELL -nc '((a = 1))' 2> /dev/null || err_exit "sh -n fails with arithmetic"
238 $SHELL -nc '((a.b++))' 2> /dev/null || err_exit "sh -n fails with arithmetic2"
242 then err_exit '% not working on floating point'
252 then err_exit "(( '${chr[i]}' != ${val[i]} ))"
255 then err_exit "(( '${chr[i]}' )) != ${val[i]}"
258 then err_exit "(( '${chr[i]}' )) != ${val[i]}"
261 then err_exit "eval (( '${chr[i]}' != ${val[i]} ))"
264 then err_exit "eval (( '${chr[i]}' != ${val[i]} ))"
269 [[ $x != 4294967293 ]] && err_exit "unsigned integers not working"
272 [[ $x != 32768 ]] && err_exit "unsigned integer addition not working"
276 then err_exit 'large integer constants not working'
287 then err_exit 'name references in arithmetic statements in functions broken'
290 then err_exit '2**3 not working'
293 then err_exit '2**3*2 not working'
296 then err_exit '4**3**2 not working'
299 then err_exit '(4**3)**2 not working'
304 then err_exit '-Z3 not treated as decimal'
308 (( x >= 0 )) || err_exit 'unsigned integer not working'
309 (( $x >= 0 )) || err_exit 'unsigned integer not working as $x'
313 then err_exit 'display of unsigned integers in non-decimal bases wrong'
315 $SHELL -c 'i=0;(( ofiles[i] != -1 && (ofiles[i] < mins || mins == -1) ));exit 0' 2> /dev/null || err_exit 'lexical error with arithemtic expression'
316 $SHELL -c '(( +1 == 1))' 2> /dev/null || err_exit 'unary + not working'
318 [[ $val == 123.0123456789 ]] || err_exit "rounding error val=$val"
320 then err_exit 'parsing error with x$((10))=foo'
322 $SHELL -c 'typeset x$((10))=foo' 2> /dev/null || err_exit 'typeset x$((10)) parse error'
325 (( x > 1.999 && x < 2.001 )) || err_exit 'composite functions not working'
333 (( x == n )) || err_exit 'let with zero filled fields not working'
334 (( y == n )) || err_exit '((...)) with zero filled fields not working'
336 [[ $(($x)) == 10 && $((1$x)) == 1010 ]] || err_exit 'zero filled fields not preserving leading zeros'
338 [[ $(let y=$x;print $y) == 10 && $(let y=1$x;print $y) == 1010 ]] || err_exit 'zero filled fields not preserving leading zeros with let'
349 (( ipx != hex[3-i] )) && err_exit "hex digit $((3-i)) not correct"
353 (( x == 8 )) || err_exit 'leading zeros not treated as octal arithmetic'
354 (( $x == 8 )) || err_exit 'leading zeros not treated as octal arithmetic with $x'
357 (( x == 10 )) || err_exit 'leading zeros not ignored for arithmetic'
358 (( $x == 10 )) || err_exit 'leading zeros not ignored for arithmetic with $x'
360 (( i == 10 )) || err_exit 'leading zeros not ignored for arithmetic assignment'
361 (( ${x:0:1} == 0 )) || err_exit 'leading zero should not be stripped for x:a:b'
363 (( c$x == 3 )) || err_exit 'leading zero with variable should not be stripped'
364 [[ $( ($SHELL -c '((++1))' 2>&1)2>/dev/null ) == *lvalue* ]] || err_exit "((++1)) not generating error message"
366 (( "22" == 22 )) || err_exit "double quoted constants fail"
367 (( "2$i" == 22 )) || err_exit "double quoted variables fail"
368 (( "18+$i+2" == 22 )) || err_exit "double quoted expressions fail"
371 (( i == -1 )) || err_exit "01-2 is not -1"
420 [[ $($tmp/script 1) != '( bar=2 baz=3 foo=1 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
421 [[ $($tmp/script 2) != '( faz=0 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
422 [[ $($tmp/script 3) != '( foz=777 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
423 [[ $($tmp/script 4) != '( foz=777 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
424 [[ $($tmp/script 5) != '( fuz=777 )' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
425 [[ $($tmp/script 6) != '0' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
426 [[ $($tmp/script 7) != '0' ]] 2>/dev/null && err_exit 'compound var arithmetic failed'
429 [[ $foo == 123456789.2 ]] || err_exit 'typeset -F1 not working correctly'
434 do [[ $( ( $SHELL -c "( (($expr)) ) || print ok" ) 2>/dev/null ) == ok ]] || err_exit "divide by zero not trapped: $expr"
438 do [[ $( ( $SHELL -c "( print -r -- \$(($expr)) )" ) 2>/dev/null ) == 2 ]] || err_exit "invalid value for: $expr"
440 [[ $((5||0)) == 1 ]] || err_exit '$((5||0))'" == $((5||0)) should be 1"
441 $SHELL -c 'integer x=3 y=2; (( (y += x += 2) == 7 && x==5))' 2> /dev/null || err_exit '((y += x += 2)) not working'
442 $SHELL -c 'b=0; [[ $((b?a=1:b=9)) == 9 ]]' 2> /dev/null || err_exit 'b?a=1:b=9 not working'
445 [[ $x == "$((x))" ]] || err_exit '$x !- $((x)) when x is pi'
446 $SHELL -c "[[ ${x//./} == {14,100}(\d) ]]" 2> /dev/null || err_exit 'pi has less than 14 significant places'
456 [[ $x == $2 ]] || err_exit "printf '%g\\n' \$(($1)) failed -- expected $2, got $x"
458 [[ $x == $2 ]] || err_exit "printf '%g\\n' $1 failed -- expected $2, got $x"
460 [[ $x == $2 ]] || err_exit "print -- \$(($1)) failed -- expected $2, got $x"
463 (( 1.0/0.0 == Inf )) || err_exit '1.0/0.0 != Inf'
464 [[ $(print -- $((0.0/0.0))) == ?(-)nan ]] || err_exit '0.0/0.0 != NaN'
465 (( Inf*Inf == Inf )) || err_exit 'Inf*Inf != Inf'
466 (( NaN != NaN )) || err_exit 'NaN == NaN'
467 (( -5*Inf == -Inf )) || err_exit '-5*Inf != -Inf'
468 [[ $(print -- $((sqrt(-1.0)))) == ?(-)nan ]]|| err_exit 'sqrt(-1.0) != NaN'
469 (( pow(1.0,Inf) == 1.0 )) || err_exit 'pow(1.0,Inf) != 1.0'
470 (( pow(Inf,0.0) == 1.0 )) || err_exit 'pow(Inf,0.0) != 1.0'
471 [[ $(print -- $((NaN/Inf))) == ?(-)nan ]] || err_exit 'NaN/Inf != NaN'
472 (( 4.0/Inf == 0.0 )) || err_exit '4.0/Inf != 0.0'
473 else err_exit 'Inf and NaN not working'
480 [[ $r == $n ]] || err_exit "output of printf %a not self preserving -- expected $x, got $y"
485 [[ $y == "$r" ]] || err_exit "-0 vs -0.0 inconsistency -- expected '$r', got '$y'"
486 $SHELL -c '(( x=));:' 2> /dev/null && err_exit '((x=)) should be an error'
487 $SHELL -c '(( x+=));:' 2> /dev/null && err_exit '((x+=)) should be an error'
488 $SHELL -c '(( x=+));:' 2> /dev/null && err_exit '((x=+)) should be an error'
489 $SHELL -c 'x=();x.arr[0]=(z=3); ((x.arr[0].z=2))' 2> /dev/null || err_exit '(((x.arr[0].z=2)) should not be an error'
498 [[ $r == $t ]] || err_exit $(printf "float t=copysign(%3.1f,%3.1f) => %3.1f -- expected %3.1f\n" a b t r)
505 (( y == y_ascii )) || err_exit "no match,\n\t$(printf "%a\n" y)\n!=\n\t$(printf "%a\n" y_ascii)"
525 EOF) 2> /dev/null || err_exit 'error with comma expression'
529 [[ $(printf "%d" N[j]-N[i]) == 6 ]] || err_exit 'printf %d N[i]-N[j] failed'
530 [[ $((N[j]-N[i])) == 6 ]] || err_exit '$((N[j]-N[i])) incorrect'
535 (( x==1)) || err_exit '((a[++x]++)) should only increment x once'
536 (( a[1]==1)) || err_exit 'a[1] not incremented'
540 (( x==1)) || err_exit '((a[x++]++)) should only increment x once'
541 (( a[0]==1)) || err_exit 'a[0] not incremented'
545 (( x==2)) || err_exit '((a[x+=2]++)) should result in x==2'
546 (( a[2]==1)) || err_exit 'a[0] not 1'
552 (( a[0] == 0 )) || err_exit 'a[0] not 0'
553 (( a[1] == 1 )) || err_exit 'a[1] not 1'
560 (( (a[0]+a[1])==1000)) || err_exit '(a[0]+a[1])!=1000'