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 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, isUnary) { | 752 operatorName(op) => Elements.constructOperatorName( |
753 return Elements.constructOperatorName(new SourceString(op), isUnary); | 753 const SourceString('operator'), new SourceString(op)); |
754 } | |
755 | 754 |
756 testIndexedOperator() { | 755 testIndexedOperator() { |
757 final script = @""" | 756 final script = @""" |
758 class C { | 757 class C { |
759 operator[](ix) => ix; | 758 operator[](ix) => ix; |
760 operator[]=(ix, v) {} | 759 operator[]=(ix, v) {} |
761 } | 760 } |
762 main() { var c = new C(); c[0]++; }"""; | 761 main() { var c = new C(); c[0]++; }"""; |
763 final compiler = compileScript(script); | 762 final compiler = compileScript(script); |
764 | 763 |
765 checkMemberResolved(compiler, 'C', operatorName('[]', false)); | 764 checkMemberResolved(compiler, 'C', operatorName('[]')); |
766 checkMemberResolved(compiler, 'C', operatorName('[]=', false)); | 765 checkMemberResolved(compiler, 'C', operatorName('[]=')); |
767 } | 766 } |
768 | 767 |
769 testIncrementsAndDecrements() { | 768 testIncrementsAndDecrements() { |
770 final script = @""" | 769 final script = @""" |
771 class A { operator+(o)=>null; } | 770 class A { operator+(o)=>null; } |
772 class B { operator+(o)=>null; } | 771 class B { operator+(o)=>null; } |
773 class C { operator-(o)=>null; } | 772 class C { operator-(o)=>null; } |
774 class D { operator-(o)=>null; } | 773 class D { operator-(o)=>null; } |
775 main() { | 774 main() { |
776 var a = new A(); | 775 var a = new A(); |
777 a++; | 776 a++; |
778 var b = new B(); | 777 var b = new B(); |
779 ++b; | 778 ++b; |
780 var c = new C(); | 779 var c = new C(); |
781 c--; | 780 c--; |
782 var d = new D(); | 781 var d = new D(); |
783 --d; | 782 --d; |
784 }"""; | 783 }"""; |
785 final compiler = compileScript(script); | 784 final compiler = compileScript(script); |
786 | 785 |
787 checkMemberResolved(compiler, 'A', operatorName('+', false)); | 786 checkMemberResolved(compiler, 'A', operatorName('+')); |
788 checkMemberResolved(compiler, 'B', operatorName('+', false)); | 787 checkMemberResolved(compiler, 'B', operatorName('+')); |
789 checkMemberResolved(compiler, 'C', operatorName('-', false)); | 788 checkMemberResolved(compiler, 'C', operatorName('-')); |
790 checkMemberResolved(compiler, 'D', operatorName('-', false)); | 789 checkMemberResolved(compiler, 'D', operatorName('-')); |
791 } | 790 } |
OLD | NEW |