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 "package:compiler/implementation/resolution/resolution.dart"; | 10 import "package:compiler/src/resolution/resolution.dart"; |
11 import "compiler_helper.dart"; | 11 import "compiler_helper.dart"; |
12 import "parser_helper.dart"; | 12 import "parser_helper.dart"; |
13 | 13 |
14 import 'package:compiler/implementation/dart_types.dart'; | 14 import 'package:compiler/src/dart_types.dart'; |
15 import 'package:compiler/implementation/elements/modelx.dart'; | 15 import 'package:compiler/src/elements/modelx.dart'; |
16 import 'link_helper.dart'; | 16 import 'link_helper.dart'; |
17 | 17 |
18 Node buildIdentifier(String name) => new Identifier(scan(name)); | 18 Node buildIdentifier(String name) => new Identifier(scan(name)); |
19 | 19 |
20 Node buildInitialization(String name) => | 20 Node buildInitialization(String name) => |
21 parseBodyCode('$name = 1', | 21 parseBodyCode('$name = 1', |
22 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); | 22 (parser, tokens) => parser.parseOptionallyInitializedIdentifier(tokens)); |
23 | 23 |
24 createLocals(List variables) { | 24 createLocals(List variables) { |
25 var locals = <Node>[]; | 25 var locals = <Node>[]; |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 | 583 |
584 Expect.equals(barElement.computeType(compiler), | 584 Expect.equals(barElement.computeType(compiler), |
585 fooElement.interfaces.head); | 585 fooElement.interfaces.head); |
586 Expect.equals(1, length(fooElement.interfaces)); | 586 Expect.equals(1, length(fooElement.interfaces)); |
587 }); | 587 }); |
588 } | 588 } |
589 | 589 |
590 Future testTwoInterfaces() { | 590 Future testTwoInterfaces() { |
591 return MockCompiler.create((MockCompiler compiler) { | 591 return MockCompiler.create((MockCompiler compiler) { |
592 compiler.parseScript( | 592 compiler.parseScript( |
593 """abstract class I1 {} | 593 """abstract class I1 {} |
594 abstract class I2 {} | 594 abstract class I2 {} |
595 class C implements I1, I2 {}"""); | 595 class C implements I1, I2 {}"""); |
596 compiler.resolveStatement("Foo bar;"); | 596 compiler.resolveStatement("Foo bar;"); |
597 | 597 |
598 ClassElement c = compiler.mainApp.find('C'); | 598 ClassElement c = compiler.mainApp.find('C'); |
599 Element i1 = compiler.mainApp.find('I1'); | 599 Element i1 = compiler.mainApp.find('I1'); |
600 Element i2 = compiler.mainApp.find('I2'); | 600 Element i2 = compiler.mainApp.find('I2'); |
601 | 601 |
602 Expect.equals(2, length(c.interfaces)); | 602 Expect.equals(2, length(c.interfaces)); |
603 Expect.equals(i1.computeType(compiler), at(c.interfaces, 0)); | 603 Expect.equals(i1.computeType(compiler), at(c.interfaces, 0)); |
604 Expect.equals(i2.computeType(compiler), at(c.interfaces, 1)); | 604 Expect.equals(i2.computeType(compiler), at(c.interfaces, 1)); |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 compiler.resolver.resolve(mainElement); | 754 compiler.resolver.resolve(mainElement); |
755 Expect.equals(0, compiler.warnings.length); | 755 Expect.equals(0, compiler.warnings.length); |
756 Expect.equals(0, compiler.errors.length); | 756 Expect.equals(0, compiler.errors.length); |
757 ClassElement aElement = compiler.mainApp.find("A"); | 757 ClassElement aElement = compiler.mainApp.find("A"); |
758 Link<DartType> supertypes = aElement.allSupertypes; | 758 Link<DartType> supertypes = aElement.allSupertypes; |
759 Expect.equals(<String>['B', 'C', 'Object'].toString(), | 759 Expect.equals(<String>['B', 'C', 'Object'].toString(), |
760 asSortedStrings(supertypes).toString()); | 760 asSortedStrings(supertypes).toString()); |
761 }), | 761 }), |
762 MockCompiler.create((MockCompiler compiler) { | 762 MockCompiler.create((MockCompiler compiler) { |
763 compiler.parseScript("""class A<T> {} | 763 compiler.parseScript("""class A<T> {} |
764 class B<Z,W> extends A<int> | 764 class B<Z,W> extends A<int> |
765 implements I<Z,List<W>> {} | 765 implements I<Z,List<W>> {} |
766 class I<X,Y> {} | 766 class I<X,Y> {} |
767 class C extends B<bool,String> {} | 767 class C extends B<bool,String> {} |
768 main() { return new C(); }"""); | 768 main() { return new C(); }"""); |
769 FunctionElement mainElement = compiler.mainApp.find(MAIN); | 769 FunctionElement mainElement = compiler.mainApp.find(MAIN); |
770 compiler.resolver.resolve(mainElement); | 770 compiler.resolver.resolve(mainElement); |
771 Expect.equals(0, compiler.warnings.length); | 771 Expect.equals(0, compiler.warnings.length); |
772 Expect.equals(0, compiler.errors.length); | 772 Expect.equals(0, compiler.errors.length); |
773 ClassElement aElement = compiler.mainApp.find("C"); | 773 ClassElement aElement = compiler.mainApp.find("C"); |
774 Link<DartType> supertypes = aElement.allSupertypes; | 774 Link<DartType> supertypes = aElement.allSupertypes; |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 }"""; | 1064 }"""; |
1065 asyncTest(() => compileScript(script2).then((compiler) { | 1065 asyncTest(() => compileScript(script2).then((compiler) { |
1066 expect(compiler, | 1066 expect(compiler, |
1067 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], | 1067 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], |
1068 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1068 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
1069 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, | 1069 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, |
1070 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, | 1070 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, |
1071 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); | 1071 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); |
1072 })); | 1072 })); |
1073 } | 1073 } |
OLD | NEW |