Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: tests/compiler/dart2js/resolver_test.dart

Issue 10857033: Make sure to register +/- when we're using ++/--. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | tests/language/language.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 testFunctionExpression(); 68 testFunctionExpression();
69 testNewExpression(); 69 testNewExpression();
70 testTopLevelFields(); 70 testTopLevelFields();
71 testClassHierarchy(); 71 testClassHierarchy();
72 testInitializers(); 72 testInitializers();
73 testThis(); 73 testThis();
74 testSuperCalls(); 74 testSuperCalls();
75 testTypeVariables(); 75 testTypeVariables();
76 testToString(); 76 testToString();
77 testIndexedOperator(); 77 testIndexedOperator();
78 testIncrementsAndDecrements();
78 } 79 }
79 80
80 testTypeVariables() { 81 testTypeVariables() {
81 matchResolvedTypes(visitor, text, name, expectedElements) { 82 matchResolvedTypes(visitor, text, name, expectedElements) {
82 VariableDefinitions definition = parseStatement(text); 83 VariableDefinitions definition = parseStatement(text);
83 visitor.visit(definition.type); 84 visitor.visit(definition.type);
84 InterfaceType type = visitor.mapping.getType(definition.type); 85 InterfaceType type = visitor.mapping.getType(definition.type);
85 Expect.equals(definition.type.typeArguments.length(), 86 Expect.equals(definition.type.typeArguments.length(),
86 length(type.arguments)); 87 length(type.arguments));
87 int index = 0; 88 int index = 0;
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 return result; 729 return result;
729 } 730 }
730 731
731 compileScript(String source) { 732 compileScript(String source) {
732 Uri uri = new Uri.fromComponents(scheme: 'source'); 733 Uri uri = new Uri.fromComponents(scheme: 'source');
733 MockCompiler compiler = compilerFor(source, uri); 734 MockCompiler compiler = compilerFor(source, uri);
734 compiler.runCompiler(uri); 735 compiler.runCompiler(uri);
735 return compiler; 736 return compiler;
736 } 737 }
737 738
739 checkMemberResolved(compiler, className, memberName) {
740 Element memberElement = findElement(compiler, className)
741 .lookupLocalMember(memberName);
742 Expect.isNotNull(memberElement);
743 Expect.isNotNull(
744 compiler.enqueuer.resolution.getCachedElements(memberElement));
745 }
746
738 testToString() { 747 testToString() {
739 final script = @"class C { toString() => 'C'; } main() { '${new C()}'; }"; 748 final script = @"class C { toString() => 'C'; } main() { '${new C()}'; }";
740 final compiler = compileScript(script); 749 final compiler = compileScript(script);
741 750
742 Element toStringMethod = findElement(compiler, 'C') 751 checkMemberResolved(compiler, 'C', buildSourceString('toString'));
743 .lookupLocalMember(buildSourceString('toString')); 752 }
744 Expect.isNotNull(toStringMethod);
745 753
746 Expect.isNotNull( 754 operatorName(op) => Elements.constructOperatorName(
747 compiler.enqueuer.resolution.getCachedElements(toStringMethod)); 755 const SourceString('operator'), new SourceString(op));
748 }
749 756
750 testIndexedOperator() { 757 testIndexedOperator() {
751 final script = @""" 758 final script = @"""
752 class C { 759 class C {
753 operator[](ix) => ix; 760 operator[](ix) => ix;
754 operator[]=(ix, v) {} 761 operator[]=(ix, v) {}
755 } 762 }
756 main() { var c = new C(); c[0]++ ; }"""; 763 main() { var c = new C(); c[0]++; }""";
757 final compiler = compileScript(script); 764 final compiler = compileScript(script);
758 765
759 operatorName(op) => Elements.constructOperatorName( 766 checkMemberResolved(compiler, 'C', operatorName('[]'));
760 const SourceString('operator'), new SourceString(op)); 767 checkMemberResolved(compiler, 'C', operatorName('[]='));
768 }
761 769
762 Element indexedOperator = findElement(compiler, 'C') 770 testIncrementsAndDecrements() {
763 .lookupLocalMember(operatorName('[]')); 771 final script = @"""
764 Expect.isNotNull(indexedOperator); 772 class A { operator+(o)=>null; }
765 Expect.isNotNull( 773 class B { operator+(o)=>null; }
766 compiler.enqueuer.resolution.getCachedElements(indexedOperator)); 774 class C { operator-(o)=>null; }
775 class D { operator-(o)=>null; }
776 main() {
777 var a = new A();
778 a++;
779 var b = new B();
780 ++b;
781 var c = new C();
782 c--;
783 var d = new D();
784 --d;
785 }""";
786 final compiler = compileScript(script);
767 787
768 Element indexedSetOperator = findElement(compiler, 'C') 788 checkMemberResolved(compiler, 'A', operatorName('+'));
769 .lookupLocalMember(operatorName('[]=')); 789 checkMemberResolved(compiler, 'B', operatorName('+'));
770 Expect.isNotNull(indexedOperator); 790 checkMemberResolved(compiler, 'C', operatorName('-'));
771 Expect.isNotNull( 791 checkMemberResolved(compiler, 'D', operatorName('-'));
772 compiler.enqueuer.resolution.getCachedElements(indexedSetOperator));
773 } 792 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/resolver.dart ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698