Skip to content

Commit

Permalink
Add tests for MetaModelica crefs
Browse files Browse the repository at this point in the history
Tests indexing using subscripts [1] as well as dot-notation using
MetaModelica records (singleton uniontypes).
  • Loading branch information
sjoelund committed Jul 5, 2015
1 parent 1445bcc commit 916948c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions metamodelica/meta/Makefile
Expand Up @@ -17,6 +17,7 @@ BuiltinString.mos \
CheckPatternScope.mo \
ComplicatedInteractive.mos \
Continue.mo \
cref.mos \
Equality.mos \
EqPatternm.mos \
ErrorInteractiveCallFunctionPtr.mos \
Expand Down
44 changes: 44 additions & 0 deletions metamodelica/meta/cref.mos
@@ -0,0 +1,44 @@
// status: correct

setCommandLineOptions("-g=MetaModelica");
loadString("
package TestCref

uniontype U
record R
Real r;
end R;
end U;
uniontype U2
record R2
array<U> u;
end R2;
end U2;
function f
output Real r1,r2,r3;
protected
array<U> a;
array<U2> au2;
U u;
U2 u2;
algorithm
a := arrayCreate(10, R(1.0));
au2 := arrayCreate(3, R2(a));
r1 := a[1].r;
u := au2[2].u[8];
r2 := au2[2].u[8].r;
u2 := R2(a);
r3 := u2.u[1].r;
end f;

end TestCref;
");getErrorString();
TestCref.f();getErrorString();

// Result:
// true
// true
// ""
// (1.0,1.0,1.0)
// ""
// endResult

0 comments on commit 916948c

Please sign in to comment.