ifstat8.gms : Tests for $if empty

Description

This tests $if EMPTY.

Contributor: Lutz Westermann, March 2024


Small Model of Type : GAMS


Category : GAMS Test library


Main file : ifstat8.gms

$title 'Tests for $IF empty' (IFSTAT8,SEQ=953)

$ontext
This tests $if EMPTY.

Contributor: Lutz Westermann, March 2024
$offtext

$eval test 0

* Simple empty
$if empty
$eval test %test%+1
$ifE %test%<>1 $abort %test%<>1

* Simple not empty
$if not empty
$eval test %test%+1
$ifE %test%<>1 $abort %test%<>1

* Simple non-empty
$if empty anything
$eval test %test%+1
$ifE %test%<>1 $abort %test%<>1

* Simple not non-empty
$if not empty anything
$eval test %test%+1
$ifE %test%<>2 $abort %test%<>2

* Empty with quotes -> not empty
$if empty ''
$eval test %test%+1
$ifE %test%<>2 $abort %test%<>2

* Empty with other quotes -> not empty
$if empty ""
$eval test %test%+1
$ifE %test%<>2 $abort %test%<>2

* Quoted quotes are not empty
$if empty '""'
$eval test %test%+1
$ifE %test%<>2 $abort %test%<>2

* Even %system.tab% is not empty
$if empty %system.tab%
$eval test %test%+1
$ifE %test%<>2 $abort %test%<>2

* After empty, there is just a string, nothing get evaluated
$if empty $eval test %test%+1
$eval test %test%+1
$ifE %test%<>2 $abort %test%<>2

* Do some shift
$onEchoV > inc.gms
$eval locTest %test%
$label start
$eval locTest %locTest%+1
$shift
$if not empty %1
$goTo start
$setGlobal batchedTest %locTest%
$offEcho

$batInclude inc.gms 1 2 3
$ifE %batchedTest%<>5 $abort %batchedTest%<>5