Changeset 14253


Ignore:
Timestamp:
Dec 2, 2019 5:22:19 PM (11 days ago)
Author:
amartensen
Message:

#5879 added tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-2559/Compiler/ModelicaFrontEnd/test/modelica/InnerOuterTests.mo

    r10783 r14253  
    13521352
    13531353
     1354model SetOuter
     1355    outer parameter Real x;
     1356annotation(
     1357__Modelon(inners(x=1)),
     1358__JModelica(UnitTesting(tests={
     1359    FlatteningTestCase(
     1360        name="SetOuter",
     1361        description="modifiers set on outers from an annotation(_Modelon(inners(..))) are applied",
     1362        flatModel="
     1363fclass InnerOuterTests.SetOuter
     1364 parameter Real x = 1 /* 1 */;
     1365end InnerOuterTests.SetOuter;
     1366")})));
     1367end SetOuter;
     1368
     1369model SetOuterNameLookup
     1370    outer parameter X x;
     1371    model X
     1372        Real x;
     1373    end X;
     1374annotation(
     1375__Modelon(inners(x(x=1))),
     1376__JModelica(UnitTesting(tests={
     1377    FlatteningTestCase(
     1378        name="SetOuterNameLookup",
     1379        description="modifiers set on outers from an annotation(_Modelon(inners(x(x=...)))) where the component has a component with the same name",
     1380        flatModel="
     1381fclass InnerOuterTests.SetOuterNameLookup
     1382 parameter Real x.x = 1 /* 1 */;
     1383end InnerOuterTests.SetOuterNameLookup;
     1384")})));
     1385end SetOuterNameLookup;
     1386
     1387model TopC
     1388   constant Real y = 1;
     1389end TopC;
     1390model SetOuterRHS
     1391    outer parameter Real x, y;
     1392    model C
     1393       constant Real x = 1;
     1394    end C;
     1395annotation(
     1396__Modelon(inners(x=C.x,y=TopC.y)),
     1397__JModelica(UnitTesting(tests={
     1398    FlatteningTestCase(
     1399        name="SetOuterRHS",
     1400        description="modifiers set on outers from an annotation(_Modelon(inners(...))) where the components have a right-hand side that are component accesses to constants which needs name lookup. Test that name lookup finds both declarations, one decl when a constant is declared in a class inside the class under test and one decl when a constant is declared in a sibling class",
     1401        flatModel="
     1402fclass InnerOuterTests.SetOuterRHS
     1403 parameter Real x = 1.0 /* 1.0 */;
     1404 parameter Real y = 1.0 /* 1.0 */;
     1405end InnerOuterTests.SetOuterRHS;
     1406")})));
     1407end SetOuterRHS;
     1408
     1409model SetOuterRedeclare
     1410    outer parameter M m;
     1411    model M
     1412        replaceable X x;
     1413    end M;
     1414    model X
     1415        Real x;
     1416    end X;
     1417    model Y
     1418        Real x;
     1419        Real y;
     1420    end Y;
     1421annotation(
     1422__Modelon(inners(m(redeclare Y x(y=1)))),
     1423__JModelica(UnitTesting(tests={
     1424    FlatteningTestCase(
     1425        name="SetOuterRedeclare",
     1426        description="modifiers set on outers from an annotation(_Modelon(inners(x(x=...)))) where the component gets redeclared. The redeclareing component has an additional component which verifies that the redeclaration is applied",
     1427        flatModel="
     1428fclass InnerOuterTests.SetOuterRedeclare
     1429 parameter Real m.x.x;
     1430 parameter Real m.x.y = 1 /* 1 */;
     1431end InnerOuterTests.SetOuterRedeclare;
     1432")})));
     1433end SetOuterRedeclare;
     1434
     1435model SetOuterNoParens
     1436    parameter Real x;
     1437annotation(
     1438__JModelica(UnitTesting(tests={
     1439    FlatteningTestCase(
     1440        name="SetOuterNoParens",
     1441        description="
     1442annotation(_Modelon(inners(..))) on the command line does not require the prefixing of a superfluous set of ()
     1443TODO should get the same result as SetOuter, the constant evaluated binding expression = 1 /* 1 */ is missing
     1444",
     1445        flatModel="
     1446fclass InnerOuterTests.SetOuterNoParens
     1447 parameter Real x;
     1448end InnerOuterTests.SetOuterNoParens;
     1449")})));
     1450end SetOuterNoParens;
     1451
     1452model SetOuterComposite
     1453    outer parameter R r;
     1454    record R
     1455      Integer n;
     1456      Real[n] xs;
     1457    end R;
     1458annotation(
     1459__Modelon(inners(r(n=2))),
     1460__JModelica(UnitTesting(tests={
     1461    FlatteningTestCase(
     1462        name="SetOuterComposite",
     1463        description="modifiers set on outers from an annotation(_Modelon(inners(..))) are applied",
     1464        flatModel="
     1465fclass InnerOuterTests.SetOuterComposite
     1466 parameter InnerOuterTests.SetOuterComposite.R r(n = 2,xs(size() = {2}));
     1467
     1468public
     1469 record InnerOuterTests.SetOuterComposite.R
     1470  discrete Integer n;
     1471  Real xs[n];
     1472 end InnerOuterTests.SetOuterComposite.R;
     1473
     1474end InnerOuterTests.SetOuterComposite;
     1475")})));
     1476end SetOuterComposite;
     1477
     1478model SetOuterError
     1479    outer parameter Real x;
     1480annotation(
     1481__Modelon(inners(accessNonExistingComponent=1)),
     1482__JModelica(UnitTesting(tests={
     1483    ErrorTestCase(
     1484        name="SetOuterError",
     1485        description="modifiers set on outers from an annotation(_Modelon(inners(..))) are error checked, so that accesses to components that do not exist in the class yield an error",
     1486        errorMessage="
     1487
     1488
     1489Error at line 4, column 18, in file '...':
     1490  Cannot find component declaration for accessNonExistingComponent
     1491")})));
     1492end SetOuterError;
     1493
    13541494end InnerOuterTests;
Note: See TracChangeset for help on using the changeset viewer.