diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index 6cf2ecbcd27..508691ef239 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -1131,6 +1131,141 @@ set /a WINE_foo=WINE_bar=5, WINE_bar ^|= 2 & call :checkenvvars WINE_foo 5 WINE_ set /a WINE_foo=WINE_bar=5, WINE_bar ^^= 2 & call :checkenvvars WINE_foo 5 WINE_bar 7 set WINE_baz=4 set /a WINE_foo=WINE_bar=19, WINE_bar %%= 4 + (WINE_baz %%= 7) & call :checkenvvars WINE_foo 19 WINE_bar 3 WINE_baz 4 +echo --- quotes +set /a WINE_foo=1 +call :checkenvvars WINE_foo 1 +set /a "WINE_foo=1" +call :checkenvvars WINE_foo 1 +set /a WINE_foo=1,WINE_bar=2 +call :checkenvvars WINE_foo 1 WINE_bar 2 +set /a "WINE_foo=1,WINE_bar=2" +call :checkenvvars WINE_foo 1 WINE_bar 2 +set /a "WINE_foo=1","WINE_bar=2" +call :checkenvvars WINE_foo 1 WINE_bar 2 +set /a ""WINE_foo=1","WINE_bar=2"" +call :checkenvvars WINE_foo 1 WINE_bar 2 +set /a WINE_foo=1,WINE_bar=2,WINE_baz=3 +call :checkenvvars WINE_foo 1 WINE_bar 2 WINE_baz 3 +set /a "WINE_foo=1,WINE_bar=2,WINE_baz=3" +call :checkenvvars WINE_foo 1 WINE_bar 2 WINE_baz 3 +set /a "WINE_foo=1","WINE_bar=2","WINE_baz=3" +call :checkenvvars WINE_foo 1 WINE_bar 2 WINE_baz 3 +set /a ""WINE_foo=1","WINE_bar=2","WINE_baz=3"" +call :checkenvvars WINE_foo 1 WINE_bar 2 WINE_baz 3 +set /a ""WINE_foo=1","WINE_bar=2"","WINE_baz=3" +call :checkenvvars WINE_foo 1 WINE_bar 2 WINE_baz 3 +set /a """"""WINE_foo=1"""""" +call :checkenvvars WINE_foo 1 +set /a """"""WINE_foo=1","WINE_bar=5""","WINE_baz=2"" +call :checkenvvars WINE_foo 1 WINE_bar 5 WINE_baz 2 +set /a WINE_foo="3"+"4"+"5+6" +call :checkenvvars WINE_foo 18 +set WINE_foo=3 +set /a WINE_bar="WINE_""foo"+4 +call :checkenvvars WINE_foo 3 WINE_bar 7 +echo --- whitespace are ignored between double char operators +set WINE_foo=4 +set WINE_bar=5 +set /a WINE_foo + = 6 +set /a WINE_bar * = WINE_foo +call :checkenvvars WINE_foo 10 WINE_bar 50 +set WINE_foo=4 +set WINE_bar=5 +set /a WINE_foo + = "6 < < 7" +set /a WINE_bar * = WINE_foo + WINE_foo +call :checkenvvars WINE_foo 772 WINE_bar 7720 +set /a WINE_foo=6 7 +set /a WINE_ var1=8 +set WINE_foo= +echo --- invalid operator sequence +set WINE_foo=4 +set /a =4 +set /a *=4 +set /a ^>=4" +set /a ^<=4" +set /a WINE_foo^>^<=4 +echo %WINE_foo% +set /a WINE_foo^>^>^>=4 +echo %WINE_foo% +echo ----- negative prefix +set /a WINE_foo=-1 +call :checkenvvars WINE_foo -1 +set /a WINE_foo=--1 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=3--3 +call :checkenvvars WINE_foo 6 +set /a WINE_foo=3---3 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=3----3 +call :checkenvvars WINE_foo 6 +set /a WINE_foo=-~1 +call :checkenvvars WINE_foo 2 +set /a WINE_foo=~-1 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=3+-~1 +call :checkenvvars WINE_foo 5 +set /a WINE_foo=3+~-1 +call :checkenvvars WINE_foo 3 +echo ----- assignment tests involving the end destination +set WINE_foo=3 +set /a WINE_foo+=3+(WINE_foo=4) +call :checkenvvars WINE_foo 11 +set WINE_foo=2 +set /a WINE_bar=3+(WINE_foo=6) +call :checkenvvars WINE_foo 6 WINE_bar 9 +set WINE_foo=2 +set /a WINE_bar=3+(WINE_foo=6,WINE_baz=7) +call :checkenvvars WINE_foo 6 WINE_bar 10 WINE_baz 7 +set WINE_foo=2 +set /a WINE_bar=WINE_foo=7 +call :checkenvvars WINE_foo 7 WINE_bar 7 +echo ----- equal precedence on stack +rem Unary - dont reduce if precedence is equal +set /a WINE_foo=!!1 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=!!0 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=~~1 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=~~0 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=--1 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=+-1 +call :checkenvvars WINE_foo -1 +set /a WINE_foo=-+1 +call :checkenvvars WINE_foo -1 +set /a WINE_foo=++1 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=!~1 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=~!1 +call :checkenvvars WINE_foo -1 +set /a WINE_foo=!-1 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=-!1 +call :checkenvvars WINE_foo 0 +set /a WINE_foo=!-0 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=-!0 +call :checkenvvars WINE_foo -1 +rem Aritmatic - Reduce if precedence is equal +set /a WINE_foo=10*5/2 +call :checkenvvars WINE_foo 25 +set /a WINE_foo=5/2*10 +call :checkenvvars WINE_foo 20 +set /a WINE_foo=10/5/2 +call :checkenvvars WINE_foo 1 +set /a WINE_foo=5%%2*4 +call :checkenvvars WINE_foo 4 +set /a WINE_foo=10-5+2 +call :checkenvvars WINE_foo 7 +set /a WINE_foo=1^<^<4^>^>1 +call :checkenvvars WINE_foo 8 +rem Assignment - dont reduce if precedence is equal +set /a WINE_foo=5 +set /a WINE_bar=WINE_foo=6 +call :checkenvvars WINE_foo 6 WINE_bar 6 echo --- for /F mkdir foobar & cd foobar diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index fd59c31e488..9e7f30b30f7 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -800,6 +800,89 @@ WINE_bar correctly 4 @todo_wine@WINE_foo correctly 19@or_broken@ERROR: WINE_foo incorrectly 0 [19] @todo_wine@WINE_bar correctly 3@or_broken@ERROR: WINE_bar incorrectly [3] WINE_baz correctly 4 +--- quotes +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_baz correctly 3 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_baz correctly 3 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_baz correctly 3 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_baz correctly 3 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 2 +@todo_wine@WINE_baz correctly 3 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_bar correctly 5 +@todo_wine@WINE_baz correctly 2 +@todo_wine@WINE_foo correctly 18 +WINE_foo correctly 3 +@todo_wine@WINE_bar correctly 7@or_broken@ERROR: WINE_bar incorrectly 4 [7] +--- whitespace are ignored between double char operators +@todo_wine@WINE_foo correctly 10@or_broken@ERROR: WINE_foo incorrectly 4 [10] +@todo_wine@WINE_bar correctly 50@or_broken@ERROR: WINE_bar incorrectly 5 [50] +@todo_wine@WINE_foo correctly 772@or_broken@ERROR: WINE_foo incorrectly 4 [772] +@todo_wine@WINE_bar correctly 7720@or_broken@ERROR: WINE_bar incorrectly 5 [7720] +--- invalid operator sequence +4 +4 +----- negative prefix +@todo_wine@WINE_foo correctly -1 +@todo_wine@WINE_foo correctly 1@or_broken@ERROR: WINE_foo incorrectly [1] +@todo_wine@WINE_foo correctly 6 +@todo_wine@WINE_foo correctly 0 +@todo_wine@WINE_foo correctly 6 +@todo_wine@WINE_foo correctly 2 +@todo_wine@WINE_foo correctly 0@or_broken@ERROR: WINE_foo incorrectly [0] +@todo_wine@WINE_foo correctly 5 +@todo_wine@WINE_foo correctly 3@or_broken@ERROR: WINE_foo incorrectly -5 [3] +----- assignment tests involving the end destination +@todo_wine@WINE_foo correctly 11@or_broken@ERROR: WINE_foo incorrectly 3 [11] +@todo_wine@WINE_foo correctly 6@or_broken@ERROR: WINE_foo incorrectly 2 [6] +@todo_wine@WINE_bar correctly 9@or_broken@ERROR: WINE_bar incorrectly [9] +@todo_wine@WINE_foo correctly 6@or_broken@ERROR: WINE_foo incorrectly 2 [6] +@todo_wine@WINE_bar correctly 10@or_broken@ERROR: WINE_bar incorrectly [10] +@todo_wine@WINE_baz correctly 7@or_broken@ERROR: WINE_baz incorrectly [7] +@todo_wine@WINE_foo correctly 7@or_broken@ERROR: WINE_foo incorrectly 2 [7] +@todo_wine@WINE_bar correctly 7@or_broken@ERROR: WINE_bar incorrectly 2 [7] +----- equal precedence on stack +@todo_wine@WINE_foo correctly 1@or_broken@ERROR: WINE_foo incorrectly 0 [1] +@todo_wine@WINE_foo correctly 0 +@todo_wine@WINE_foo correctly 1@or_broken@ERROR: WINE_foo incorrectly [1] +@todo_wine@WINE_foo correctly 0@or_broken@ERROR: WINE_foo incorrectly [0] +@todo_wine@WINE_foo correctly 1@or_broken@ERROR: WINE_foo incorrectly [1] +@todo_wine@WINE_foo correctly -1@or_broken@ERROR: WINE_foo incorrectly [-1] +@todo_wine@WINE_foo correctly -1@or_broken@ERROR: WINE_foo incorrectly [-1] +@todo_wine@WINE_foo correctly 1@or_broken@ERROR: WINE_foo incorrectly [1] +@todo_wine@WINE_foo correctly 0@or_broken@ERROR: WINE_foo incorrectly [0] +@todo_wine@WINE_foo correctly -1 +@todo_wine@WINE_foo correctly 0@or_broken@ERROR: WINE_foo incorrectly -1 [0] +@todo_wine@WINE_foo correctly 0 +@todo_wine@WINE_foo correctly 1@or_broken@ERROR: WINE_foo incorrectly 0 [1] +@todo_wine@WINE_foo correctly -1@or_broken@ERROR: WINE_foo incorrectly 0 [-1] +@todo_wine@WINE_foo correctly 25@or_broken@ERROR: WINE_foo incorrectly 20 [25] +@todo_wine@WINE_foo correctly 20 +@todo_wine@WINE_foo correctly 1 +@todo_wine@WINE_foo correctly 4 +@todo_wine@WINE_foo correctly 7 +@todo_wine@WINE_foo correctly 8@or_broken@ERROR: WINE_foo incorrectly 4 [8] +@todo_wine@WINE_foo correctly 6@or_broken@ERROR: WINE_foo incorrectly 5 [6] +@todo_wine@WINE_bar correctly 6@or_broken@ERROR: WINE_bar incorrectly 5 [6] --- for /F ------ string argument a