https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f5cf67f455f22ac0300216...
commit f5cf67f455f22ac03002165707bb41a8fdfa8535 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Mon Jul 27 16:46:49 2020 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Wed Sep 23 00:22:48 2020 +0200
[CMD_ROSTEST] Add tests for SET /A errorlevels. --- modules/rostests/win32/cmd/test_builtins.cmd | 56 ++++++++++++++++++++++++ modules/rostests/win32/cmd/test_builtins.cmd.exp | 29 ++++++++++++ 2 files changed, 85 insertions(+)
diff --git a/modules/rostests/win32/cmd/test_builtins.cmd b/modules/rostests/win32/cmd/test_builtins.cmd index 4cec71c48aa..5545f33b288 100644 --- a/modules/rostests/win32/cmd/test_builtins.cmd +++ b/modules/rostests/win32/cmd/test_builtins.cmd @@ -498,6 +498,62 @@ goto :eof :continue
+:: Testing different ERRORLEVELs from the SET command. +:: See https://ss64.com/nt/set.html for more details. + +echo ---------- Testing SET /A ERRORLEVELs ---------- + +echo --- Success +call :setError 0 +set /a "total=1+1" +call :checkErrorLevel 0 +echo %errorlevel% +echo %total% + +echo --- Unbalanced parentheses +call :setError 0 +set /a "total=(2+1" +call :checkErrorLevel 1073750988 +echo %errorlevel% +echo %total% + +echo --- Missing operand +call :setError 0 +set /a "total=5*" +call :checkErrorLevel 1073750989 +echo %errorlevel% +echo %total% + +echo --- Syntax error +call :setError 0 +set /a "total=7$3" +call :checkErrorLevel 1073750990 +echo %errorlevel% +echo %total% + +echo --- Invalid number +call :setError 0 +set /a "total=0xdeadbeeg" +call :checkErrorLevel 1073750991 +echo %errorlevel% +echo %total% + +echo --- Number larger than 32-bits +call :setError 0 +set /a "total=999999999999999999999999" +call :checkErrorLevel 1073750992 +echo %errorlevel% +echo %total% + +echo --- Division by zero +call :setError 0 +set /a "total=1/0" +call :checkErrorLevel 1073750993 +echo %errorlevel% +echo %total% + + + :: :: Finished! :: diff --git a/modules/rostests/win32/cmd/test_builtins.cmd.exp b/modules/rostests/win32/cmd/test_builtins.cmd.exp index 50cff1eae09..96be9047fda 100644 --- a/modules/rostests/win32/cmd/test_builtins.cmd.exp +++ b/modules/rostests/win32/cmd/test_builtins.cmd.exp @@ -130,4 +130,33 @@ OK 0 0 0 +---------- Testing SET /A ERRORLEVELs ---------- +--- Success +OK +0 +2 +--- Unbalanced parentheses +OK +1073750988 +2 +--- Missing operand +OK +1073750989 +2 +--- Syntax error +OK +1073750990 +7 +--- Invalid number +OK +1073750991 +7 +--- Number larger than 32-bits +OK +1073750992 +7 +--- Division by zero +OK +1073750993 +7 --------- Finished --------------