Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
[NF] Update tests.
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2703
  - #1047
  • Loading branch information
perost authored and OpenModelica-Hudson committed Oct 8, 2018
1 parent 9f88584 commit 1d6f8f5
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 35 deletions.
20 changes: 20 additions & 0 deletions flattening/modelica/scodeinst/CevalArrayConstructor1.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// name: CevalArrayConstructor1
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model CevalArrayConstructor1
constant Real x[:] = {i for i in 1:5};
end CevalArrayConstructor1;

// Result:
// class CevalArrayConstructor1
// constant Real x[1] = 1.0;
// constant Real x[2] = 2.0;
// constant Real x[3] = 3.0;
// constant Real x[4] = 4.0;
// constant Real x[5] = 5.0;
// end CevalArrayConstructor1;
// endResult
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// name: CevalReduction2
// name: CevalArrayConstructor2
// keywords:
// status: correct
// cflags: -d=newInst
//
//

model CevalReduction2
model CevalArrayConstructor2
constant Real x[:,:] = {i-j for i in 1:5, j in 1:3};
end CevalReduction2;
end CevalArrayConstructor2;

// Result:
// class CevalReduction2
// class CevalArrayConstructor2
// constant Real x[1,1] = 0.0;
// constant Real x[1,2] = 1.0;
// constant Real x[1,3] = 2.0;
Expand All @@ -26,5 +26,5 @@ end CevalReduction2;
// constant Real x[3,3] = 0.0;
// constant Real x[3,4] = 1.0;
// constant Real x[3,5] = 2.0;
// end CevalReduction2;
// end CevalArrayConstructor2;
// endResult
61 changes: 55 additions & 6 deletions flattening/modelica/scodeinst/CevalReduction1.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,64 @@
//

model CevalReduction1
constant Real x[:] = {i for i in 1:5};
type E = enumeration(one, two, three);

constant Real r1 = min(r*2 for r in {1.0, 2, 3, 4});
constant Real r2 = max(r*r for r in {-4.0, -2.0, 3.0, 5.0});
constant Real r3 = sum(r*2.0 for r in 1:10);
constant Real r4 = product(r^2 for r in 1:5);
constant Real r5 = sum(x*y*1.0 for x in 1:4, y in 3:9);
constant Real r6 = min(r*2.0 for r in 1:0);
constant Real r7 = max(r*2.0 for r in 1:0);
constant Real r8 = sum(r*2.0 for r in 1:0);
constant Real r9 = product(r*2.0 for r in 1:0);

constant Integer i1 = min(i-1 for i in {2, 4, 1});
constant Integer i2 = max(i for i in {4, 2, 9});
constant Integer i3 = sum(i*i for i in {1, 2, 3});
constant Integer i4 = product(i for i in 4:9);
constant Integer i5 = min(i for i in 1:0);
constant Integer i6 = max(i for i in 1:0);
constant Integer i7 = sum(i for i in 1:0);
constant Integer i8 = product(i for i in 1:0);

constant Boolean b1 = min(not b for b in {false, true});
constant Boolean b2 = max(i == 2 for i in 1:4);
constant Boolean b3 = min(b for b in true:false);
constant Boolean b4 = max(b for b in true:false);

constant E e1 = min(e for e in E.one:E.three);
constant E e2 = max(e for e in E);
constant E e3 = min(e for e in E.three:E.one);
constant E e4 = max(e for e in E.three:E.one);
end CevalReduction1;

// Result:
// class CevalReduction1
// constant Real x[1] = 1.0;
// constant Real x[2] = 2.0;
// constant Real x[3] = 3.0;
// constant Real x[4] = 4.0;
// constant Real x[5] = 5.0;
// constant Real r1 = 2.0;
// constant Real r2 = 25.0;
// constant Real r3 = 110.0;
// constant Real r4 = 14400.0;
// constant Real r5 = 420.0;
// constant Real r6 = 8.777798510069901e+304;
// constant Real r7 = -8.777798510069901e+304;
// constant Real r8 = 0.0;
// constant Real r9 = 1.0;
// constant Integer i1 = 0;
// constant Integer i2 = 9;
// constant Integer i3 = 14;
// constant Integer i4 = 60480;
// constant Integer i5 = 4611686018427387903;
// constant Integer i6 = -4611686018427387903;
// constant Integer i7 = 0;
// constant Integer i8 = 1;
// constant Boolean b1 = false;
// constant Boolean b2 = true;
// constant Boolean b3 = true;
// constant Boolean b4 = false;
// constant enumeration(one, two, three) e1 = E.one;
// constant enumeration(one, two, three) e2 = E.three;
// constant enumeration(one, two, three) e3 = E.three;
// constant enumeration(one, two, three) e4 = E.one;
// end CevalReduction1;
// endResult
35 changes: 27 additions & 8 deletions flattening/modelica/scodeinst/FuncBuiltinReduction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,31 @@ model FuncBuiltinReduction
end FuncBuiltinReduction;

// Result:
// [D:/OpenModelica/OMCompiler/Compiler/NFFrontEnd/NFExpression.mo:819:11-819:95:writable]Modelica Assert: NFExpression.toDAE got unknown expression 'E'!
// Error processing file: FuncBuiltinReduction.mo
// Error: Internal error Instantiation of FuncBuiltinReduction failed with no error message.
//
// # Error encountered! Exiting...
// # Please check the error message and the flags.
//
// Execution failed!
// class FuncBuiltinReduction
// Real r1 = min(r * 2.0 for r in {1.0, 2.0, 3.0, 4.0});
// Real r2 = max(r * r for r in {-4.0, -2.0, 3.0, 5.0});
// Real r3 = sum(/*Real*/(r) * 2.0 for r in 1:10);
// Real r4 = product(/*Real*/(r) ^ 2.0 for r in 1:5);
// Real r5 = sum(/*Real*/(x * y) for x in 1:4, y in 3:9);
// Real r6 = min(/*Real*/(r) * 2.0 for r in 1:0);
// Real r7 = max(/*Real*/(r) * 2.0 for r in 1:0);
// Real r8 = sum(/*Real*/(r) * 2.0 for r in 1:0);
// Real r9 = product(/*Real*/(r) * 2.0 for r in 1:0);
// Integer i1 = min(i - 1 for i in {2, 4, 1});
// Integer i2 = max(i for i in {4, 2, 9});
// Integer i3 = sum(i * i for i in {1, 2, 3});
// Integer i4 = product(i for i in 4:9);
// Integer i5 = min(i for i in 1:0);
// Integer i6 = max(i for i in 1:0);
// Integer i7 = sum(i for i in 1:0);
// Integer i8 = product(i for i in 1:0);
// Boolean b1 = min(not b for b in {false, true});
// Boolean b2 = max(i == 2 for i in 1:4);
// Boolean b3 = min(b for b in true:false);
// Boolean b4 = max(b for b in true:false);
// enumeration(one, two, three) e1 = min(e for e in E.one:E.three);
// enumeration(one, two, three) e2 = max(e for e in {E.one, E.two, E.three});
// enumeration(one, two, three) e3 = min(e for e in E.three:E.one);
// enumeration(one, two, three) e4 = max(e for e in E.three:E.one);
// end FuncBuiltinReduction;
// endResult
4 changes: 2 additions & 2 deletions flattening/modelica/scodeinst/FuncVectorizationMap1.mo
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end FuncVectorizationMap1;
// Real g[2,3];
// equation
// g = array(FuncVectorizationMap1.F(b[$i1,$i2], 1.0) for $i2 in 1:3, $i1 in 1:2);
// g = array(array(FuncVectorizationMap1.F(b[i,$i1,:], 1.0) for $i1 in 1:3) for i in 1:2);
// g = array(FuncVectorizationMap1.F(b[i,j,:], 1.0) for j in 1:3, i in 1:2);
// g = array(array(FuncVectorizationMap1.F(b[i,$i1], 1.0) for $i1 in 1:3) for i in 1:2);
// g = array(FuncVectorizationMap1.F(b[i,j], 1.0) for j in 1:3, i in 1:2);
// end FuncVectorizationMap1;
// endResult
6 changes: 3 additions & 3 deletions flattening/modelica/scodeinst/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ CevalArray1.mo \
CevalArrayConstant1.mo \
CevalArrayConstant2.mo \
CevalArrayConstant3.mo \
CevalArrayConstructor1.mo \
CevalArrayConstructor2.mo \
CevalAsin1.mo \
CevalAtan1.mo \
CevalAtan21.mo \
Expand Down Expand Up @@ -135,8 +137,6 @@ CevalRecordArray1.mo \
CevalRecordArray2.mo \
CevalRecordArray4.mo \
CevalRecordArray5.mo \
CevalReduction1.mo \
CevalReduction2.mo \
CevalRelation1.mo \
CevalRem1.mo \
CevalScalar1.mo \
Expand Down Expand Up @@ -411,6 +411,7 @@ FuncBuiltinOnes.mo \
FuncBuiltinOuterProduct.mo \
FuncBuiltinPre.mo \
FuncBuiltinProduct.mo \
FuncBuiltinReduction.mo \
FuncBuiltinRem.mo \
FuncBuiltinSample.mo \
FuncBuiltinScalar.mo \
Expand Down Expand Up @@ -797,7 +798,6 @@ expconn6.mo \
expconn7.mo \
func1.mo \
FuncBuiltinEnumTypeName.mo \
FuncBuiltinReduction.mo \
ImportShadowing1.mo \
InnerOuterExtends1.mo \
inst1.mo \
Expand Down
2 changes: 1 addition & 1 deletion flattening/modelica/scodeinst/Subscript5.mo
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end Subscript5;
// input Real[:, :] y;
// output Real z;
// algorithm
// z := x[1,:] * y[2,:];
// z := x[1] * y[2];
// end f;
//
// class Subscript5
Expand Down
20 changes: 10 additions & 10 deletions flattening/modelica/scodeinst/TestSampleNoClock.mos
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ instantiateModel(Modelica.Blocks.Examples.BooleanNetwork1); getErrorString();
// algorithm
// if size(table, 1) == 0 then
// index := 0;
// nextTime := 1e+060;
// nextTime := 9.999999999999999e+59;
// y := startValue;
// elseif size(table, 1) == 1 then
// index := 1;
// if table[1] > simulationStartTime then
// nextTime := table[1];
// y := startValue;
// else
// nextTime := 1e+060;
// nextTime := 9.999999999999999e+59;
// y := not startValue;
// end if;
// else
Expand All @@ -49,7 +49,7 @@ instantiateModel(Modelica.Blocks.Examples.BooleanNetwork1); getErrorString();
// j := j + 1;
// end while;
// if j > n then
// nextTime := 1e+060;
// nextTime := 9.999999999999999e+59;
// else
// nextTime := table[j];
// end if;
Expand Down Expand Up @@ -81,7 +81,7 @@ instantiateModel(Modelica.Blocks.Examples.BooleanNetwork1); getErrorString();
// input Boolean[:] b \"Boolean vector\";
// output Integer n \"Number of true entries\";
// algorithm
// n := sum(array(if b[i] then 1 else 0 for i in 1:size(b, 1)));
// n := sum(if b[i] then 1 else 0 for i in 1:size(b, 1));
// end Modelica.Math.BooleanVectors.countTrue;
//
// function Modelica.Math.BooleanVectors.firstTrueIndex \"Returns the index of the first true element of a Boolean vector\"
Expand Down Expand Up @@ -114,14 +114,14 @@ instantiateModel(Modelica.Blocks.Examples.BooleanNetwork1); getErrorString();
// Boolean and1.u[2] \"Vector of Boolean input signals\";
// Boolean and1.u[3] \"Vector of Boolean input signals\";
// Boolean and1.y \"Boolean output signal\";
// parameter Real booleanPulse1.width(min = 1e-060, max = 100.0) = 20.0 \"Width of pulse in % of period\";
// parameter Real booleanPulse1.period(quantity = \"Time\", unit = \"s\", min = 1e-060, start = 1.0) = 1.0 \"Time for one period\";
// parameter Real booleanPulse1.width(min = 1e-60, max = 100.0) = 20.0 \"Width of pulse in % of period\";
// parameter Real booleanPulse1.period(quantity = \"Time\", unit = \"s\", min = 1e-60, start = 1.0) = 1.0 \"Time for one period\";
// parameter Real booleanPulse1.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Time instant of first pulse\";
// Boolean booleanPulse1.y \"Connector of Boolean output signal\";
// protected parameter Real booleanPulse1.Twidth(quantity = \"Time\", unit = \"s\") = booleanPulse1.period * booleanPulse1.width / 100.0 \"width of one pulse\";
// protected discrete Real booleanPulse1.pulsStart(quantity = \"Time\", unit = \"s\") \"Start time of pulse\";
// parameter Real booleanPulse2.width(min = 1e-060, max = 100.0) = 80.0 \"Width of pulse in % of period\";
// parameter Real booleanPulse2.period(quantity = \"Time\", unit = \"s\", min = 1e-060, start = 1.0) = 1.0 \"Time for one period\";
// parameter Real booleanPulse2.width(min = 1e-60, max = 100.0) = 80.0 \"Width of pulse in % of period\";
// parameter Real booleanPulse2.period(quantity = \"Time\", unit = \"s\", min = 1e-60, start = 1.0) = 1.0 \"Time for one period\";
// parameter Real booleanPulse2.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Time instant of first pulse\";
// Boolean booleanPulse2.y \"Connector of Boolean output signal\";
// protected parameter Real booleanPulse2.Twidth(quantity = \"Time\", unit = \"s\") = booleanPulse2.period * booleanPulse2.width / 100.0 \"width of one pulse\";
Expand Down Expand Up @@ -231,10 +231,10 @@ instantiateModel(Modelica.Blocks.Examples.BooleanNetwork1); getErrorString();
// Boolean rSFlipFlop.pre.y \"Connector of Boolean output signal\";
// Boolean rSFlipFlop.S;
// Boolean rSFlipFlop.R;
// parameter Real sampleTriggerSet.period(quantity = \"Time\", unit = \"s\", min = 1e-060, start = 0.01) = 0.5 \"Sample period\";
// parameter Real sampleTriggerSet.period(quantity = \"Time\", unit = \"s\", min = 1e-60, start = 0.01) = 0.5 \"Sample period\";
// parameter Real sampleTriggerSet.startTime(quantity = \"Time\", unit = \"s\") = 0.0 \"Time instant of first sample trigger\";
// Boolean sampleTriggerSet.y \"Connector of Boolean output signal\";
// parameter Real sampleTriggerReset.period(quantity = \"Time\", unit = \"s\", min = 1e-060, start = 0.01) = 0.5 \"Sample period\";
// parameter Real sampleTriggerReset.period(quantity = \"Time\", unit = \"s\", min = 1e-60, start = 0.01) = 0.5 \"Sample period\";
// parameter Real sampleTriggerReset.startTime(quantity = \"Time\", unit = \"s\") = 0.3 \"Time instant of first sample trigger\";
// Boolean sampleTriggerReset.y \"Connector of Boolean output signal\";
// initial equation
Expand Down

0 comments on commit 1d6f8f5

Please sign in to comment.