Changeset 14164


Ignore:
Timestamp:
Nov 25, 2019 12:32:01 PM (11 days ago)
Author:
molsson
Message:

Merged revision(s) 14105-14107, 14121, 14141 from branches/dev-mo-2559:
Added support for compiling with modifications to test framework. (#5879)
........
Removed automatic adding of missing parenthesis when compiling with modifications in unit test. (#5879)
........
Added an implicit space before modification added for unit test, to avoid syntax error when giving only annotation. (#5879)
........
#5879 improved name lookup in InstGeneratedInner. removed implicit space added in r14107.
........
#5879 using vendorAnnotation() instead of hard-coded string
........

Location:
branches/dev-mo-st
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mo-st

  • branches/dev-mo-st/Compiler/ModelicaFrontEnd/src/jastadd/instance/InnerOuter.jrag

    r13948 r14164  
    9393    syn nta List<InstGeneratedInner> InstClassDecl.getInstGeneratedInners() = new List<InstGeneratedInner>();
    9494
    95     eq InstGeneratedInner.getChild().myEnvironment() = new Environment();
    96     eq InstGeneratedInner.getChild().myEnvironment(String name) = new Environment();
     95    eq InstGeneratedInner.getChild().lookupInstComponentInInstElement(String name) {
     96        InstComponentDecl icd = getInstComponentDecl();
     97        if (icd.matches(name)) {
     98            return InstLookupResult.<InstComponentDecl>found(icd);
     99        }
     100        return icd.genericLookupInstComponent(name);
     101    }
     102
     103    eq InstGeneratedInner.getChild().myEnvironment()            = new Environment().mergeInnerClone(getGeneratedInnerModifications());
     104    eq InstGeneratedInner.getChild().myEnvironment(String name) = new Environment().mergeInnerClone(getGeneratedInnerModifications()).filter(name);
     105   
     106    syn nta List<InstModification> InstGeneratedInner.getGeneratedInnerModifications() {
     107        List<InstModification> res = new List<>();
     108        SrcModification annotation = myInnerAnnotation(name());
     109        if (annotation != null) {
     110            res.add(annotation.newInstModification());
     111        }
     112        return res;
     113    }
     114   
     115    inh SrcModification InstGeneratedInner.myInnerAnnotation(String name);
     116    eq BaseNode.getChild().myInnerAnnotation(String name) = null;
     117    eq InstClassDecl.getChild().myInnerAnnotation(String name) {
     118        AnnotationNode an = annotation().vendorNode().forPath("inners").forPath(name);
     119        if (!an.exists()) {
     120            return null;
     121        }
     122        return (SrcModification) an.ast();
     123    }
    97124
    98125    public InstGeneratedInner.InstGeneratedInner(InstClassDecl parent, InstComponentDecl outer, InstComponentDecl nonInner) {
  • branches/dev-mo-st/Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo

    r13948 r14164  
    42944294end OrderFile4;
    42954295
     4296
     4297model ModificationOnTest1
     4298    Real x = time;
     4299
     4300annotation(__JModelica(UnitTesting(tests={
     4301    FlatteningTestCase(
     4302        name="ModificationOnTest1",
     4303        description="Check that a modification to the test class can be added in test annotation",
     4304        modification="(x=2)",
     4305        flatModel="
     4306fclass NameTests.ModificationOnTest1
     4307 Real x = 2;
     4308end NameTests.ModificationOnTest1;
     4309")})));
     4310end ModificationOnTest1;
     4311
    42964312end NameTests;
  • branches/dev-mo-st/Compiler/TestFramework/src/jastadd/TestCase.jrag

    r13396 r14164  
    6060    private String sourceFileName = null;
    6161    private String className = null;
     62    private String modification = null;
    6263    private int beginLine = -1;
    6364
     
    292293    }
    293294
     295    /**
     296     * @return the modification
     297     */
     298    public String getModification() {
     299        return modification;
     300    }
     301
     302    /**
     303     * @param name the modification to set
     304     */
     305    public void setModification(String modification) {
     306        this.modification = modification;
     307    }
     308
     309    /**
     310     * Returns the class name with any set modification added to it,
     311     * using the syntax accepted by ModelicaCompiler.
     312     */
     313    public String makeClassNameWithMod() {
     314        StringBuilder buf = new StringBuilder(className);
     315        if (modification != null) {
     316            buf.append(modification);
     317        }
     318        return buf.toString();
     319    }
     320   
    294321    /**
    295322     * @return the beginLine
     
    600627        // Instantiate and check for errors.
    601628        InstProgramRoot ipr = sr.getProgram().getInstProgramRoot();
     629        String classNameWithMod = makeClassNameWithMod();
    602630        Collection<Problem> problems = null;
    603631        try {
    604             ipr.checkErrorsInInstClass(className, checkType);
     632            ipr.checkErrorsInInstClass(classNameWithMod, checkType);
    605633            problems = sr.collectWarnings();
    606634        } catch (CompilerException e) {
     
    610638       
    611639        // Test instantiated class
    612         InstClassDecl icd = ipr.instantiateModel(getClassName());
     640        InstClassDecl icd = ipr.instantiateModel(classNameWithMod);
    613641        uif.modelInstantiated(icd);
    614642        if (testInstantiated(icd)) return;
Note: See TracChangeset for help on using the changeset viewer.