Description
This test ensures correct behavior of the command line parameter dumpopt in combination with $onVerbatim and $ifThen ... $else ... $endIf. Contributor: Lutz Westermann, January 2021
Small Model of Type : GAMS
Category : GAMS Test library
Main file : dumpopt1.gms
$title 'Test verbatim dumpOpt' (DUMPOPT1,SEQ=848)
$onText
This test ensures correct behavior of the command line parameter dumpopt
in combination with $onVerbatim and $ifThen ... $else ... $endIf.
Contributor: Lutz Westermann, January 2021
$offText
$onEcho > wantDmp.dmp
$onVerbatim
$ifThen "%MYVAR%"=="1"
$ set A 1
Display
$(1) '1';
$elseIf "%MYVAR%"=="2"
$ set B 2
Display
$(2) '2';
$else
$ set C 3
display
$(3) '3';
$ log ### SCHALALALALAAA
$endIf
$if "%MYVAR%"=="1" display '1';
$if "%MYVAR%"=="2" display '2';
$if "%MYVAR%"=="3" display '3';
$ifThen "1"=="0"
Display 'bla';
$endIf
$ifThen %SOMECOMPILETIMEVAR%==0
%MYVAR%
$endIf
display 'hello';
$onEmbeddedCode Python:
pass
$offEmbeddedCode
embeddedCode Python:
pass
endEmbeddedCode
file fx;
put fx;
$onPut
xxx
$offPut
$offVerbatim
$offEcho
$onEcho > makeDmp.gms
$if not set MYVAR $set MYVAR 2
$onVerbatim
$ifThen "%MYVAR%"=="1"
$ set A 1
Display
$(1) '1';
$elseIf "%MYVAR%"=="2"
$ set B 2
Display
$(2) '2';
$else
$ set C 3
display
$(3) '3';
$ log ### SCHALALALALAAA
$endIf
$if "%MYVAR%"=="1" display '1';
$if "%MYVAR%"=="2" display '2';
$if "%MYVAR%"=="3" display '3';
$ifThen "1"=="0"
Display 'bla';
$endIf
$ifThen %SOMECOMPILETIMEVAR%==0
%MYVAR%
$endIf
display 'hello';
$onEmbeddedCode Python:
pass
$offEmbeddedCode
embeddedCode Python:
pass
endEmbeddedCode
file fx;
put fx;
$onPut
xxx
$offPut
$offVerbatim
$offEcho
$call.checkErrorLevel gams makeDmp dumpopt=11 lo=%gams.lo%
$call.checkErrorLevel awk "/^.onVerbatim/,/^.offVerbatim/" makeDmp.dmp > haveDmp.dmp
$call.checkErrorLevel diff -bw haveDmp.dmp wantDmp.dmp
* Random DCO which caused unwanted behavior in the past
$onEcho > inc.inc
$onDelim
$onCheckErrorLevel
$offEcho
* With $onVerbatim we do not want to see any content of the inc file in the dmp file
$onEcho > dontDmpIncContent.gms
$onVerbatim
$include inc.inc
$offVerbatim
$offEcho
$call.checkErrorLevel gams dontDmpIncContent.gms dumpopt=21 lo=%gams.lo%
$call grep -i onDelim dontDmpIncContent.dmp
$ife errorlevel=0 $abort onDelim should not be dumped
$call grep -i onCheckErrorLevel dontDmpIncContent.dmp
$ife errorlevel=0 $abort onCheckErrorLevel should not be dumped
* Without $onVerbatim we do want to see the content of the inc file in the dmp file
$onEcho > dmpIncContent.gms
$include inc.inc
$offEcho
$call.checkErrorLevel gams dmpIncContent.gms dumpopt=21 lo=%gams.lo%
$call grep -i onDelim dmpIncContent.dmp > %system.NullFile%
$ife errorlevel<>0 $abort onDelim should be dumped
$call grep -i onCheckErrorLevel dmpIncContent.dmp > %system.NullFile%
$ife errorlevel<>0 $abort onCheckErrorLevel should be dumped