Changeset 13647


Ignore:
Timestamp:
Oct 2, 2019 10:28:32 PM (2 months ago)
Author:
Christian Andersson
Message:

Added basic JUnit tests for the evaluator. Related to ticket:5837

Location:
branches/dev-cw-evaluator/Compiler/ModelicaCBackEnd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-evaluator/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExternalCeval.jrag

    r13630 r13647  
    394394            }
    395395        }
     396    }
     397   
     398    public String FClass.externalCTypes() {
     399        StringBuilder sb = new StringBuilder();
     400        for (FExternalStmt stmt : myExternals()) {
     401            if (stmt.dynamicEvaluatorEnabled()) {
     402                sb.append(stmt.getName());
     403                sb.append("\n");
     404                sb.append(stmt.functionReturnArgSerialized());
     405                sb.append("\n");
     406                sb.append(stmt.functionArgsSerialized());
     407                sb.append("\n");
     408            }
     409        }
     410        return sb.toString();
    396411    }
    397412
  • branches/dev-cw-evaluator/Compiler/ModelicaCBackEnd/test/modelica/CCodeGenExternalCevalTests.mo

    r12934 r13647  
    1717
    1818package CCodeGenExternalCevalTests
     19
     20model ExtDynFcn1
     21        type E = enumeration(A,B);
     22    function f
     23        input Real a1;
     24        input Integer a2;
     25        input Boolean a3;
     26        input String a4;
     27        input E a5;
     28        output Real b1;
     29        output Integer b2;
     30        output Boolean b3;
     31        output String b4;
     32        output E b5;
     33        external;
     34    end f;
     35   
     36    Real x1;
     37    Integer x2;
     38    Boolean x3;
     39    String x4;
     40    E x5;
     41equation
     42    (x1,x2,x3,x4,x5) = f(1,2,true,"s",E.A);
     43
     44    annotation(__JModelica(UnitTesting(tests={
     45        FClassMethodTestCase(
     46            name="ExtDynFcn1",
     47            methodName="externalCTypes",
     48            description="Verifies that external objects are not handled by the dynamic evaluator",
     49            methodResult="
     50f
     51void
     52d,i,i,s,i,*d,*i,*i,*s,*i,
     53")})));
     54end ExtDynFcn1;
    1955
    2056model Scalar
     
    792828end ExtObj5;
    793829
     830model ExtDynObj1
     831    function use1
     832        input  Os.Obj1 o1;
     833        output Real x;
     834        external annotation(Library="extObjectsUse", Include="#include \"extObjectsUse.h\"",
     835            LibraryDirectory="modelica://Library2", IncludeDirectory="Include2");
     836    end use1;
     837
     838    Os.Obj1 o1 = Os.Obj1(3.13, 3, true, "A message");
     839    Real x = use1(o1);
     840
     841    annotation(__JModelica(UnitTesting(tests={
     842        FClassMethodTestCase(
     843            name="ExtDynObj1",
     844            methodName="externalCTypes",
     845            description="Verifies that external objects are not handled by the dynamic evaluator",
     846            methodResult="
     847")})));
     848end ExtDynObj1;
     849
     850
    794851model Dgelsx
    795852    function dgelsx
Note: See TracChangeset for help on using the changeset viewer.