Search in sources :

Example 1 with Analyser

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

the class ECMA6TestSuite method test.

/**
 * generated instances of the tests will use this base implementation
 */
@Override
@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());
    // we do the same here
    if (code.contains("flags: [onlyStrict]")) {
        // by using the proper file extension
        uri = uri.trimFileExtension().appendFileExtension("n4js");
    }
    Script script = doParse(code, uri, resourceSet, analyser);
    if (config.isValidator()) {
        // thus the negative tests will likely succeed for bogus reasons
        throw new IllegalStateException(config.entry.getName());
    }
    // try {
    analyser.analyse(script, config.entry.getName(), code);
// } catch (AssertionError e) {
// System.out.println(config.entry.getName());
// throw e;
// }
}
Also used : 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)

Example 2 with Analyser

use of org.eclipse.n4js.analysis.Analyser 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)2 Analyser (org.eclipse.n4js.analysis.Analyser)2 NegativeAnalyser (org.eclipse.n4js.analysis.NegativeAnalyser)2 PositiveAnalyser (org.eclipse.n4js.analysis.PositiveAnalyser)2 Script (org.eclipse.n4js.n4JS.Script)2 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)2 Test (org.junit.Test)2 AbstractJSLibTest (org.eclipse.n4js.AbstractJSLibTest)1