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

Unified Diff: tests/language/type_cast_vm_test.dart

Issue 13190014: Optimizes 'as' operation in similar way as 'instanceof': collect type feedback in unoptimized mode… (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 | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/type_cast_vm_test.dart
===================================================================
--- tests/language/type_cast_vm_test.dart (revision 20744)
+++ tests/language/type_cast_vm_test.dart (working copy)
@@ -5,6 +5,15 @@
//
// Dart test program testing type casts.
+checkTopFunction(String expected, Stacktrace stacktrace) {
+ var topLine = stacktrace.toString().split("\n")[0];
+ int startPos = topLine.lastIndexOf("/");
+ int endPos = topLine.lastIndexOf(")");
+ String subs = topLine.substring(startPos + 1, endPos);
+ Expect.equals(expected, subs);
+}
+
+
// Test that the initializer expression gets properly skipped.
bool b = "foo" as double;
@@ -24,9 +33,9 @@
pos = error.url.lastIndexOf("\\", error.url.length);
}
String subs = error.url.substring(pos + 1, error.url.length);
- Expect.equals("type_cast_vm_test.dart", subs);
- Expect.equals(15, error.line);
- Expect.equals(23, error.column);
+ Expect.equals("dart:core-patch", subs);
+ Expect.equals(1889, error.line);
+ Expect.equals(1, error.column);
}
return result;
}
@@ -66,9 +75,9 @@
pos = error.url.lastIndexOf("\\", error.url.length);
}
String subs = error.url.substring(pos + 1, error.url.length);
- Expect.equals("type_cast_vm_test.dart", subs);
- Expect.equals(57, error.line);
- Expect.equals(25, error.column);
+ Expect.equals("dart:core-patch", subs);
+ Expect.equals(1889, error.line);
+ Expect.equals(1, error.column);
}
return result;
}
@@ -80,43 +89,30 @@
}
try {
int i = f("hello");
- } on TypeError catch (error) {
+ } on TypeError catch (error, stacktrace) {
result = 1;
Expect.isTrue(error is CastError);
Expect.equals("int", error.dstType);
Expect.equals("String", error.srcType);
Expect.equals("type cast", error.dstName);
- int pos = error.url.lastIndexOf("/", error.url.length);
- if (pos == -1) {
- pos = error.url.lastIndexOf("\\", error.url.length);
- }
- String subs = error.url.substring(pos + 1, error.url.length);
- Expect.equals("type_cast_vm_test.dart", subs);
- Expect.equals(79, error.line);
- Expect.equals(16, error.column);
+ checkTopFunction("type_cast_vm_test.dart:88:16", stacktrace);
}
return result;
}
static var field = "hello";
+
static testField() {
int result = 0;
Expect.equals(5, (field as String).length);
try {
field as int; // Throws a CastError
- } on TypeError catch (error) {
+ } on TypeError catch (error, stacktrace) {
result = 1;
Expect.equals("int", error.dstType);
Expect.equals("String", error.srcType);
Expect.equals("type cast", error.dstName);
- int pos = error.url.lastIndexOf("/", error.url.length);
- if (pos == -1) {
- pos = error.url.lastIndexOf("\\", error.url.length);
- }
- String subs = error.url.substring(pos + 1, error.url.length);
- Expect.equals("type_cast_vm_test.dart", subs);
- Expect.equals(106, error.line);
- Expect.equals(13, error.column);
+ checkTopFunction("type_cast_vm_test.dart:109:13", stacktrace);
}
return result;
}
@@ -129,19 +125,12 @@
anyFunction = null as Function; // No error.
try {
var i = f as int; // Throws a TypeError if type checks are enabled.
- } on TypeError catch (error) {
+ } on TypeError catch (error, stacktrace) {
result = 1;
Expect.equals("int", error.dstType);
Expect.equals("() => dynamic", error.srcType);
Expect.equals("type cast", error.dstName);
- int pos = error.url.lastIndexOf("/", error.url.length);
- if (pos == -1) {
- pos = error.url.lastIndexOf("\\", error.url.length);
- }
- String subs = error.url.substring(pos + 1, error.url.length);
- Expect.equals("type_cast_vm_test.dart", subs);
- Expect.equals(131, error.line);
- Expect.equals(17, error.column);
+ checkTopFunction("type_cast_vm_test.dart:127:17", stacktrace);
}
return result;
}
« no previous file with comments | « runtime/vm/symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698