| Index: tests/language/type_vm_test.dart
|
| ===================================================================
|
| --- tests/language/type_vm_test.dart (revision 25753)
|
| +++ tests/language/type_vm_test.dart (working copy)
|
| @@ -3,26 +3,27 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
| // VMOptions=--enable_type_checks --no_show_internal_names
|
| // Dart test program testing type checks.
|
| +
|
| import "package:expect/expect.dart";
|
|
|
| +class C {
|
| + factory C() {
|
| + return 1; // Implicit result type is 'C', not int.
|
| + }
|
| +}
|
| +
|
| class TypeTest {
|
| static test() {
|
| int result = 0;
|
| try {
|
| int i = "hello"; // 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("String", error.srcType);
|
| - Expect.equals("i", 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_vm_test.dart", subs);
|
| - Expect.equals(12, error.line);
|
| - Expect.equals(15, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'int'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("'i'")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:19:15"));
|
| }
|
| return result;
|
| }
|
| @@ -51,19 +52,13 @@
|
| }
|
| try {
|
| int i = f("hello"); // 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("String", error.srcType);
|
| - Expect.equals("i", 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_vm_test.dart", subs);
|
| - Expect.equals(49, error.line);
|
| - Expect.equals(15, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'int'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("'i'")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:50:15"));
|
| }
|
| return result;
|
| }
|
| @@ -75,19 +70,13 @@
|
| }
|
| try {
|
| int i = f("hello"); // 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("String", error.srcType);
|
| - Expect.equals("function result", 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_vm_test.dart", subs);
|
| - Expect.equals(74, error.line);
|
| - Expect.equals(14, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'int'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("function result")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:69:14"));
|
| }
|
| return result;
|
| }
|
| @@ -97,19 +86,13 @@
|
| int result = 0;
|
| try {
|
| field = "hello"; // 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("String", error.srcType);
|
| - Expect.equals("field", 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_vm_test.dart", subs);
|
| - Expect.equals(99, error.line);
|
| - Expect.equals(15, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'int'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("'field'")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:88:15"));
|
| }
|
| return result;
|
| }
|
| @@ -121,19 +104,13 @@
|
| anyFunction = f; // No error.
|
| try {
|
| int i = f; // 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("i", 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_vm_test.dart", subs);
|
| - Expect.equals(123, error.line);
|
| - Expect.equals(15, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'int'")); // dstType
|
| + Expect.isTrue(msg.contains("'() => dynamic'")); // srcType
|
| + Expect.isTrue(msg.contains("'i'")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:106:15"));
|
| }
|
| return result;
|
| }
|
| @@ -152,19 +129,13 @@
|
| acceptObjFunObj(objFunObj);
|
| try {
|
| acceptObjFunObj(voidFunObj); // Throws a TypeError.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result = 1;
|
| - Expect.equals("(Object) => Object", error.dstType);
|
| - Expect.equals("(Object) => void", error.srcType);
|
| - Expect.equals("objFunObj", 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_vm_test.dart", subs);
|
| - Expect.equals(145, error.line);
|
| - Expect.equals(33, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'(Object) => Object'")); // dstType
|
| + Expect.isTrue(msg.contains("'(Object) => void'")); // srcType
|
| + Expect.isTrue(msg.contains("'objFunObj'")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:122:33"));
|
| }
|
| return result;
|
| }
|
| @@ -186,19 +157,13 @@
|
| acceptFunNum(funInt); // No error.
|
| try {
|
| acceptFunNum(funString); // Throws an error.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result = 1;
|
| - Expect.equals("(num) => void", error.dstType);
|
| - Expect.equals("(String) => void", error.srcType);
|
| - Expect.equals("funNum", 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_vm_test.dart", subs);
|
| - Expect.equals(175, error.line);
|
| - Expect.equals(28, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'(num) => void'")); // dstType
|
| + Expect.isTrue(msg.contains("'(String) => void'")); // srcType
|
| + Expect.isTrue(msg.contains("'funNum'")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:146:28"));
|
| }
|
| return result;
|
| }
|
| @@ -207,147 +172,93 @@
|
| int result = 0;
|
| try {
|
| bool i = !"hello"; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(209, error.line);
|
| - Expect.equals(17, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:174:17"));
|
| }
|
| try {
|
| while ("hello") {}; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(225, error.line);
|
| - Expect.equals(14, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:184:14"));
|
| }
|
| try {
|
| do {} while ("hello"); // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(241, error.line);
|
| - Expect.equals(20, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:194:20"));
|
| }
|
| try {
|
| for (;"hello";) {}; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(257, error.line);
|
| - Expect.equals(13, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:204:13"));
|
| }
|
| try {
|
| int i = "hello" ? 1 : 0; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(273, error.line);
|
| - Expect.equals(15, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:214:15"));
|
| }
|
| try {
|
| if ("hello") {}; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(289, error.line);
|
| - Expect.equals(11, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:224:11"));
|
| }
|
| try {
|
| if ("hello" || false) {}; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(305, error.line);
|
| - Expect.equals(11, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:234:11"));
|
| }
|
| try {
|
| if (false || "hello") {}; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("String", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(321, error.line);
|
| - Expect.equals(20, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'String'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:244:20"));
|
| }
|
| try {
|
| if (null) {}; // Throws a TypeError if type checks are enabled.
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("bool", error.dstType);
|
| - Expect.equals("Null", error.srcType);
|
| - Expect.equals("boolean expression", 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_vm_test.dart", subs);
|
| - Expect.equals(337, error.line);
|
| - Expect.equals(11, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'bool'")); // dstType
|
| + Expect.isTrue(msg.contains("'Null'")); // srcType
|
| + Expect.isTrue(msg.contains("boolean expression")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:254:11"));
|
| }
|
| return result;
|
| }
|
| @@ -357,19 +268,13 @@
|
| int result = 0;
|
| try {
|
| var x = new C();
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("C", error.dstType);
|
| - Expect.equals("int", error.srcType);
|
| - Expect.equals("function result", 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_vm_test.dart", subs);
|
| - Expect.equals(560, error.line);
|
| - Expect.equals(12, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'C'")); // dstType
|
| + Expect.isTrue(msg.contains("'int'")); // srcType
|
| + Expect.isTrue(msg.contains("function result")); // dstName
|
| + Expect.isTrue(stacktrace.toString().contains("type_vm_test.dart:11:12"));
|
| }
|
| return result;
|
| }
|
| @@ -390,51 +295,36 @@
|
| List<Object> ao = a;
|
| try {
|
| List<int> ai = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<int>", error.dstType);
|
| - Expect.equals("List<Object>", error.srcType);
|
| - Expect.equals("ai", 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_vm_test.dart", subs);
|
| - Expect.equals(392, error.line);
|
| - Expect.equals(24, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<int>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<Object>'")); // srcType
|
| + Expect.isTrue(msg.contains("'ai'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:297:24"));
|
| }
|
| try {
|
| List<num> an = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<num>", error.dstType);
|
| - Expect.equals("List<Object>", error.srcType);
|
| - Expect.equals("an", 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_vm_test.dart", subs);
|
| - Expect.equals(408, error.line);
|
| - Expect.equals(24, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<num>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<Object>'")); // srcType
|
| + Expect.isTrue(msg.contains("'an'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:308:24"));
|
| }
|
| try {
|
| List<String> as = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<String>", error.dstType);
|
| - Expect.equals("List<Object>", error.srcType);
|
| - Expect.equals("as", 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_vm_test.dart", subs);
|
| - Expect.equals(424, error.line);
|
| - Expect.equals(27, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<String>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<Object>'")); // srcType
|
| + Expect.isTrue(msg.contains("'as'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:319:27"));
|
| }
|
| }
|
| {
|
| @@ -445,19 +335,14 @@
|
| List<num> an = a;
|
| try {
|
| List<String> as = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<String>", error.dstType);
|
| - Expect.equals("List<int>", error.srcType);
|
| - Expect.equals("as", 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_vm_test.dart", subs);
|
| - Expect.equals(447, error.line);
|
| - Expect.equals(27, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<String>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<int>'")); // srcType
|
| + Expect.isTrue(msg.contains("'as'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:337:27"));
|
| }
|
| }
|
| {
|
| @@ -466,36 +351,26 @@
|
| List<Object> ao = a;
|
| try {
|
| List<int> ai = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<int>", error.dstType);
|
| - Expect.equals("List<num>", error.srcType);
|
| - Expect.equals("ai", 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_vm_test.dart", subs);
|
| - Expect.equals(468, error.line);
|
| - Expect.equals(24, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<int>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<num>'")); // srcType
|
| + Expect.isTrue(msg.contains("'ai'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:353:24"));
|
| }
|
| List<num> an = a;
|
| try {
|
| List<String> as = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<String>", error.dstType);
|
| - Expect.equals("List<num>", error.srcType);
|
| - Expect.equals("as", 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_vm_test.dart", subs);
|
| - Expect.equals(485, error.line);
|
| - Expect.equals(27, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<String>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<num>'")); // srcType
|
| + Expect.isTrue(msg.contains("'as'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:365:27"));
|
| }
|
| }
|
| {
|
| @@ -504,35 +379,25 @@
|
| List<Object> ao = a;
|
| try {
|
| List<int> ai = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<int>", error.dstType);
|
| - Expect.equals("List<String>", error.srcType);
|
| - Expect.equals("ai", 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_vm_test.dart", subs);
|
| - Expect.equals(506, error.line);
|
| - Expect.equals(24, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<int>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<String>'")); // srcType
|
| + Expect.isTrue(msg.contains("'ai'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:381:24"));
|
| }
|
| try {
|
| List<num> an = a;
|
| - } on TypeError catch (error) {
|
| + } on TypeError catch (error, stacktrace) {
|
| result++;
|
| - Expect.equals("List<num>", error.dstType);
|
| - Expect.equals("List<String>", error.srcType);
|
| - Expect.equals("an", 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_vm_test.dart", subs);
|
| - Expect.equals(522, error.line);
|
| - Expect.equals(24, error.column);
|
| + var msg = error.toString();
|
| + Expect.isTrue(msg.contains("'List<num>'")); // dstType
|
| + Expect.isTrue(msg.contains("'List<String>'")); // srcType
|
| + Expect.isTrue(msg.contains("'an'")); // dstName
|
| + Expect.isTrue(
|
| + stacktrace.toString().contains("type_vm_test.dart:392:24"));
|
| }
|
| List<String> as = a;
|
| }
|
| @@ -554,14 +419,6 @@
|
| }
|
| }
|
|
|
| -
|
| -class C {
|
| - factory C() {
|
| - return 1; // Implicit result type is 'C', not int.
|
| - }
|
| -}
|
| -
|
| -
|
| main() {
|
| TypeTest.testMain();
|
| }
|
|
|