Chromium Code Reviews| Index: tests/compiler/dart2js/resolver_test.dart |
| diff --git a/tests/compiler/dart2js/resolver_test.dart b/tests/compiler/dart2js/resolver_test.dart |
| index d1970ac286c647be5e608faccb25e9ab0f1a1081..06f0de08ce166d5318d1897ae8c2bcca31952ac4 100644 |
| --- a/tests/compiler/dart2js/resolver_test.dart |
| +++ b/tests/compiler/dart2js/resolver_test.dart |
| @@ -132,11 +132,12 @@ class Bar extends Foo implements X<Bar> {} |
| """); |
| compiler.resolveStatement("Bar bar;"); |
| ClassElement classBar = compiler.mainApp.find("Bar"); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.MULTI_INHERITANCE, |
| - compiler.errors[0].message.kind); |
| - Expect.equals(0, compiler.crashes.length); |
| + collector.errors.first.message.kind); |
| + Expect.equals(0, collector.crashes.length); |
| }), |
| ]); |
| } |
| @@ -172,19 +173,21 @@ Future testTypeVariables() { |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript('class Foo<T, U> {}'); |
| compiler.resolveStatement('Foo<notype, int> x;'); |
| - Expect.equals(1, compiler.warnings.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.warnings.length); |
| Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE, |
| - compiler.warnings[0].message.kind); |
| - Expect.equals(0, compiler.errors.length); |
| + collector.warnings.first.message.kind); |
| + Expect.equals(0, collector.errors.length); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript('class Foo<T, U> {}'); |
| compiler.resolveStatement('var x = new Foo<notype, int>();'); |
| - Expect.equals(1, compiler.warnings.length); |
| - Expect.equals(0, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.warnings.length); |
| + Expect.equals(0, collector.errors.length); |
| Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE, |
| - compiler.warnings[0].message.kind); |
| + collector.warnings.first.message.kind); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| @@ -198,8 +201,9 @@ Future testTypeVariables() { |
| foo.lookupLocalMember('t').computeType(compiler.resolution); |
| foo.lookupLocalMember('foo').computeType(compiler.resolution); |
| compiler.resolver.resolve(foo.lookupLocalMember('bar')); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(0, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(0, collector.errors.length); |
| }), |
| ]); |
| } |
| @@ -240,15 +244,16 @@ Future testSwitch() { |
| ClassElement fooElement = compiler.mainApp.find("Foo"); |
| FunctionElement funElement = fooElement.lookupLocalMember("foo"); |
| compiler.processQueue(compiler.enqueuer.resolution, funElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL, |
| - compiler.errors[0].message.kind); |
| - Expect.equals(2, compiler.infos.length); |
| + collector.errors.first.message.kind); |
| + Expect.equals(2, collector.infos.length); |
| Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, |
| - compiler.infos[0].message.kind); |
| + collector.infos.first.message.kind); |
| Expect.equals(MessageKind.SWITCH_CASE_TYPES_NOT_EQUAL_CASE, |
| - compiler.infos[1].message.kind); |
| + collector.infos.elementAt(1).message.kind); |
| }); |
| } |
| @@ -268,15 +273,17 @@ Future testThis() { |
| visitor.visit(function.body); |
| Map mapping = map(visitor); |
| List<Element> values = mapping.values.toList(); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| Expect.equals(0, mapping.length); |
| - Expect.equals(0, compiler.warnings.length); |
| + Expect.equals(0, collector.warnings.length); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.resolveStatement("main() { return this; }"); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("class Foo { static foo() { return this; } }"); |
| @@ -289,10 +296,11 @@ Future testThis() { |
| FunctionExpression function = |
| (funElement as FunctionElementX).parseNode(compiler.parsing); |
| visitor.visit(function.body); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.NO_INSTANCE_AVAILABLE, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| }), |
| ]); |
| } |
| @@ -313,12 +321,13 @@ Future testLocalsOne() { |
| () => testLocals([["foo", false], ["foo", false]]) |
| .then((MockCompiler compiler) { |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals( |
| new Message( |
| MessageTemplate.TEMPLATES[MessageKind.DUPLICATE_DEFINITION], |
| {'name': 'foo'}, false), |
| - compiler.errors[0].message); |
| + collector.errors.first.message); |
| })], (f) => f()); |
| } |
| @@ -486,29 +495,26 @@ Future testTypeAnnotation() { |
| Map mapping = compiler.resolveStatement(statement).map; |
| Expect.equals(1, mapping.length); // Only [bar] has an element. |
| - Expect.equals(1, compiler.warnings.length); |
| - |
| - Node warningNode = compiler.warnings[0].node; |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.warnings.length); |
| Expect.equals( |
| new Message( |
| MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE], |
| {'typeName': 'Foo'}, false), |
| - compiler.warnings[0].message); |
| - VariableDefinitions definition = compiler.parsedTree; |
| - Expect.equals(warningNode, definition.type); |
| - compiler.clearMessages(); |
| + collector.warnings.first.message); |
| + collector.clear(); |
| // Test that there is no warning after defining Foo. |
| compiler.parseScript("class Foo {}"); |
| mapping = compiler.resolveStatement(statement).map; |
| Expect.equals(1, mapping.length); |
| - Expect.equals(0, compiler.warnings.length); |
| + Expect.equals(0, collector.warnings.length); |
| // Test that 'var' does not create a warning. |
| mapping = compiler.resolveStatement("var foo;").map; |
| Expect.equals(1, mapping.length); |
| - Expect.equals(0, compiler.warnings.length); |
| + Expect.equals(0, collector.warnings.length); |
| }); |
| } |
| @@ -517,12 +523,13 @@ Future testSuperclass() { |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("class Foo extends Bar {}"); |
| compiler.resolveStatement("Foo bar;"); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.errors.length); |
| var cannotResolveBar = new Message( |
| MessageTemplate.TEMPLATES[MessageKind.CANNOT_EXTEND_MALFORMED], |
| {'className': 'Foo', 'malformedType': 'Bar'}, false); |
| - Expect.equals(cannotResolveBar, compiler.errors[0].message); |
| - compiler.clearMessages(); |
| + Expect.equals(cannotResolveBar, collector.errors.first.message); |
| + collector.clear(); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("class Foo extends Bar {}"); |
| @@ -544,13 +551,14 @@ Future testVarSuperclass() { |
| return MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("class Foo extends var {}"); |
| compiler.resolveStatement("Foo bar;"); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals( |
| new Message( |
| MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE], |
| {'typeName': 'var'}, false), |
| - compiler.errors[0].message); |
| - compiler.clearMessages(); |
| + collector.errors.first.message); |
| + collector.clear(); |
| }); |
| } |
| @@ -558,13 +566,14 @@ Future testOneInterface() { |
| return MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("class Foo implements Bar {}"); |
| compiler.resolveStatement("Foo bar;"); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals( |
| new Message( |
| MessageTemplate.TEMPLATES[MessageKind.CANNOT_RESOLVE_TYPE], |
| {'typeName': 'bar'}, false), |
| - compiler.errors[0].message); |
| - compiler.clearMessages(); |
| + collector.errors.first.message); |
| + collector.clear(); |
| // Add the abstract class to the world and make sure everything is setup |
| // correctly. |
| @@ -699,9 +708,10 @@ Future resolveConstructor( |
| Expect.equals(expectedElementCount, map(visitor).length, |
| "${map(visitor).values} for '$statement' in context of `$script`"); |
| - compareWarningKinds(script, expectedWarnings, compiler.warnings); |
| - compareWarningKinds(script, expectedErrors, compiler.errors); |
| - compareWarningKinds(script, expectedInfos, compiler.infos); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + compareWarningKinds(script, expectedWarnings, collector.warnings); |
| + compareWarningKinds(script, expectedErrors, collector.errors); |
| + compareWarningKinds(script, expectedInfos, collector.infos); |
| }); |
| } |
| @@ -713,10 +723,11 @@ Future testClassHierarchy() { |
| main() { return new A(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("""class A extends B {} |
| @@ -724,12 +735,13 @@ Future testClassHierarchy() { |
| main() { return new A(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(2, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(2, collector.errors.length); |
| Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| Expect.equals(MessageKind.CANNOT_FIND_CONSTRUCTOR, |
| - compiler.errors[1].message.kind); |
| + collector.errors.elementAt(1).message.kind); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("""abstract class A extends B {} |
| @@ -738,10 +750,11 @@ Future testClassHierarchy() { |
| main() { return new C(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.CYCLIC_CLASS_HIERARCHY, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| compiler.parseScript("""class A extends B {} |
| @@ -750,8 +763,9 @@ Future testClassHierarchy() { |
| main() { return new A(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(0, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(0, collector.errors.length); |
| ClassElement aElement = compiler.mainApp.find("A"); |
| Link<DartType> supertypes = aElement.allSupertypes; |
| Expect.equals(<String>['B', 'C', 'Object'].toString(), |
| @@ -766,8 +780,9 @@ Future testClassHierarchy() { |
| main() { return new C(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(0, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(0, collector.errors.length); |
| ClassElement aElement = compiler.mainApp.find("C"); |
| Link<DartType> supertypes = aElement.allSupertypes; |
| // Object is once per inheritance path, that is from both A and I. |
| @@ -782,8 +797,9 @@ Future testClassHierarchy() { |
| main() { return new E(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(0, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(0, collector.errors.length); |
| ClassElement aElement = compiler.mainApp.find("E"); |
| Link<DartType> supertypes = aElement.allSupertypes; |
| Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), |
| @@ -795,11 +811,12 @@ Future testClassHierarchy() { |
| main() { return new D(); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(1, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(1, collector.errors.length); |
| Expect.equals(MessageKind.MULTI_INHERITANCE, |
| - compiler.errors[0].message.kind); |
| - Expect.equals(0, compiler.crashes.length); |
| + collector.errors.first.message.kind); |
| + Expect.equals(0, collector.crashes.length); |
| }), |
| ]); |
| } |
| @@ -812,10 +829,11 @@ Future testEnumDeclaration() { |
| main() { Enum e; }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length, |
| - 'Unexpected warnings: ${compiler.warnings}'); |
| - Expect.equals(1, compiler.errors.length, |
| - 'Unexpected errors: ${compiler.errors}'); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length, |
| + 'Unexpected warnings: ${collector.warnings}'); |
| + Expect.equals(1, collector.errors.length, |
| + 'Unexpected errors: ${collector.errors}'); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| @@ -823,10 +841,11 @@ Future testEnumDeclaration() { |
| main() { Enum e = Enum.A; }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length, |
| - 'Unexpected warnings: ${compiler.warnings}'); |
| - Expect.equals(0, compiler.errors.length, |
| - 'Unexpected errors: ${compiler.errors}'); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length, |
| + 'Unexpected warnings: ${collector.warnings}'); |
| + Expect.equals(0, collector.errors.length, |
| + 'Unexpected errors: ${collector.errors}'); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| @@ -834,12 +853,13 @@ Future testEnumDeclaration() { |
| main() { Enum e = Enum.B; }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(1, compiler.warnings.length, |
| - 'Unexpected warnings: ${compiler.warnings}'); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(1, collector.warnings.length, |
| + 'Unexpected warnings: ${collector.warnings}'); |
| Expect.equals(MessageKind.MEMBER_NOT_FOUND, |
| - compiler.warnings[0].message.kind); |
| - Expect.equals(0, compiler.errors.length, |
| - 'Unexpected errors: ${compiler.errors}'); |
| + collector.warnings.first.message.kind); |
| + Expect.equals(0, collector.errors.length, |
| + 'Unexpected errors: ${collector.errors}'); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| @@ -847,10 +867,11 @@ Future testEnumDeclaration() { |
| main() { List values = Enum.values; }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length, |
| - 'Unexpected warnings: ${compiler.warnings}'); |
| - Expect.equals(0, compiler.errors.length, |
| - 'Unexpected errors: ${compiler.errors}'); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length, |
| + 'Unexpected warnings: ${collector.warnings}'); |
| + Expect.equals(0, collector.errors.length, |
| + 'Unexpected errors: ${collector.errors}'); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
| @@ -858,12 +879,13 @@ Future testEnumDeclaration() { |
| main() { new Enum(0, ''); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length, |
| - 'Unexpected warnings: ${compiler.warnings}'); |
| - Expect.equals(1, compiler.errors.length, |
| - 'Unexpected errors: ${compiler.errors}'); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length, |
| + 'Unexpected warnings: ${collector.warnings}'); |
| + Expect.equals(1, collector.errors.length, |
| + 'Unexpected errors: ${collector.errors}'); |
| Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| }), |
| MockCompiler.create((MockCompiler compiler) { |
|
sigurdm
2015/11/10 07:52:54
Not for this CL, but it seems these tests can be a
Johnni Winther
2015/11/10 09:38:52
Acknowledged.
|
| @@ -871,12 +893,13 @@ Future testEnumDeclaration() { |
| main() { const Enum(0, ''); }"""); |
| FunctionElement mainElement = compiler.mainApp.find(MAIN); |
| compiler.resolver.resolve(mainElement); |
| - Expect.equals(0, compiler.warnings.length, |
| - 'Unexpected warnings: ${compiler.warnings}'); |
| - Expect.equals(1, compiler.errors.length, |
| - 'Unexpected errors: ${compiler.errors}'); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length, |
| + 'Unexpected warnings: ${collector.warnings}'); |
| + Expect.equals(1, collector.errors.length, |
| + 'Unexpected errors: ${collector.errors}'); |
| Expect.equals(MessageKind.CANNOT_INSTANTIATE_ENUM, |
| - compiler.errors[0].message.kind); |
| + collector.errors.first.message.kind); |
| }), |
| ]); |
| } |
| @@ -1039,8 +1062,9 @@ Future testConstantExpressions() { |
| CollectingTreeElements elements = |
| compiler.resolveStatement("main() => $constant;"); |
| List<String> expectedConstants = testedConstants[constant]; |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(0, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(0, collector.errors.length); |
| List<ConstantExpression> constants = elements.constants; |
| String constantsText = |
| '[${constants.map((c) => c.getText()).join(', ')}]'; |
| @@ -1148,25 +1172,27 @@ testOverrideHashCodeCheck() { |
| new A() == new B(); |
| }"""; |
| asyncTest(() => compileScript(script).then((compiler) { |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(0, compiler.infos.length); |
| - Expect.equals(1, compiler.hints.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(0, collector.infos.length); |
| + Expect.equals(1, collector.hints.length); |
| Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE, |
| - compiler.hints[0].message.kind); |
| - Expect.equals(0, compiler.errors.length); |
| + collector.hints.first.message.kind); |
| + Expect.equals(0, collector.errors.length); |
| })); |
| } |
| testConstConstructorAndNonFinalFields() { |
| void expect(compiler, List errors, List infos) { |
| - Expect.equals(errors.length, compiler.errors.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(errors.length, collector.errors.length); |
| for (int i = 0 ; i < errors.length ; i++) { |
| - Expect.equals(errors[i], compiler.errors[i].message.kind); |
| + Expect.equals(errors[i], collector.errors.elementAt(i).message.kind); |
| } |
| - Expect.equals(0, compiler.warnings.length); |
| - Expect.equals(infos.length, compiler.infos.length); |
| + Expect.equals(0, collector.warnings.length); |
| + Expect.equals(infos.length, collector.infos.length); |
| for (int i = 0 ; i < infos.length ; i++) { |
| - Expect.equals(infos[i], compiler.infos[i].message.kind); |
| + Expect.equals(infos[i], collector.infos.elementAt(i).message.kind); |
| } |
| } |
| @@ -1370,13 +1396,14 @@ testCantAssignFinalAndConsts() { |
| checkWarningOn(String script, List<MessageKind> warnings) { |
| Expect.isTrue(warnings.length >= 0 && warnings.length <= 2); |
| asyncTest(() => compileScript(script).then((compiler) { |
| - Expect.equals(0, compiler.errors.length, |
| - 'Unexpected errors in\n$script\n${compiler.errors}'); |
| - Expect.equals(warnings.length, compiler.warnings.length, |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.errors.length, |
| + 'Unexpected errors in\n$script\n${collector.errors}'); |
| + Expect.equals(warnings.length, collector.warnings.length, |
| 'Unexpected warnings in\n$script\n' |
| - 'Expected:$warnings\nFound:${compiler.warnings}'); |
| + 'Expected:$warnings\nFound:${collector.warnings}'); |
| for (int i = 0; i < warnings.length; i++) { |
| - Expect.equals(warnings[i], compiler.warnings[i].message.kind); |
| + Expect.equals(warnings[i], collector.warnings.elementAt(i).message.kind); |
| } |
| })); |
| } |
| @@ -1389,11 +1416,12 @@ testAwaitHint() { |
| var where = functionName == null |
| ? 'the enclosing function' : "'$functionName'"; |
| asyncTest(() => compileScript(script).then((compiler) { |
| - Expect.equals(0, compiler.errors.length); |
| - Expect.equals(1, compiler.warnings.length); |
| + DiagnosticCollector collector = compiler.diagnosticCollector; |
| + Expect.equals(0, collector.errors.length); |
| + Expect.equals(1, collector.warnings.length); |
| Expect.equals("$prefix.\n" |
| "Did you mean to add the 'async' marker to $where?", |
| - '${compiler.warnings[0].message}'); |
| + '${collector.warnings.first.message}'); |
| })); |
| } |
| check('main() { await -3; }', functionName: 'main'); |