Description
Tests a number of basic $if options. Contributor: Alex Meeraus
Small Model of Type : GAMS
Category : GAMS Test library
Main file : ifstat1.gms
$title 'Tests of $if statement' (IFSTAT1,SEQ=140)
$onText
Tests a number of basic $if options.
Contributor: Alex Meeraus
$offText
$log %system.version%
$log %system.verid%
$set var_scoped scoped
$setLocal var_local local
$setGlobal var_global global
$show
$if NOT SET Var_Scoped $abort set scoped failed
$if NOT SET Var_Local $abort set local failed
$if NOT SET Var_Global $abort set global failed
$if NOT errorfree $abort bad errorfree test
$if errorlevel 1 $abort errolevel should be zero
Set s;
Parameter p;
Variable v;
Equation e;
File f;
Model m;
Function fun;
Acronym acr;
$macro myD(x) display x;
$if NOT FunType exp $abort should be funtype
$if NOT SetType s $abort should be settype
$if NOT ParType p $abort should be partype
$if NOT VarType v $abort should be vartype
$if NOT EquType e $abort should be eqytype
$if NOT AcrType acr $abort should be acrtype
$if NOT FilType f $abort should be filtype
$if NOT ModType m $abort should be modtype
$if NOT MacType myD $abort should be mactype
$if NOT FunType fun $abort should be funtype
$if NOT PreType diag $abort should be pretype
* Testing for unknown type is more complex
$onEcho > xxxType.gms
display x;
$if NOT xxxType x $abort should be xxxtype
$offEcho
$call.checkErrorLevel gams xxxType mp=1 lo=%gams.lo%
$if not declared s $abort should be declared
$if defined s $abort no data yet
$if defined f $abort no data yet
$if defined m $abort no data yet
* this will create an error starting in 147
$if dimension 0 s $abort dimension should not be known
$ifThen errorfree $abort we should have an error
$else $clearErrors
$endIf
set s / 1*3 /; p = 20; file f / temp /; model m / e /;
$if not defined f $abort we should have data
$if not defined m $abort we should have date
$if not defined s $abort s should be definded
$if not defined p $abort p should be definded
$if readable v $abort v should not be readable
$if not readable p $abort p should be readable
$if uelExist 4 $abort 4 should be no known UEL
$if not uelExist 3 $abort 3 should be known UEL
$if not dimension 1 s $abort dimension should be 1
$if dimension 0 V $abort dimension should not be known
$if dimension 0 m $abort dimension not defined
$if dimension 0 f $abort dimension not defined
$ifThen errorfree $abort we should have an error
$else $clearErrors
$endIf
* pretypes are implemented in a funny way, when a symbol is
* referenced we make a second entry and make the first one
* invisible
$if NOT declared sameas $abort should be pretype
$if NOT PreType sameas $abort should be pretype
$if NOT defined sameas $abort should have data
$if NOT SetType sameas $abort should be pretype
$if NOT dimension 2 sameas $abort should be pretype
p = sameas('1','1');
* symbol not reachable any more with current symbol table management
*$if NOT PreType sameas $abort should be pretype
$if NOT declared sameas $abort should be pretype
$if NOT SetType sameas $abort should be pretype
$if NOT dimension 2 sameas $abort should be pretype
$if NOT defined sameas $abort should have data
$if solver xxxxxxxxxx $abort there is no solver xxxxxxxxxx
$if not solver soplex $abort soplex should be there always
Set gdxS / s1 /;
Parameter gdxP(gdxS) / s1 1 /;
Variable gdxV(gdxS) / s1.l 1 /;
Equation gdxE(gdxS) / s1.l 1 /;
$gdxUnload myGdx.gdx gdxS gdxP gdxV gdxE
$gdxIn myGdx.gdx
$if not gdxSymExist gdxS $abort gdxS should be in myGdx.gdx
$if not gdxSetType gdxS $abort gdxS should be set in myGdx.gdx
$if not gdxParType gdxP $abort gdxP should be par in myGdx.gdx
$if not gdxVarType gdxV $abort gdxV should be var in myGdx.gdx
$if not gdxEquType gdxE $abort gdxE should be equ in myGdx.gdx
$if not gdxDimension 1 gdxP $abort gdxP should have dim 1 in myGdx.gdx
$if gdxSymExist gdxX $abort gdxX should not be in myGdx.gdx
$if gdxSetType gdxP $abort gdxP should not be set in myGdx.gdx
$if gdxParType gdxS $abort gdxS should not be par in myGdx.gdx
$if gdxVarType gdxE $abort gdxE should not be var in myGdx.gdx
$if gdxEquType gdxV $abort gdxV should not be equ in myGdx.gdx
$if gdxDimension 2 gdxP $abort gdxP should not have dim 2 in myGdx.gdx