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

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

Issue 17759007: First pass at asynchronous input loading in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 7 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
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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async';
7 import "../../async_helper.dart";
6 import 'dart:collection'; 8 import 'dart:collection';
7 9
8 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart"; 10 import "../../../sdk/lib/_internal/compiler/implementation/resolution/resolution .dart";
9 import "compiler_helper.dart"; 11 import "compiler_helper.dart";
10 import "parser_helper.dart"; 12 import "parser_helper.dart";
11 13
12 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; 14 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
13 15
14 Node buildIdentifier(String name) => new Identifier(scan(name)); 16 Node buildIdentifier(String name) => new Identifier(scan(name));
15 17
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 836
835 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); 837 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1);
836 838
837 List<String> asSortedStrings(Link link) { 839 List<String> asSortedStrings(Link link) {
838 List<String> result = <String>[]; 840 List<String> result = <String>[];
839 for (; !link.isEmpty; link = link.tail) result.add(link.head.toString()); 841 for (; !link.isEmpty; link = link.tail) result.add(link.head.toString());
840 result.sort((s1, s2) => s1.compareTo(s2)); 842 result.sort((s1, s2) => s1.compareTo(s2));
841 return result; 843 return result;
842 } 844 }
843 845
844 compileScript(String source) { 846 Future compileScript(String source) {
845 Uri uri = new Uri(scheme: 'source'); 847 Uri uri = new Uri(scheme: 'source');
846 MockCompiler compiler = compilerFor(source, uri); 848 MockCompiler compiler = compilerFor(source, uri);
847 compiler.runCompiler(uri); 849 return compiler.runCompiler(uri).then((_) {
848 return compiler; 850 return compiler;
851 });
849 } 852 }
850 853
851 checkMemberResolved(compiler, className, memberName) { 854 checkMemberResolved(compiler, className, memberName) {
852 ClassElement cls = findElement(compiler, className); 855 ClassElement cls = findElement(compiler, className);
853 Element memberElement = cls.lookupLocalMember(memberName); 856 Element memberElement = cls.lookupLocalMember(memberName);
854 Expect.isNotNull(memberElement); 857 Expect.isNotNull(memberElement);
855 Expect.isNotNull( 858 Expect.isNotNull(
856 compiler.enqueuer.resolution.getCachedElements(memberElement)); 859 compiler.enqueuer.resolution.getCachedElements(memberElement));
857 } 860 }
858 861
859 testToString() { 862 testToString() {
860 final script = r"class C { toString() => 'C'; } main() { '${new C()}'; }"; 863 final script = r"class C { toString() => 'C'; } main() { '${new C()}'; }";
861 final compiler = compileScript(script); 864 asyncTest(() => compileScript(script).then((compiler) {
862 865 checkMemberResolved(compiler, 'C', buildSourceString('toString'));
863 checkMemberResolved(compiler, 'C', buildSourceString('toString')); 866 }));
864 } 867 }
865 868
866 operatorName(op, isUnary) { 869 operatorName(op, isUnary) {
867 return Elements.constructOperatorName(new SourceString(op), isUnary); 870 return Elements.constructOperatorName(new SourceString(op), isUnary);
868 } 871 }
869 872
870 testIndexedOperator() { 873 testIndexedOperator() {
871 final script = r""" 874 final script = r"""
872 class C { 875 class C {
873 operator[](ix) => ix; 876 operator[](ix) => ix;
874 operator[]=(ix, v) {} 877 operator[]=(ix, v) {}
875 } 878 }
876 main() { var c = new C(); c[0]++; }"""; 879 main() { var c = new C(); c[0]++; }""";
877 final compiler = compileScript(script); 880 asyncTest(() => compileScript(script).then((compiler) {
878 881 checkMemberResolved(compiler, 'C', operatorName('[]', false));
879 checkMemberResolved(compiler, 'C', operatorName('[]', false)); 882 checkMemberResolved(compiler, 'C', operatorName('[]=', false));
880 checkMemberResolved(compiler, 'C', operatorName('[]=', false)); 883 }));
881 } 884 }
882 885
883 testIncrementsAndDecrements() { 886 testIncrementsAndDecrements() {
884 final script = r""" 887 final script = r"""
885 class A { operator+(o)=>null; } 888 class A { operator+(o)=>null; }
886 class B { operator+(o)=>null; } 889 class B { operator+(o)=>null; }
887 class C { operator-(o)=>null; } 890 class C { operator-(o)=>null; }
888 class D { operator-(o)=>null; } 891 class D { operator-(o)=>null; }
889 main() { 892 main() {
890 var a = new A(); 893 var a = new A();
891 a++; 894 a++;
892 var b = new B(); 895 var b = new B();
893 ++b; 896 ++b;
894 var c = new C(); 897 var c = new C();
895 c--; 898 c--;
896 var d = new D(); 899 var d = new D();
897 --d; 900 --d;
898 }"""; 901 }""";
899 final compiler = compileScript(script); 902 asyncTest(() => compileScript(script).then((compiler) {
900 903 checkMemberResolved(compiler, 'A', operatorName('+', false));
901 checkMemberResolved(compiler, 'A', operatorName('+', false)); 904 checkMemberResolved(compiler, 'B', operatorName('+', false));
902 checkMemberResolved(compiler, 'B', operatorName('+', false)); 905 checkMemberResolved(compiler, 'C', operatorName('-', false));
903 checkMemberResolved(compiler, 'C', operatorName('-', false)); 906 checkMemberResolved(compiler, 'D', operatorName('-', false));
904 checkMemberResolved(compiler, 'D', operatorName('-', false)); 907 }));
905 } 908 }
906 909
907 testOverrideHashCodeCheck() { 910 testOverrideHashCodeCheck() {
908 final script = r""" 911 final script = r"""
909 class A { 912 class A {
910 operator==(other) => true; 913 operator==(other) => true;
911 } 914 }
912 class B { 915 class B {
913 operator==(other) => true; 916 operator==(other) => true;
914 get hashCode => 0; 917 get hashCode => 0;
915 } 918 }
916 main() { 919 main() {
917 new A() == new B(); 920 new A() == new B();
918 }"""; 921 }""";
919 final compiler = compileScript(script); 922 asyncTest(() => compileScript(script).then((compiler) {
920 Expect.equals(1, compiler.warnings.length); 923 Expect.equals(1, compiler.warnings.length);
921 Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE, 924 Expect.equals(MessageKind.OVERRIDE_EQUALS_NOT_HASH_CODE,
922 compiler.warnings[0].message.kind); 925 compiler.warnings[0].message.kind);
923 Expect.equals(0, compiler.errors.length); 926 Expect.equals(0, compiler.errors.length);
927 }));
924 } 928 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698