| 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;
|
| }
|
|
|