Skip to content

Commit

Permalink
Add test for clashes with reserved names
Browse files Browse the repository at this point in the history
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Jan 29, 2017
1 parent 2defa71 commit 7a939dc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions openmodelica/cppruntime/Makefile
Expand Up @@ -13,6 +13,7 @@ clockedTypesTest.mos \
clockedTest.mos \
externalArrayInputTest.mos \
mathFunctionsTest.mos \
nameClashTest.mos \
functionPointerTest.mos \
recordTupleReturnTest.mos \
RefArrayDim2.mos \
Expand Down
48 changes: 48 additions & 0 deletions openmodelica/cppruntime/nameClashTest.mos
@@ -0,0 +1,48 @@
// name: nameClashTest
// keywords: reserved names
// status: correct
// teardown_command: rm -f *NameClash.Test*

setCommandLineOptions("+simCodeTarget=Cpp");

loadModel(Modelica);
loadString("
package NameClash
function f
input Real simTime;
output Real mydouble = simTime; // fixme: double does not work in functions!
output Integer int = integer(simTime);
output String string = String(simTime);
end f;
model Test
Real simTime = time;
Real double;
Integer int;
String string;
equation
(double, int, string) = f(simTime);
annotation(experiment(StopTime = 0));
end Test;
end NameClash;
");
getErrorString();

simulate(NameClash.Test);
val(double, 0);
val(int, 0);
getErrorString();

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

0 comments on commit 7a939dc

Please sign in to comment.