[CMD_ROSTEST] Add tests for GOTO and CALL label search ordering.

This commit is contained in:
Hermès Bélusca-Maïto 2020-07-27 00:42:11 +02:00
parent 495c82ccde
commit 8ed9a46dc2
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 45 additions and 0 deletions

View file

@ -8,6 +8,47 @@ setlocal enabledelayedexpansion
::
:: GOTO/CALL jump to labels present forward to their call-point. Only when
:: the label cannot be found forward, the search is then restarted from the
:: beginning of the batch file onwards up to the original call-point.
::
goto :test_start
:: Execution must never go there!
:test_goto
echo Unexpected GOTO jump^^!
exit
:test_call
echo Unexpected CALL jump^^!
goto :EOF
:test_start
:: Testing GOTO/CALL forwards.
echo --------- Testing GOTO ---------
goto :test_goto
:do_test_call
echo --------- Testing CALL within batch ---------
call :test_call
goto :continue
:test_goto
echo Test GOTO ok
goto :do_test_call
:test_call
echo Test CALL ok from %0
:: We exit this CALL invocation
goto :EOF
::
:: Next suite of tests.
::
:continue
::
:: Testing GOTO/CALL from and to within parenthesized blocks.

View file

@ -1,3 +1,7 @@
--------- Testing GOTO ---------
Test GOTO ok
--------- Testing CALL within batch ---------
Test CALL ok from :test_call
--------- Testing GOTO within block ---------
Block-test 1: Single-line
Block-test 2: Multi-line