Search in sources :

Example 1 with PositiveAnalyser

use of org.eclipse.n4js.analysis.PositiveAnalyser in project n4js by eclipse.

the class AbstractECMATestSuiteBase method test.

/**
 * generated instances of the tests will use this base implementation
 */
@Test
public void test() throws Exception {
    if (this.parserN4JS == null) {
        throw new Error("parser instance is null");
    }
    String code = TestCodeProvider.getContentsFromFileEntry(config.entry, config.resourceName);
    if (code == null) {
        throw new Error("test data code instance is null");
    }
    Analyser analyser = createAnalyzer(code);
    XtextResourceSet resourceSet = resourceSetProvider.get();
    URI uri = URI.createURI(config.entry.getName());
    if (isStrictModeTestCase(code)) {
        uri = uri.trimFileExtension().appendFileExtension("n4js");
    }
    try {
        Script script = doParse(code, uri, resourceSet, analyser);
        if (config.isValidator()) {
            Analyser syntaxAnalyzer = new PositiveAnalyser(logger, tester);
            syntaxAnalyzer.analyse(script, config.entry.getName(), code);
            // TODO figure out why we ignore the validation result
            validationTestHelper.validate(script);
        }
        analyser.analyse(script, config.entry.getName(), code);
    } catch (Throwable t) {
        if (!t.getStackTrace()[10].getClassName().contains("Black")) {
            System.out.println(config.entry.getName());
        }
        throw t;
    }
}
Also used : PositiveAnalyser(org.eclipse.n4js.analysis.PositiveAnalyser) Script(org.eclipse.n4js.n4JS.Script) NegativeAnalyser(org.eclipse.n4js.analysis.NegativeAnalyser) Analyser(org.eclipse.n4js.analysis.Analyser) PositiveAnalyser(org.eclipse.n4js.analysis.PositiveAnalyser) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test) AbstractJSLibTest(org.eclipse.n4js.AbstractJSLibTest)

Aggregations

URI (org.eclipse.emf.common.util.URI)1 AbstractJSLibTest (org.eclipse.n4js.AbstractJSLibTest)1 Analyser (org.eclipse.n4js.analysis.Analyser)1 NegativeAnalyser (org.eclipse.n4js.analysis.NegativeAnalyser)1 PositiveAnalyser (org.eclipse.n4js.analysis.PositiveAnalyser)1 Script (org.eclipse.n4js.n4JS.Script)1 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)1 Test (org.junit.Test)1