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

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

Issue 165143004: Move TypeMask.simplify to a test helper. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 years, 10 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 "package:async_helper/async_helper.dart"; 6 import "package:async_helper/async_helper.dart";
7 import 'compiler_helper.dart'; 7 import 'compiler_helper.dart';
8 import 'type_mask_test_helper.dart';
8 9
9 const String TEST = """ 10 const String TEST = """
10 returnInt1() { 11 returnInt1() {
11 var a = 42; 12 var a = 42;
12 var f = () { 13 var f = () {
13 return a; 14 return a;
14 }; 15 };
15 return a; 16 return a;
16 } 17 }
17 18
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 117
117 void main() { 118 void main() {
118 Uri uri = new Uri(scheme: 'source'); 119 Uri uri = new Uri(scheme: 'source');
119 var compiler = compilerFor(TEST, uri); 120 var compiler = compilerFor(TEST, uri);
120 asyncTest(() => compiler.runCompiler(uri).then((_) { 121 asyncTest(() => compiler.runCompiler(uri).then((_) {
121 var typesInferrer = compiler.typesTask.typesInferrer; 122 var typesInferrer = compiler.typesTask.typesInferrer;
122 123
123 checkReturn(String name, type) { 124 checkReturn(String name, type) {
124 var element = findElement(compiler, name); 125 var element = findElement(compiler, name);
125 Expect.equals(type, 126 Expect.equals(type,
126 typesInferrer.getReturnTypeOfElement(element).simplify(compiler), 127 simplify(typesInferrer.getReturnTypeOfElement(element), compiler),
127 name); 128 name);
128 } 129 }
129 130
130 checkReturn('returnInt1', compiler.typesTask.uint31Type); 131 checkReturn('returnInt1', compiler.typesTask.uint31Type);
131 checkReturn('returnInt2', compiler.typesTask.uint31Type); 132 checkReturn('returnInt2', compiler.typesTask.uint31Type);
132 checkReturn('returnInt3', compiler.typesTask.uint31Type); 133 checkReturn('returnInt3', compiler.typesTask.uint31Type);
133 checkReturn('returnInt4', compiler.typesTask.uint31Type); 134 checkReturn('returnInt4', compiler.typesTask.uint31Type);
134 checkReturn('returnIntOrNull', compiler.typesTask.uint31Type.nullable()); 135 checkReturn('returnIntOrNull', compiler.typesTask.uint31Type.nullable());
135 136
136 checkReturn('returnDyn1', compiler.typesTask.dynamicType.nonNullable()); 137 checkReturn('returnDyn1', compiler.typesTask.dynamicType.nonNullable());
137 checkReturn('returnDyn2', compiler.typesTask.dynamicType.nonNullable()); 138 checkReturn('returnDyn2', compiler.typesTask.dynamicType.nonNullable());
138 checkReturn('returnDyn3', compiler.typesTask.dynamicType.nonNullable()); 139 checkReturn('returnDyn3', compiler.typesTask.dynamicType.nonNullable());
139 checkReturn('returnNum1', compiler.typesTask.numType); 140 checkReturn('returnNum1', compiler.typesTask.numType);
140 141
141 checkReturnInClass(String className, String methodName, type) { 142 checkReturnInClass(String className, String methodName, type) {
142 var cls = findElement(compiler, className); 143 var cls = findElement(compiler, className);
143 var element = cls.lookupLocalMember(methodName); 144 var element = cls.lookupLocalMember(methodName);
144 Expect.equals(type, 145 Expect.equals(type,
145 typesInferrer.getReturnTypeOfElement(element).simplify(compiler)); 146 simplify(typesInferrer.getReturnTypeOfElement(element), compiler));
146 } 147 }
147 var cls = findElement(compiler, 'A'); 148 var cls = findElement(compiler, 'A');
148 checkReturnInClass('A', 'foo', new TypeMask.nonNullExact(cls)); 149 checkReturnInClass('A', 'foo', new TypeMask.nonNullExact(cls));
149 })); 150 }));
150 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698