Skip to content

Commit

Permalink
[NF] Add tuple operation tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 28, 2018
1 parent dddb7ad commit 21c648d
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flattening/modelica/scodeinst/Makefile
Expand Up @@ -593,6 +593,9 @@ Time3.mo \
TupleInvalid1.mo \
TupleInvalid2.mo \
TupleInvalid3.mo \
TupleOperation1.mo \
TupleOperation2.mo \
TupleOperation4.mo \
type2.mo \
TypeDim1.mo \
TypeDim2.mo \
Expand All @@ -619,6 +622,7 @@ Wild1.mo \
# test that currently fail. Move up when fixed.
# Run make testfailing
FAILINGTESTFILES=\
TupleOperation3.mo \
RedeclareConstant1.mo \
BuiltinAttribute13.mo \
CevalDer2.mo \
Expand Down
27 changes: 27 additions & 0 deletions flattening/modelica/scodeinst/TupleOperation1.mo
@@ -0,0 +1,27 @@
// name: TupleOperation1
// keywords:
// status: correct
// cflags: -d=newInst
//

function f
input Real t;
output Real x = 1.0;
output Real y = 2.0;
end f;

model TupleOperation1
Real x = -f(time);
end TupleOperation1;

// Result:
// function f
// input Real t;
// output Real x = 1.0;
// output Real y = 2.0;
// end f;
//
// class TupleOperation1
// Real x = -f(time)[1];
// end TupleOperation1;
// endResult
41 changes: 41 additions & 0 deletions flattening/modelica/scodeinst/TupleOperation2.mo
@@ -0,0 +1,41 @@
// name: TupleOperation2
// keywords:
// status: correct
// cflags: -d=newInst
//

function f
input Real t;
output Real x = 1.0;
output Real y = 2.0;
end f;

function f2
input Real t;
output Real x = 3.0;
output Real y = 4.0;
output Real z = 5.0;
end f2;

model TupleOperation2
Real x = f(time) + f2(time);
end TupleOperation2;

// Result:
// function f
// input Real t;
// output Real x = 1.0;
// output Real y = 2.0;
// end f;
//
// function f2
// input Real t;
// output Real x = 3.0;
// output Real y = 4.0;
// output Real z = 5.0;
// end f2;
//
// class TupleOperation2
// Real x = f(time)[1] + f2(time)[1];
// end TupleOperation2;
// endResult
21 changes: 21 additions & 0 deletions flattening/modelica/scodeinst/TupleOperation3.mo
@@ -0,0 +1,21 @@
// name: TupleOperation3
// keywords:
// status: correct
// cflags: -d=newInst
//

function f
output Integer n1 = 2;
output Integer n2 = 3;
end f;

model TupleOperation3
Real x[f()];
end TupleOperation3;

// Result:
// class TupleOperation3
// Real x[1];
// Real x[2];
// end TupleOperation3;
// endResult
35 changes: 35 additions & 0 deletions flattening/modelica/scodeinst/TupleOperation4.mo
@@ -0,0 +1,35 @@
// name: TupleOperation4
// keywords:
// status: correct
// cflags: -d=newInst
//

function f
input Real t;
output Integer n1 = 2;
output Integer n2 = 3;
end f;

model TupleOperation4
Real x[3];
Real y;
equation
y = x[f(time)];
end TupleOperation4;

// Result:
// function f
// input Real t;
// output Integer n1 = 2;
// output Integer n2 = 3;
// end f;
//
// class TupleOperation4
// Real x[1];
// Real x[2];
// Real x[3];
// Real y;
// equation
// y = x[f(time)[1]];
// end TupleOperation4;
// endResult

0 comments on commit 21c648d

Please sign in to comment.