Skip to content

Commit

Permalink
Added testcase EnumFuncIf.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Dec 2, 2016
1 parent 763e605 commit 6b50eb6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 20 deletions.
41 changes: 41 additions & 0 deletions flattening/modelica/enums/EnumFuncIf.mo
@@ -0,0 +1,41 @@
// name: EnumRange
// keywords: enumeration enum range reduction
// status: correct
// cflags: --condenseArrays=false
//
// Tests that enum dimensions are used properly when an if-expression containing
// a function call is expanded.
//

function f
input Real x;
output Boolean out;
algorithm
end f;

type E = enumeration(A, B, C);

model EnumFuncIf
Real x[E];
Real y;
equation
x = if f(y) then zeros(size(E, 1)) else x / y;
end EnumFuncIf;

// Result:
// function f
// input Real x;
// output Boolean out;
// end f;
//
// class EnumFuncIf
// Real x[E.A];
// Real x[E.B];
// Real x[E.C];
// Real y;
// equation
// x[E.A] = if f(y) then 0.0 else x[E.A] / y;
// x[E.B] = if f(y) then 0.0 else x[E.B] / y;
// x[E.C] = if f(y) then 0.0 else x[E.C] / y;
// end EnumFuncIf;
// endResult
1 change: 1 addition & 0 deletions flattening/modelica/enums/Makefile
Expand Up @@ -21,6 +21,7 @@ EnumConnectArray.mo \
EnumDimSum.mo \
EnumFor.mo \
EnumFor2.mo \
EnumFuncIf.mo \
EnumInnerOuterDim.mo \
EnumInvalidLiteral.mo \
EnumMatrixProduct.mo \
Expand Down
20 changes: 0 additions & 20 deletions flattening/modelica/scodeinst/inst5.mo

This file was deleted.

0 comments on commit 6b50eb6

Please sign in to comment.