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 "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart" | 7 import "../../../sdk/lib/_internal/compiler/implementation/dart2jslib.dart" |
8 hide TreeElementMapping, TreeElements, SourceString; | 8 hide TreeElementMapping, TreeElements, SourceString; |
9 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart"; | 9 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart"; |
10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"; | 10 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 FunctionElement fooA = classA.lookupLocalMember(buildSourceString("foo")); | 150 FunctionElement fooA = classA.lookupLocalMember(buildSourceString("foo")); |
151 | 151 |
152 ResolverVisitor visitor = | 152 ResolverVisitor visitor = |
153 new ResolverVisitor(compiler, fooB, new CollectingTreeElements(fooB)); | 153 new ResolverVisitor(compiler, fooB, new CollectingTreeElements(fooB)); |
154 FunctionExpression node = fooB.parseNode(compiler); | 154 FunctionExpression node = fooB.parseNode(compiler); |
155 visitor.visit(node.body); | 155 visitor.visit(node.body); |
156 Map mapping = map(visitor); | 156 Map mapping = map(visitor); |
157 | 157 |
158 Send superCall = node.body.asReturn().expression; | 158 Send superCall = node.body.asReturn().expression; |
159 FunctionElement called = mapping[superCall]; | 159 FunctionElement called = mapping[superCall]; |
160 Expect.isTrue(called !== null); | 160 Expect.isTrue(called != null); |
Lasse Reichstein Nielsen
2012/11/12 13:10:41
Expect.isNotNull(called);
Ditto in other similar p
floitsch
2012/11/12 22:18:43
Done.
| |
161 Expect.equals(fooA, called); | 161 Expect.equals(fooA, called); |
162 } | 162 } |
163 | 163 |
164 testThis() { | 164 testThis() { |
165 MockCompiler compiler = new MockCompiler(); | 165 MockCompiler compiler = new MockCompiler(); |
166 compiler.parseScript("class Foo { foo() { return this; } }"); | 166 compiler.parseScript("class Foo { foo() { return this; } }"); |
167 compiler.resolveStatement("Foo foo;"); | 167 compiler.resolveStatement("Foo foo;"); |
168 ClassElement fooElement = compiler.mainApp.find(buildSourceString("Foo")); | 168 ClassElement fooElement = compiler.mainApp.find(buildSourceString("Foo")); |
169 FunctionElement funElement = | 169 FunctionElement funElement = |
170 fooElement.lookupLocalMember(buildSourceString("foo")); | 170 fooElement.lookupLocalMember(buildSourceString("foo")); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 Expect.equals(ElementKind.FUNCTION, element.kind); | 514 Expect.equals(ElementKind.FUNCTION, element.kind); |
515 Expect.equals(buildSourceString('f'), element.name); | 515 Expect.equals(buildSourceString('f'), element.name); |
516 Expect.equals(element.parseNode(compiler), node); | 516 Expect.equals(element.parseNode(compiler), node); |
517 } | 517 } |
518 | 518 |
519 testNewExpression() { | 519 testNewExpression() { |
520 MockCompiler compiler = new MockCompiler(); | 520 MockCompiler compiler = new MockCompiler(); |
521 compiler.parseScript("class A {} foo() { print(new A()); }"); | 521 compiler.parseScript("class A {} foo() { print(new A()); }"); |
522 ClassElement aElement = compiler.mainApp.find(buildSourceString('A')); | 522 ClassElement aElement = compiler.mainApp.find(buildSourceString('A')); |
523 FunctionElement fooElement = compiler.mainApp.find(buildSourceString('foo')); | 523 FunctionElement fooElement = compiler.mainApp.find(buildSourceString('foo')); |
524 Expect.isTrue(aElement !== null); | 524 Expect.isTrue(aElement != null); |
525 Expect.isTrue(fooElement !== null); | 525 Expect.isTrue(fooElement != null); |
526 | 526 |
527 fooElement.parseNode(compiler); | 527 fooElement.parseNode(compiler); |
528 compiler.resolver.resolve(fooElement); | 528 compiler.resolver.resolve(fooElement); |
529 | 529 |
530 TreeElements elements = compiler.resolveStatement("new A();"); | 530 TreeElements elements = compiler.resolveStatement("new A();"); |
531 NewExpression expression = | 531 NewExpression expression = |
532 compiler.parsedTree.asExpressionStatement().expression; | 532 compiler.parsedTree.asExpressionStatement().expression; |
533 Element element = elements[expression.send]; | 533 Element element = elements[expression.send]; |
534 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind); | 534 Expect.equals(ElementKind.GENERATIVE_CONSTRUCTOR, element.kind); |
535 Expect.isTrue(element is SynthesizedConstructorElement); | 535 Expect.isTrue(element is SynthesizedConstructorElement); |
(...skipping 26 matching lines...) Expand all Loading... | |
562 String constructor, int expectedElementCount, | 562 String constructor, int expectedElementCount, |
563 {List expectedWarnings: const [], | 563 {List expectedWarnings: const [], |
564 List expectedErrors: const [], | 564 List expectedErrors: const [], |
565 String corelib: DEFAULT_CORELIB}) { | 565 String corelib: DEFAULT_CORELIB}) { |
566 MockCompiler compiler = new MockCompiler(coreSource: corelib); | 566 MockCompiler compiler = new MockCompiler(coreSource: corelib); |
567 compiler.parseScript(script); | 567 compiler.parseScript(script); |
568 compiler.resolveStatement(statement); | 568 compiler.resolveStatement(statement); |
569 ClassElement classElement = | 569 ClassElement classElement = |
570 compiler.mainApp.find(buildSourceString(className)); | 570 compiler.mainApp.find(buildSourceString(className)); |
571 Element element; | 571 Element element; |
572 if (constructor !== '') { | 572 if (constructor != '') { |
573 element = classElement.lookupConstructor( | 573 element = classElement.lookupConstructor( |
574 new Selector.callConstructor(buildSourceString(constructor), | 574 new Selector.callConstructor(buildSourceString(constructor), |
575 classElement.getLibrary())); | 575 classElement.getLibrary())); |
576 } else { | 576 } else { |
577 element = classElement.lookupConstructor( | 577 element = classElement.lookupConstructor( |
578 new Selector.callDefaultConstructor(classElement.getLibrary())); | 578 new Selector.callDefaultConstructor(classElement.getLibrary())); |
579 } | 579 } |
580 | 580 |
581 FunctionExpression tree = element.parseNode(compiler); | 581 FunctionExpression tree = element.parseNode(compiler); |
582 ResolverVisitor visitor = | 582 ResolverVisitor visitor = |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
807 var d = new D(); | 807 var d = new D(); |
808 --d; | 808 --d; |
809 }"""; | 809 }"""; |
810 final compiler = compileScript(script); | 810 final compiler = compileScript(script); |
811 | 811 |
812 checkMemberResolved(compiler, 'A', operatorName('+', false)); | 812 checkMemberResolved(compiler, 'A', operatorName('+', false)); |
813 checkMemberResolved(compiler, 'B', operatorName('+', false)); | 813 checkMemberResolved(compiler, 'B', operatorName('+', false)); |
814 checkMemberResolved(compiler, 'C', operatorName('-', false)); | 814 checkMemberResolved(compiler, 'C', operatorName('-', false)); |
815 checkMemberResolved(compiler, 'D', operatorName('-', false)); | 815 checkMemberResolved(compiler, 'D', operatorName('-', false)); |
816 } | 816 } |
OLD | NEW |