embgms05.gms : Test merge/replace when loading data from embedded code

Description

Contributor: Michael Bussieck, January 2023


Small Model of Type : GAMS


Category : GAMS Test library


Main file : embgms05.gms

$title 'Test merge/replace when loading data from embedded code' (EMBGMS05,SEQ=929)

$onText
Contributor: Michael Bussieck, January 2023
$offText


Set       universe / i1*i3 /
          s(universe);

$onEmbeddedCode GAMS:
  set s /I2/;
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i2 $abort 'Expected i2 but got %STL%'

$onEmbeddedCode GAMS:
  set s /I2/;
$offEmbeddedCode s
$if errorFree $abort 'Error expected'
$clearErrors

$kill s
$onEmbeddedCode GAMS:
  set s /I2/;
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i2 $abort 'Expected i2 but got %STL%'

$onMulti
$onEmbeddedCode GAMS:
  set s /I1/;
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i1 $abort 'Expected i1 but got %STL%'

$onMultiR
$onEmbeddedCode GAMS:
  set s /I3/;
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i3 $abort 'Expected i3 but got %STL%'
$offMulti

$kill s
$onEmbeddedCode GAMS:
  set s /I2/;
$offEmbeddedCode s
$if not errorFree $abort 'No error expected'
$eval.Set STL s.firstTL
$if not %STL%==i2 $abort 'Expected i2 but got %STL%'

* Execution time import does a merge
option clear=s;
EmbeddedCode GAMS:
  set s /I2/;
endEmbeddedCode s
abort$(card(s)<>1 or not s('i2')) 'expect just i2 in s', s;

EmbeddedCode GAMS:
  set s /I1/;
endEmbeddedCode s
abort$(card(s)<>2 or not s('i1') or not s('i2')) 'expect just i1 in s', s;