Skip to content

Commit

Permalink
Add first test for ArraySlice
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke committed Mar 27, 2016
1 parent 37fcc39 commit fe83e7a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions openmodelica/cppruntime/Makefile
Expand Up @@ -4,6 +4,7 @@ TESTFILES = \
tearnonlin1.mos \
WhenStatement1.mos \
BouncingBall.mos \
arraySliceTest.mos \
clockedTest.mos \
clockedEventTest.mos \
clockedSolverTest.mos \
Expand Down
43 changes: 43 additions & 0 deletions openmodelica/cppruntime/arraySliceTest.mos
@@ -0,0 +1,43 @@
// name: arrayAppendTest
// keywords: slice array
// status: correct
// teardown_command: rm -f *ArraySlice.Test*

setCommandLineOptions("+simCodeTarget=Cpp");

loadString("
package ArraySlice
model Test
Real[:] v = {1, 2, 3, 4, 5};
Real[:] w = reverse(v);
annotation(experiment(StopTime = 0));
end Test;
function reverse
input Real[:] v;
output Real[size(v, 1) - 1] w;
algorithm
w := v[size(w, 1):-1:1];
end reverse;
end ArraySlice;
");
getErrorString();

simulate(ArraySlice.Test);
getErrorString();

val(w[1], 0);
val(w[4], 0);

// Result:
// true
// true
// ""
// record SimulationResult
// resultFile = "ArraySlice.Test_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 0.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'ArraySlice.Test', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// 4.0
// 1.0
// endResult

0 comments on commit fe83e7a

Please sign in to comment.