Lines Matching refs: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 == 10 )) || err_exit 'leading zeros in x treated as octal arithmetic with $((x))'
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 ) == *++1:* ]] || 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"
484 [[ $((-0)) == 0 ]] || err_exit '$((-0)) should be 0'
485 [[ $(( -1*0)) == 0 ]] || err_exit '$(( -1*0)) should be 0'
486 [[ $(( -1.0*0)) == -0 ]] || err_exit '$(( -1.0*0)) should be -0'
487 [[ $(printf "%g %g %g\n" x $x $((x)) ) == '-0 -0 -0' ]] || err_exit '%g of x $x $((x)) for x=-0 should all be -0'
488 [[ $(printf "%g %g %g\n" y $x $((y)) ) == '-0 -0 -0' ]] || err_exit '%g of y $y $((y)) for y=-0.0 should all be -0'
489 $SHELL -c '(( x=));:' 2> /dev/null && err_exit '((x=)) should be an error'
490 $SHELL -c '(( x+=));:' 2> /dev/null && err_exit '((x+=)) should be an error'
491 $SHELL -c '(( x=+));:' 2> /dev/null && err_exit '((x=+)) should be an error'
492 $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'
501 [[ $r == $t ]] || err_exit $(printf "float t=copysign(%3.1f,%3.1f) => %3.1f -- expected %3.1f\n" a b t r)
508 (( y == y_ascii )) || err_exit "no match,\n\t$(printf "%a\n" y)\n!=\n\t$(printf "%a\n" y_ascii)"
528 EOF) 2> /dev/null || err_exit 'error with comma expression'
532 [[ $(printf "%d" N[j]-N[i]) == 6 ]] || err_exit 'printf %d N[i]-N[j] failed'
533 [[ $((N[j]-N[i])) == 6 ]] || err_exit '$((N[j]-N[i])) incorrect'
538 (( x==1)) || err_exit '((a[++x]++)) should only increment x once'
539 (( a[1]==1)) || err_exit 'a[1] not incremented'
543 (( x==1)) || err_exit '((a[x++]++)) should only increment x once'
544 (( a[0]==1)) || err_exit 'a[0] not incremented'
548 (( x==2)) || err_exit '((a[x+=2]++)) should result in x==2'
549 (( a[2]==1)) || err_exit 'a[0] not 1'
555 (( a[0] == 0 )) || err_exit 'a[0] not 0'
556 (( a[1] == 1 )) || err_exit 'a[1] not 1'
563 (( (a[0]+a[1])==1000)) || err_exit '(a[0]+a[1])!=1000'
565 (( 4.**3/10 == 6.4 )) || err_exit '4.**3/10!=6.4'
566 (( (.5+3)/7 == .5 )) || err_exit '(.5+3)/7!==.5'
573 (( abs(sin(.5)-mysin(.5)) < 1e-6 )) || err_exit 'mysin() not close to sin()'
575 $SHELL 2> /dev/null <<- \EOF || err_exit "arithmetic functions defined and referenced in compound command not working"
594 (( max(max(3,8,5),7,5)==8)) || err_exit 'max(max(3,8,5),7,5)!=8'
595 (( max(max(3,8,5),7,9)==9)) || err_exit 'max(max(3,8,9),7,5)!=9'
596 (( max(6,max(3,9,5),7)==9 )) || err_exit 'max(6,max(3,8,5),7)!=9'
597 (( max(6,7, max(3,8,5))==8 )) || err_exit 'max(6,7,max(3,8,5))!=8'
601 (( pants == blue )) || err_exit 'pants should be blue'
602 (( shirt == red )) || err_exit 'pants should be red'
603 (( shirt != green )) || err_exit 'shirt should not be green'
604 (( pants != shirt )) || err_exit 'pants should be the same as shirt'
606 (( pants == yellow )) || err_exit 'pants should be yellow'
615 (( abs(x-y) < 1e-10 )) || err_exit '$nz and nz differs in arithmetic expression when nz is reference to array instance'
622 (( abs(x-.5) < 1.e-10 )) || err_exit 'bug in composite function evaluation'
626 { (( $x == 16 )) ;} 2> /dev/null || err_exit 'expansions of hexfloat not working in arithmetic expansions'
635 (( foo == 8 )) || err_exit 'arithmetic assignment binding to the wrong scope'
637 (( tgamma(4)/12 )) || err_exit 'floating point attribute for functions not preserved'
645 [[ $F == 1 ]] || err_exit 'scoping bug with arithmetic expression'
653 [[ $F == 1 ]] || err_exit 'scoping bug2 with arithmetic expression'
662 (( z==2 )) || err_exit 'unset compound array variable error with for loop optimization'
664 [[ $($SHELL 2> /dev/null -c 'print -- $(( ldexp(1, 4) ))' ) == 16 ]] || err_exit 'function ldexp not implement or not working correctly'
667 $SHELL 2> /dev/null -c 'str="0x1.df768ed398ee1e01329a130627ae0000p-1";typeset -l -E x;((x=str))' || err_exit '((x=var)) fails for hexfloat with var begining with 0x1.nnn'
671 (( x[2] == 4 )) || err_exit '(( x[2] /= x[0])) fails for index array'
675 (( x[2] == 4 )) || err_exit '(( x[2] /= x[0])) fails for associative array'
679 [[ $got == "$exp" ]] || err_exit '(( x[0].y[0].z[2]=3 )) not working'
683 [[ $x == 10 ]] || err_exit 'let treating 010 as octal'
686 [[ $x == 8 ]] || err_exit 'let not treating 010 as octal with letoctal on'
694 (( z == 1 )) || err_exit "z should be 1 but is $z for associative array of
696 [[ ${A[a].AA[aa]} == 2 ]] || err_exit '${A[a].AA[aa]} should be 2 after ++ operation for associative array of associative array arithmetic'
702 (( z == 2 )) || err_exit "z should be 2 but is $z for associative array of
704 (( aa == 3 )) || err_exit "subscript aa should be 3 but is $aa after ++"
705 [[ ${A[a].AA[aa-1]} == 2 ]] || err_exit '${A[a].AA[aa]} should be 2 after ++ operation for ssociative array of index array arithmetic'
712 (( z == 3 )) || err_exit "z should be 3 but is $z for index array of
714 [[ ${A[a].AA[aa]} == 2 ]] || err_exit '${A[a].AA[aa]} should be 2 after ++ operation for index array of associative array arithmetic'
720 (( z == 4 )) || err_exit "z should be 4 but is $z for index array of
722 [[ ${A[a-1].AA[aa-1]} == 2 ]] || err_exit '${A[a].AA[aa]} should be 2 after ++ operation for index array of index array arithmetic'
723 (( aa == 4 )) || err_exit "subscript aa should be 4 but is $aa after ++"
724 (( a == 2 )) || err_exit "subscript a should be 2 but is $a after ++"
730 (($r == 16)) || err_exit 'leading 0 not treated as octal inside ((...))'
732 (( x == 16 )) || err_exit 'leading 0 not treated as octal inside $((...))'
734 ((x == 20 )) || err_exit 'leading 0 should not be treated as octal outside ((...))'
736 ((x == -20)) || err_exit 'numbers with leading -0 should not be treated as octal outside ((...))'
738 ((x == -16)) || err_exit 'numbers with leading -8# should be treated as octal'
742 let "$x==1" || err_exit 'hex constants not working with let'
743 (( $x == 1 )) || err_exit 'arithmetic with $x, where $x is hex constant not working'
745 do (($x == 1)) || err_exit 'arithmetic in for loop with $x, where $x is hex constant not working'
748 let "$x==10" || err_exit 'arithmetic with $x where $x is 010 should be decimal in let'
749 (( 9.$x == 9.01 )) || err_exit 'arithmetic with 9.$x where x=010 should be 9.01'
750 (( 9$x == 9010 )) || err_exit 'arithmetic with 9$x where x=010 should be 9010'
752 ((x$x == 99 )) || err_exit 'arithtmetic with x$x where x=010 should be $x010'
753 (( 3+$x == 11 )) || err_exit '3+$x where x=010 should be 11 in ((...))'
754 let "(3+$x)==13" || err_exit 'let should not recognize leading 0 as octal'
757 (( $x == 10 )) || err_exit 'leading 0 in -RZ should not create octal constant with ((...))'
758 let "$x==10" || err_exit 'leading 0 in -RZ should not create octal constant with let'
763 [[ $v == "$x" ]] || err_exit "'printf %.28a 64' failed -- expected '$x', got '$v'"