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

Unified Diff: tests/compiler/dart2js/call_site_simple_type_inferer_test.dart

Issue 12781005: Track argument types, and remove obsolete code that also used to track it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/concrete_type_inference_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/call_site_simple_type_inferer_test.dart
===================================================================
--- tests/compiler/dart2js/call_site_simple_type_inferer_test.dart (revision 19875)
+++ tests/compiler/dart2js/call_site_simple_type_inferer_test.dart (working copy)
@@ -1,9 +1,9 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import '../../../sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart';
-import '../../../sdk/lib/_internal/compiler/implementation/ssa/ssa.dart';
+import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'
+ show TypeMask;
import 'compiler_helper.dart';
import 'parser_helper.dart';
@@ -19,7 +19,7 @@
compiler.runCompiler(uri);
var cls = findElement(compiler, className);
var member = cls.lookupLocalMember(buildSourceString(memberName));
- return check(compiler.backend, member);
+ return check(compiler.typesTask.typesInferrer, member);
}
const String TEST_1 = r"""
@@ -200,73 +200,63 @@
}
""";
-void doTest(String test,
- bool enableInlining,
- List<HType> expectedTypes,
- OptionalParameterTypes defaultTypes) {
+void doTest(String test, bool enableInlining, Function f) {
compileAndFind(
test,
'A',
'x',
enableInlining,
- (backend, x) {
- HTypeList types = backend.optimisticParameterTypes(x, defaultTypes);
- if (expectedTypes != null) {
- Expect.isFalse(types.allUnknown);
- Expect.listEquals(expectedTypes, types.types);
- } else {
- Expect.isTrue(types.allUnknown);
- }
+ (inferrer, element) {
+ var expectedTypes = f(inferrer);
+ var signature = element.computeSignature(inferrer.compiler);
+ int index = 0;
+ print(inferrer.typeOf);
+ signature.forEachParameter((Element element) {
+ Expect.equals(expectedTypes[index++], inferrer.typeOf[element]);
+ });
+ Expect.equals(index, expectedTypes.length);
});
}
-void runTest(String test,
- [List<HType> expectedTypes,
- OptionalParameterTypes defaultTypes]) {
- doTest(test, false, expectedTypes, defaultTypes);
- doTest(test, true, expectedTypes, defaultTypes);
+void runTest(String test, Function f) {
+ doTest(test, false, f);
+ doTest(test, true, f);
}
void test() {
- OptionalParameterTypes defaultTypes;
+ runTest(TEST_1, (inferrer) => [inferrer.stringType]);
+ runTest(TEST_2, (inferrer) => [inferrer.intType]);
+ runTest(TEST_3, (inferrer) => [inferrer.numType]);
+ runTest(TEST_4, (inferrer) => [inferrer.numType]);
+ runTest(TEST_5, (inferrer) => [inferrer.numType]);
+ runTest(TEST_6, (inferrer) => [inferrer.numType]);
+ runTest(TEST_7, (inferrer) => [inferrer.giveUpType]);
- runTest(TEST_1, [HType.STRING]);
- runTest(TEST_2, [HType.INTEGER]);
- runTest(TEST_3, [HType.INTEGER]);
- runTest(TEST_4, [HType.DOUBLE]);
- runTest(TEST_5, [HType.NUMBER]);
- runTest(TEST_6, [HType.NUMBER]);
- runTest(TEST_7);
- runTest(TEST_8, [HType.INTEGER, HType.UNKNOWN]);
- runTest(TEST_9, [HType.INTEGER, HType.INTEGER]);
- runTest(TEST_10, [HType.INTEGER, HType.INTEGER]);
- runTest(TEST_11);
+ // In the following tests, we can't infer the right types because we
+ // have recursive calls with the same parameters. We should build a
+ // constraint system for those, to find the types.
+ runTest(TEST_8, (inferrer) => [inferrer.dynamicType, inferrer.giveUpType]);
+ runTest(TEST_9, (inferrer) => [inferrer.dynamicType, inferrer.dynamicType]);
+ runTest(TEST_10, (inferrer) => [inferrer.dynamicType, inferrer.dynamicType]);
+ runTest(TEST_11, (inferrer) => [inferrer.giveUpType, inferrer.giveUpType]);
- defaultTypes = new OptionalParameterTypes(1);
- defaultTypes.update(0, const SourceString("p2"), HType.INTEGER);
- runTest(TEST_12, [HType.STRING, HType.INTEGER], defaultTypes);
+ runTest(TEST_12, (inferrer) => [inferrer.stringType, inferrer.intType]);
- runTest(TEST_13, [HType.NUMBER]);
+ runTest(TEST_13, (inferrer) => [inferrer.numType]);
- defaultTypes = new OptionalParameterTypes(1);
- defaultTypes.update(0, const SourceString("p2"), HType.STRING);
- runTest(TEST_14, [HType.INTEGER, HType.STRING], defaultTypes);
+ runTest(TEST_14, (inferrer) => [inferrer.intType, inferrer.stringType]);
- defaultTypes = new OptionalParameterTypes(1);
- defaultTypes.update(0, const SourceString("p2"), HType.BOOLEAN);
- runTest(TEST_15, [HType.STRING, HType.BOOLEAN], defaultTypes);
+ runTest(TEST_15, (inferrer) => [inferrer.stringType, inferrer.boolType]);
- defaultTypes = new OptionalParameterTypes(2);
- defaultTypes.update(0, const SourceString("p2"), HType.INTEGER);
- defaultTypes.update(1, const SourceString("p3"), HType.STRING);
- runTest(TEST_16, [HType.INTEGER, HType.INTEGER, HType.STRING], defaultTypes);
+ runTest(TEST_16, (inferrer) => [inferrer.intType,
+ inferrer.intType,
+ inferrer.stringType]);
- defaultTypes = new OptionalParameterTypes(2);
- defaultTypes.update(0, const SourceString("p2"), HType.INTEGER);
- defaultTypes.update(1, const SourceString("p3"), HType.STRING);
- runTest(TEST_17, [HType.INTEGER, HType.BOOLEAN, HType.DOUBLE], defaultTypes);
+ runTest(TEST_17, (inferrer) => [inferrer.intType,
+ inferrer.boolType,
+ inferrer.doubleType]);
- runTest(TEST_18);
+ runTest(TEST_18, (inferrer) => [inferrer.giveUpType, inferrer.giveUpType]);
}
void main() {
« no previous file with comments | « tests/co19/co19-dart2js.status ('k') | tests/compiler/dart2js/concrete_type_inference_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698