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;
// }
}
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;
}
}
Aggregations