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

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

Issue 10870066: Support unary - operator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix unparser to handle that negate is no longer a keyword. Created 8 years, 3 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 | « dart/tests/compiler/dart2js/parser_test.dart ('k') | no next file » | 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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 compiler.enqueuer.resolution.getCachedElements(memberElement)); 742 compiler.enqueuer.resolution.getCachedElements(memberElement));
743 } 743 }
744 744
745 testToString() { 745 testToString() {
746 final script = @"class C { toString() => 'C'; } main() { '${new C()}'; }"; 746 final script = @"class C { toString() => 'C'; } main() { '${new C()}'; }";
747 final compiler = compileScript(script); 747 final compiler = compileScript(script);
748 748
749 checkMemberResolved(compiler, 'C', buildSourceString('toString')); 749 checkMemberResolved(compiler, 'C', buildSourceString('toString'));
750 } 750 }
751 751
752 operatorName(op) => Elements.constructOperatorName( 752 operatorName(op, isUnary) {
753 const SourceString('operator'), new SourceString(op)); 753 return Elements.constructOperatorName(new SourceString(op), isUnary);
754 }
754 755
755 testIndexedOperator() { 756 testIndexedOperator() {
756 final script = @""" 757 final script = @"""
757 class C { 758 class C {
758 operator[](ix) => ix; 759 operator[](ix) => ix;
759 operator[]=(ix, v) {} 760 operator[]=(ix, v) {}
760 } 761 }
761 main() { var c = new C(); c[0]++; }"""; 762 main() { var c = new C(); c[0]++; }""";
762 final compiler = compileScript(script); 763 final compiler = compileScript(script);
763 764
764 checkMemberResolved(compiler, 'C', operatorName('[]')); 765 checkMemberResolved(compiler, 'C', operatorName('[]', false));
765 checkMemberResolved(compiler, 'C', operatorName('[]=')); 766 checkMemberResolved(compiler, 'C', operatorName('[]=', false));
766 } 767 }
767 768
768 testIncrementsAndDecrements() { 769 testIncrementsAndDecrements() {
769 final script = @""" 770 final script = @"""
770 class A { operator+(o)=>null; } 771 class A { operator+(o)=>null; }
771 class B { operator+(o)=>null; } 772 class B { operator+(o)=>null; }
772 class C { operator-(o)=>null; } 773 class C { operator-(o)=>null; }
773 class D { operator-(o)=>null; } 774 class D { operator-(o)=>null; }
774 main() { 775 main() {
775 var a = new A(); 776 var a = new A();
776 a++; 777 a++;
777 var b = new B(); 778 var b = new B();
778 ++b; 779 ++b;
779 var c = new C(); 780 var c = new C();
780 c--; 781 c--;
781 var d = new D(); 782 var d = new D();
782 --d; 783 --d;
783 }"""; 784 }""";
784 final compiler = compileScript(script); 785 final compiler = compileScript(script);
785 786
786 checkMemberResolved(compiler, 'A', operatorName('+')); 787 checkMemberResolved(compiler, 'A', operatorName('+', false));
787 checkMemberResolved(compiler, 'B', operatorName('+')); 788 checkMemberResolved(compiler, 'B', operatorName('+', false));
788 checkMemberResolved(compiler, 'C', operatorName('-')); 789 checkMemberResolved(compiler, 'C', operatorName('-', false));
789 checkMemberResolved(compiler, 'D', operatorName('-')); 790 checkMemberResolved(compiler, 'D', operatorName('-', false));
790 } 791 }
OLDNEW
« no previous file with comments | « dart/tests/compiler/dart2js/parser_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698