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

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

Issue 362243003: Generate mock libraries and assert that helpers are non-null. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix after rebase. Created 6 years, 5 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 | « tests/compiler/dart2js/patch_test.dart ('k') | tests/compiler/dart2js/size_test.dart » ('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 "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:async'; 6 import 'dart:async';
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import "package:compiler/implementation/resolution/resolution.dart"; 10 import "package:compiler/implementation/resolution/resolution.dart";
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 Expect.isTrue(bNode.modifiers.isVar); 672 Expect.isTrue(bNode.modifiers.isVar);
673 }); 673 });
674 } 674 }
675 675
676 Future resolveConstructor( 676 Future resolveConstructor(
677 String script, String statement, String className, 677 String script, String statement, String className,
678 String constructor, int expectedElementCount, 678 String constructor, int expectedElementCount,
679 {List expectedWarnings: const [], 679 {List expectedWarnings: const [],
680 List expectedErrors: const [], 680 List expectedErrors: const [],
681 List expectedInfos: const [], 681 List expectedInfos: const [],
682 String corelib: DEFAULT_CORELIB}) { 682 Map<String, String> corelib}) {
683 MockCompiler compiler = new MockCompiler.internal(coreSource: corelib); 683 MockCompiler compiler = new MockCompiler.internal(coreSource: corelib);
684 return compiler.init().then((_) { 684 return compiler.init().then((_) {
685 compiler.parseScript(script); 685 compiler.parseScript(script);
686 compiler.resolveStatement(statement); 686 compiler.resolveStatement(statement);
687 ClassElement classElement = compiler.mainApp.find(className); 687 ClassElement classElement = compiler.mainApp.find(className);
688 Element element; 688 Element element;
689 if (constructor != '') { 689 if (constructor != '') {
690 element = classElement.lookupConstructor( 690 element = classElement.lookupConstructor(
691 new Selector.callConstructor(constructor, classElement.library)); 691 new Selector.callConstructor(constructor, classElement.library));
692 } else { 692 } else {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 908 }
909 class B extends A { 909 class B extends A {
910 B() : super(0), super(1); 910 B() : super(0), super(1);
911 }"""; 911 }""";
912 return resolveConstructor(script, "B b = new B();", "B", "", 2, 912 return resolveConstructor(script, "B b = new B();", "B", "", 2,
913 expectedWarnings: [], 913 expectedWarnings: [],
914 expectedErrors: [MessageKind.DUPLICATE_SUPER_INITIALIZER]); 914 expectedErrors: [MessageKind.DUPLICATE_SUPER_INITIALIZER]);
915 }, 915 },
916 () { 916 () {
917 String script = ""; 917 String script = "";
918 final String CORELIB_WITH_INVALID_OBJECT = 918 final INVALID_OBJECT =
919 '''print(var obj) {} 919 const { 'Object': 'class Object { Object() : super(); }' };
920 class int {}
921 class double {}
922 class bool {}
923 class String {}
924 class num {}
925 class Function {}
926 class List<E> {}
927 class Map {}
928 class Closure {}
929 class Null {}
930 class StackTrace {}
931 class Dynamic_ {}
932 class Type {}
933 class Object { Object() : super(); }
934 const proxy = 0;''';
935 return resolveConstructor(script, 920 return resolveConstructor(script,
936 "Object o = new Object();", "Object", "", 1, 921 "Object o = new Object();", "Object", "", 1,
937 expectedWarnings: [], 922 expectedWarnings: [],
938 expectedErrors: [MessageKind.SUPER_INITIALIZER_IN_OBJECT], 923 expectedErrors: [MessageKind.SUPER_INITIALIZER_IN_OBJECT],
939 corelib: CORELIB_WITH_INVALID_OBJECT); 924 corelib: INVALID_OBJECT);
940 }, 925 },
941 ], (f) => f()); 926 ], (f) => f());
942 } 927 }
943 928
944 map(ResolverVisitor visitor) { 929 map(ResolverVisitor visitor) {
945 CollectingTreeElements elements = visitor.registry.mapping; 930 CollectingTreeElements elements = visitor.registry.mapping;
946 return elements.map; 931 return elements.map;
947 } 932 }
948 933
949 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); 934 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 }"""; 1066 }""";
1082 asyncTest(() => compileScript(script2).then((compiler) { 1067 asyncTest(() => compileScript(script2).then((compiler) {
1083 expect(compiler, 1068 expect(compiler,
1084 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS], 1069 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS],
1085 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 1070 [MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
1086 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR, 1071 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_CONSTRUCTOR,
1087 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD, 1072 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD,
1088 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]); 1073 MessageKind.CONST_CONSTRUCTOR_WITH_NONFINAL_FIELDS_FIELD]);
1089 })); 1074 }));
1090 } 1075 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/patch_test.dart ('k') | tests/compiler/dart2js/size_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698