| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; | 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution
.dart"; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 compiler = new MockCompiler(); | 110 compiler = new MockCompiler(); |
| 111 compiler.parseScript(""" | 111 compiler.parseScript(""" |
| 112 class X<T> {} | 112 class X<T> {} |
| 113 class Foo extends X<Foo> {} | 113 class Foo extends X<Foo> {} |
| 114 class Bar extends Foo implements X<Bar> {} | 114 class Bar extends Foo implements X<Bar> {} |
| 115 """); | 115 """); |
| 116 compiler.resolveStatement("Bar bar;"); | 116 compiler.resolveStatement("Bar bar;"); |
| 117 ClassElement classBar = compiler.mainApp.find("Bar"); | 117 ClassElement classBar = compiler.mainApp.find("Bar"); |
| 118 Expect.equals(0, compiler.warnings.length); | 118 Expect.equals(0, compiler.warnings.length); |
| 119 Expect.equals(0, compiler.errors.length); | 119 Expect.equals(1, compiler.errors.length); |
| 120 Expect.equals(1, compiler.crashes.length); | |
| 121 Expect.equals(MessageKind.MULTI_INHERITANCE, | 120 Expect.equals(MessageKind.MULTI_INHERITANCE, |
| 122 compiler.crashes[0].message.kind); | 121 compiler.errors[0].message.kind); |
| 122 Expect.equals(0, compiler.crashes.length); |
| 123 } | 123 } |
| 124 | 124 |
| 125 testTypeVariables() { | 125 testTypeVariables() { |
| 126 matchResolvedTypes(visitor, text, name, expectedElements) { | 126 matchResolvedTypes(visitor, text, name, expectedElements) { |
| 127 VariableDefinitions definition = parseStatement(text); | 127 VariableDefinitions definition = parseStatement(text); |
| 128 visitor.visit(definition.type); | 128 visitor.visit(definition.type); |
| 129 InterfaceType type = visitor.mapping.getType(definition.type); | 129 InterfaceType type = visitor.mapping.getType(definition.type); |
| 130 Expect.equals(definition.type.typeArguments.slowLength(), | 130 Expect.equals(definition.type.typeArguments.slowLength(), |
| 131 length(type.typeArguments)); | 131 length(type.typeArguments)); |
| 132 int index = 0; | 132 int index = 0; |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), | 747 Expect.equals(<String>['A<E>', 'D', 'Object'].toString(), |
| 748 asSortedStrings(supertypes).toString()); | 748 asSortedStrings(supertypes).toString()); |
| 749 | 749 |
| 750 compiler = new MockCompiler(); | 750 compiler = new MockCompiler(); |
| 751 compiler.parseScript("""class A<T> {} | 751 compiler.parseScript("""class A<T> {} |
| 752 class D extends A<int> implements A<double> {} | 752 class D extends A<int> implements A<double> {} |
| 753 main() { return new D(); }"""); | 753 main() { return new D(); }"""); |
| 754 mainElement = compiler.mainApp.find(MAIN); | 754 mainElement = compiler.mainApp.find(MAIN); |
| 755 compiler.resolver.resolve(mainElement); | 755 compiler.resolver.resolve(mainElement); |
| 756 Expect.equals(0, compiler.warnings.length); | 756 Expect.equals(0, compiler.warnings.length); |
| 757 Expect.equals(0, compiler.errors.length); | 757 Expect.equals(1, compiler.errors.length); |
| 758 Expect.equals(1, compiler.crashes.length); | |
| 759 Expect.equals(MessageKind.MULTI_INHERITANCE, | 758 Expect.equals(MessageKind.MULTI_INHERITANCE, |
| 760 compiler.crashes[0].message.kind); | 759 compiler.errors[0].message.kind); |
| 760 Expect.equals(0, compiler.crashes.length); |
| 761 } | 761 } |
| 762 | 762 |
| 763 testInitializers() { | 763 testInitializers() { |
| 764 String script; | 764 String script; |
| 765 script = """class A { | 765 script = """class A { |
| 766 int foo; int bar; | 766 int foo; int bar; |
| 767 A() : this.foo = 1, bar = 2; | 767 A() : this.foo = 1, bar = 2; |
| 768 }"""; | 768 }"""; |
| 769 resolveConstructor(script, "A a = new A();", "A", "", 2); | 769 resolveConstructor(script, "A a = new A();", "A", "", 2); |
| 770 | 770 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 }"""; | 1010 }"""; |
| 1011 asyncTest(() => compileScript(script2).then((compiler) { | 1011 asyncTest(() => compileScript(script2).then((compiler) { |
| 1012 expect(compiler, | 1012 expect(compiler, |
| 1013 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1013 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
| 1014 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1014 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1015 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1015 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
| 1016 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1016 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
| 1017 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1017 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
| 1018 })); | 1018 })); |
| 1019 } | 1019 } |
| OLD | NEW |