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('dart:uri'); | 5 #import('dart:uri'); |
6 | 6 |
7 #import("../../../lib/compiler/implementation/leg.dart"); | 7 #import("../../../lib/compiler/implementation/leg.dart"); |
8 #import("../../../lib/compiler/implementation/elements/elements.dart"); | 8 #import("../../../lib/compiler/implementation/elements/elements.dart"); |
9 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 9 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
10 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart"); | 10 #import("../../../lib/compiler/implementation/scanner/scannerlib.dart"); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 testTypeVariables() { | 81 testTypeVariables() { |
82 matchResolvedTypes(visitor, text, name, expectedElements) { | 82 matchResolvedTypes(visitor, text, name, expectedElements) { |
83 VariableDefinitions definition = parseStatement(text); | 83 VariableDefinitions definition = parseStatement(text); |
84 visitor.visit(definition.type); | 84 visitor.visit(definition.type); |
85 InterfaceType type = visitor.mapping.getType(definition.type); | 85 InterfaceType type = visitor.mapping.getType(definition.type); |
86 Expect.equals(definition.type.typeArguments.length(), | 86 Expect.equals(definition.type.typeArguments.length(), |
87 length(type.arguments)); | 87 length(type.arguments)); |
88 int index = 0; | 88 int index = 0; |
89 Link<Type> arguments = type.arguments; | 89 Link<DartType> arguments = type.arguments; |
90 while (!arguments.isEmpty()) { | 90 while (!arguments.isEmpty()) { |
91 Expect.equals(true, index < expectedElements.length); | 91 Expect.equals(true, index < expectedElements.length); |
92 Expect.equals(expectedElements[index], arguments.head.element); | 92 Expect.equals(expectedElements[index], arguments.head.element); |
93 index++; | 93 index++; |
94 arguments = arguments.tail; | 94 arguments = arguments.tail; |
95 } | 95 } |
96 Expect.equals(index, expectedElements.length); | 96 Expect.equals(index, expectedElements.length); |
97 } | 97 } |
98 | 98 |
99 MockCompiler compiler = new MockCompiler(); | 99 MockCompiler compiler = new MockCompiler(); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 compiler = new MockCompiler(); | 602 compiler = new MockCompiler(); |
603 compiler.parseScript("""class A extends B {} | 603 compiler.parseScript("""class A extends B {} |
604 class B extends C {} | 604 class B extends C {} |
605 class C {} | 605 class C {} |
606 main() { return new A(); }"""); | 606 main() { return new A(); }"""); |
607 mainElement = compiler.mainApp.find(MAIN); | 607 mainElement = compiler.mainApp.find(MAIN); |
608 compiler.resolver.resolve(mainElement); | 608 compiler.resolver.resolve(mainElement); |
609 Expect.equals(0, compiler.warnings.length); | 609 Expect.equals(0, compiler.warnings.length); |
610 Expect.equals(0, compiler.errors.length); | 610 Expect.equals(0, compiler.errors.length); |
611 ClassElement aElement = compiler.mainApp.find(buildSourceString("A")); | 611 ClassElement aElement = compiler.mainApp.find(buildSourceString("A")); |
612 Link<Type> supertypes = aElement.allSupertypes; | 612 Link<DartType> supertypes = aElement.allSupertypes; |
613 Expect.equals(<String>['B', 'C', 'Object'].toString(), | 613 Expect.equals(<String>['B', 'C', 'Object'].toString(), |
614 asSortedStrings(supertypes).toString()); | 614 asSortedStrings(supertypes).toString()); |
615 } | 615 } |
616 | 616 |
617 testInitializers() { | 617 testInitializers() { |
618 String script; | 618 String script; |
619 script = """class A { | 619 script = """class A { |
620 int foo; int bar; | 620 int foo; int bar; |
621 A() : this.foo = 1, bar = 2; | 621 A() : this.foo = 1, bar = 2; |
622 }"""; | 622 }"""; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 var d = new D(); | 782 var d = new D(); |
783 --d; | 783 --d; |
784 }"""; | 784 }"""; |
785 final compiler = compileScript(script); | 785 final compiler = compileScript(script); |
786 | 786 |
787 checkMemberResolved(compiler, 'A', operatorName('+', false)); | 787 checkMemberResolved(compiler, 'A', operatorName('+', false)); |
788 checkMemberResolved(compiler, 'B', operatorName('+', false)); | 788 checkMemberResolved(compiler, 'B', operatorName('+', false)); |
789 checkMemberResolved(compiler, 'C', operatorName('-', false)); | 789 checkMemberResolved(compiler, 'C', operatorName('-', false)); |
790 checkMemberResolved(compiler, 'D', operatorName('-', false)); | 790 checkMemberResolved(compiler, 'D', operatorName('-', false)); |
791 } | 791 } |
OLD | NEW |