Skip to content

Commit

Permalink
Adding test for parameter record bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Oct 13, 2017
1 parent 8f278a2 commit 505f10d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions simulation/modelica/records/Makefile
@@ -1,9 +1,9 @@
TEST = ../../../rtest -v

TESTFILES = \
ATotal.mos \
InOutRecord.mos \
ATotal.mos

TestComplexSum1.mos


# test that currently fail. Move up when fixed.
Expand Down
13 changes: 13 additions & 0 deletions simulation/modelica/records/TestComplexSum.mo
@@ -0,0 +1,13 @@
function 'sum' "Return sum of complex vector"
input Complex v[:] "Vector";
output Complex result "Complex sum of vector elements";
algorithm
result:=Complex(sum(v[i].re for i in 1:size(v,1)), sum(v[i].im for i in 1:size(v,1)));
annotation(Inline=true);
end 'sum';

model TestComplexSum1
parameter Complex a[2]={Complex(1,2),Complex(2,3)};
parameter Complex sum1 = 'sum'(a);
parameter Complex sum2 = Complex(sum(a.re),sum(a.im));
end TestComplexSum1;
23 changes: 23 additions & 0 deletions simulation/modelica/records/TestComplexSum1.mos
@@ -0,0 +1,23 @@
// status: correct

loadFile("TestComplexSum.mo");getErrorString();
loadModel(Complex,{"3.2.2"});getErrorString();
simulate(TestComplexSum1,simflags="-output sum1.re,sum1.im,sum2.re,sum2.im");getErrorString();

// Result:
// true
// ""
// true
// ""
// record SimulationResult
// resultFile = "TestComplexSum1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'TestComplexSum1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-output sum1.re,sum1.im,sum2.re,sum2.im'",
// messages = "stdout | info | The initialization finished successfully without homotopy method.
// time=1,sum1.re=3,sum1.im=5,sum2.re=3,sum2.im=5
// stdout | info | The simulation finished successfully.
// "
// end SimulationResult;
// "[simulation/modelica/records/TestComplexSum.mo:11:3-11:36:writable] Notification: Moving binding to equation section and setting fixed attribute of sum1.re to false. This is done to work around a compiler design flaw (there is no good way to represent bindings that span multiple variables).
// [simulation/modelica/records/TestComplexSum.mo:11:3-11:36:writable] Notification: Moving binding to equation section and setting fixed attribute of sum1.im to false. This is done to work around a compiler design flaw (there is no good way to represent bindings that span multiple variables).
// "
// endResult

0 comments on commit 505f10d

Please sign in to comment.