Changeset 13712


Ignore:
Timestamp:
Oct 9, 2019 2:05:48 PM (2 months ago)
Author:
Christian Andersson
Message:

Updated evaluator tests. Related to ticket:5837

Location:
branches/dev-cw-evaluator
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-cw-evaluator/Python/src/tests_jmodelica/files/Modelica/ExtFunctionTests.mo

    r13562 r13712  
    3535    end i_ii;
    3636   
    37     Integer c = i_ii(1,2);
     37    constant Integer c = i_ii(1,2);
    3838end Evaluator_Integer;
    3939
     
    6262    end iddpR_ddddddddddd_;
    6363   
    64     R c = iddpR_ddddddddddd_(1,2.0,3.0);
     64    constant R c = iddpR_ddddddddddd_(1,2.0,3.0);
    6565end Evaluator_Record;
    6666
  • branches/dev-cw-evaluator/Python/src/tests_jmodelica/general/test_extfunctions.py

    r13646 r13712  
    2626from pymodelica import compile_fmu
    2727from pymodelica.common.core import get_platform_dir, create_temp_dir
    28 from pyfmi import load_fmu
     28from pyfmi import load_fmu, FMUModelME2
    2929from pyfmi.fmi import FMUException
    3030from tests_jmodelica import testattr, get_files_path
     
    6666    def test_add(self):
    6767        cpath = "ExtFunctionTests.Evaluator_Add"
    68         fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log.txt")
     68        fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt")
    6969       
    7070        nbr_of_evaluator_calls = 0
     
    7575        assert nbr_of_evaluator_calls == 2, "Wrong number of external function calls, check log."
    7676       
    77         model = load_fmu(fmu_name)
    78        
    79         assert model.get("c") == 3, model.get("c")
    80         assert model.get("d") == 3, model.get("d")
     77        model = FMUModelME2(fmu_name, _connect_dll=False)
     78       
     79        assert model.get_variable_start("c") == 3, model.get_variable_start("c")
     80        assert model.get_variable_start("d") == 3, model.get_variable_start("d")
    8181   
    8282    @testattr(stddist_base = True)
     
    110110    def test_double_return(self):
    111111        cpath = "ExtFunctionTests.Evaluator_Double"
    112         fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log.txt")
     112        fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt")
    113113       
    114114        nbr_of_evaluator_calls = 0
     
    119119        assert nbr_of_evaluator_calls == 2, "Wrong number of external function calls, check log."
    120120       
    121         model = load_fmu(fmu_name)
    122        
    123         assert model.get("c") == 3.0, model.get("c")
    124         assert model.get("d") == 9.0, model.get("d")
     121        model = FMUModelME2(fmu_name, _connect_dll=False)
     122       
     123        assert model.get_variable_start("c") == 3.0, model.get_variable_start("c")
     124        assert model.get_variable_start("d") == 9.0, model.get_variable_start("d")
    125125   
    126126    @testattr(stddist_base = True)
    127127    def test_integer_return(self):
    128128        cpath = "ExtFunctionTests.Evaluator_Integer"
    129         fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log.txt")
     129        fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt")
    130130       
    131131        nbr_of_evaluator_calls = 0
     
    136136        assert nbr_of_evaluator_calls == 1, "Wrong number of external function calls, check log."
    137137       
    138         model = load_fmu(fmu_name)
    139        
    140         assert model.get("c") == 3.0, model.get("c")
     138        model = FMUModelME2(fmu_name, _connect_dll=False)
     139       
     140        assert model.get_variable_start("c") == 3.0, model.get_variable_start("c")
    141141   
    142142    @testattr(stddist_base = True)
    143143    def test_record(self):
    144144        cpath = "ExtFunctionTests.Evaluator_Record"
    145         fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, compiler_log_level="d:log.txt")
     145        fmu_name = compile_fmu(cpath, self.fpath, compiler_options={"external_constant_evaluation_dynamic":True}, version=2.0, compiler_log_level="d:log.txt")
    146146       
    147147        nbr_of_evaluator_calls = 0
     
    152152        assert nbr_of_evaluator_calls == 1, "Wrong number of external function calls, check log."
    153153       
    154         model = load_fmu(fmu_name)
    155        
    156         assert model.get("c.x0") == 1.0, model.get("c.x0")
    157         assert model.get("c.x1") == 2.0, model.get("c.x1")
    158         assert model.get("c.x2") == 3.0, model.get("c.x2")
    159         assert model.get("c.x3") == 3.0, model.get("c.x3")
    160         assert model.get("c.x4") == 4.0, model.get("c.x4")
    161         assert model.get("c.x5") == 5.0, model.get("c.x5")
    162         assert model.get("c.x6") == 6.0, model.get("c.x6")
    163         assert model.get("c.x7") == 7.0, model.get("c.x7")
    164         assert model.get("c.x8") == 8.0, model.get("c.x8")
    165         assert model.get("c.x9") == 9.0, model.get("c.x9")
    166         assert model.get("c.x10") == 10.0, model.get("c.x10")
     154        model = FMUModelME2(fmu_name, _connect_dll=False)
     155       
     156        assert model.get_variable_start("c.x0") == 1.0, model.get_variable_start("c.x0")
     157        assert model.get_variable_start("c.x1") == 2.0, model.get_variable_start("c.x1")
     158        assert model.get_variable_start("c.x2") == 3.0, model.get_variable_start("c.x2")
     159        assert model.get_variable_start("c.x3") == 3.0, model.get_variable_start("c.x3")
     160        assert model.get_variable_start("c.x4") == 4.0, model.get_variable_start("c.x4")
     161        assert model.get_variable_start("c.x5") == 5.0, model.get_variable_start("c.x5")
     162        assert model.get_variable_start("c.x6") == 6.0, model.get_variable_start("c.x6")
     163        assert model.get_variable_start("c.x7") == 7.0, model.get_variable_start("c.x7")
     164        assert model.get_variable_start("c.x8") == 8.0, model.get_variable_start("c.x8")
     165        assert model.get_variable_start("c.x9") == 9.0, model.get_variable_start("c.x9")
     166        assert model.get_variable_start("c.x10") == 10.0, model.get_variable_start("c.x10")
    167167   
    168168class TestExternalStatic:
  • branches/dev-cw-evaluator/RuntimeLibrary/src/evaluator/jmi_evaluator.c

    r13602 r13712  
    246246}
    247247
     248void jmi_call_integer_fcn_ii(generic_funcptr fcn, int *out) {
     249    JMI_DEF(INT, arg_0)
     250    JMI_DEF(INT, arg_1)
     251    JMI_DEF(INT_EXT, tmp_0)
     252    JMI_DEF(INT_EXT, tmp_1)
     253
     254    JMCEVAL_parse(Integer, arg_0);
     255    JMCEVAL_parse(Integer, arg_1);
     256
     257    JMCEVAL_check("CALC");
     258    if (JMCEVAL_try()) {
     259        /* Calc phase */
     260        tmp_0 = (int)arg_0;
     261        tmp_1 = (int)arg_1;
     262        *out = ((f_i_ii)fcn)(arg_0, arg_1);
     263    }
     264    else {
     265        JMCEVAL_failed();
     266    }
     267}
     268
    248269void jmi_call_integer_fcn(generic_funcptr fcn, const char* inputs) {
    249270    JMI_DEF(INT, i_output)
     
    259280    } else if (strcmp(inputs, "s,s,i,") == 0) {
    260281        jmi_call_integer_fcn_ssi(fcn, &tmp_output);
     282    } else if (strcmp(inputs, "i,i,") == 0) {
     283        jmi_call_integer_fcn_ii(fcn, &tmp_output);
    261284    } else {
    262285        printf(ERROR_NOT_SUPPORTED_INPUT_ARGS_MSG);
Note: See TracChangeset for help on using the changeset viewer.