Changeset 14105


Ignore:
Timestamp:
Nov 18, 2019 12:38:34 PM (4 weeks ago)
Author:
Jesper Mattsson
Message:

Added support for compiling with modifications to test framework. (#5879)

Location:
branches/dev-mo-2559/Compiler
Files:
2 edited

Legend:

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

    r13948 r14105  
    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-2559/Compiler/TestFramework/src/jastadd/TestCase.jrag

    r13396 r14105  
    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            boolean addParen = !modification.startsWith("(");
     317            if (addParen) {
     318                buf.append('(');
     319            }
     320            buf.append(modification);
     321            if (addParen) {
     322                buf.append(')');
     323            }
     324        }
     325        return buf.toString();
     326    }
     327   
    294328    /**
    295329     * @return the beginLine
     
    600634        // Instantiate and check for errors.
    601635        InstProgramRoot ipr = sr.getProgram().getInstProgramRoot();
     636        String classNameWithMod = makeClassNameWithMod();
    602637        Collection<Problem> problems = null;
    603638        try {
    604             ipr.checkErrorsInInstClass(className, checkType);
     639            ipr.checkErrorsInInstClass(classNameWithMod, checkType);
    605640            problems = sr.collectWarnings();
    606641        } catch (CompilerException e) {
     
    610645       
    611646        // Test instantiated class
    612         InstClassDecl icd = ipr.instantiateModel(getClassName());
     647        InstClassDecl icd = ipr.instantiateModel(classNameWithMod);
    613648        uif.modelInstantiated(icd);
    614649        if (testInstantiated(icd)) return;
Note: See TracChangeset for help on using the changeset viewer.