goto01.gms : Test $maxGoTo behavior

Description

This tests the correct behavior of $goto under different $maxGoTo settings.

Contributor: Lutz Westermann, November 2024


Small Model of Type : GAMS


Category : GAMS Test library


Main file : goto01.gms

$title 'Test $maxGoTo behavior (GOTO01,SEQ=972)'

$onText
This tests the correct behavior of $goto under different $maxGoTo settings.

Contributor: Lutz Westermann, November 2024
$offText


* Default should work
$onEcho > test.gms
$eval a 0
$label start
$eval a %a%+1
$ifE %a%<111 $goto start

Scalar a /%a%/;
$offEcho
$call.checkErrorLevel gams test.gms lo=%GAMS.lo%

* Old default should fail
$onEcho > test.gms
$maxGoTo 100
$eval a 0
$label start
$eval a %a%+1
$ifE %a%<111 $goto start

Scalar a /%a%/;
$offEcho
$call gams test.gms lo=%GAMS.lo%
$ifE errorlevel=1 $abort Error expected in %system.Line%

* 0 skips goto but does not throw an error
$onEcho > test.gms
$maxGoTo 0
$eval a 0
$label start
$eval a %a%+1
$ifE %a%<111 $goto start

Scalar a /%a%/;
abort$(a<>1) '1 expected';
$offEcho
$call.checkErrorLevel gams test.gms lo=%GAMS.lo%