mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:06:59 +00:00
Migrate standalone tests off @compile-error.
The "@compile-error" comment is an old not-great way of defining static error tests. Note that the behavior of the code under test here had changed significantly, but the test didn't catch it at all because "@compile-error" is too coarse-grained. See: https://github.com/dart-lang/sdk/issues/45634 Change-Id: I4b6c4e1fd36770e13f7b5ca100b42b0b8b2983ae Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296121 Commit-Queue: Jake Macdonald <jakemac@google.com> Reviewed-by: Jake Macdonald <jakemac@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
363a61d72b
commit
105a0f30d6
|
@ -17,17 +17,23 @@ void testIndexOf32() {
|
|||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
/*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10));
|
||||
/*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15));
|
||||
/*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19));
|
||||
/*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20));
|
||||
|
||||
// These used to be type errors when passing integers to indexOf() which
|
||||
// expects a double, but are no longer an error because of int-to-double.
|
||||
Expect.equals(0, list.indexOf(10));
|
||||
Expect.equals(5, list.indexOf(15));
|
||||
Expect.equals(9, list.indexOf(19));
|
||||
Expect.equals(-1, list.indexOf(20));
|
||||
}
|
||||
|
||||
void testBadValues32() {
|
||||
var list = new Float32List(10);
|
||||
list[0] = 2.0;
|
||||
/*@compile-error=unspecified*/ list[0] = 2;
|
||||
/*@compile-error=unspecified*/ list[0] = "hello";
|
||||
list[0] = 2; // Not an error because of int-to-double.
|
||||
list[0] = "hello";
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'double'.
|
||||
}
|
||||
|
||||
void testIndexOf64() {
|
||||
|
@ -35,17 +41,23 @@ void testIndexOf64() {
|
|||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
/*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10));
|
||||
/*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15));
|
||||
/*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19));
|
||||
/*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20));
|
||||
|
||||
// These used to be type errors when passing integers to indexOf() which
|
||||
// expects a double, but are no longer an error because of int-to-double.
|
||||
Expect.equals(0, list.indexOf(10));
|
||||
Expect.equals(5, list.indexOf(15));
|
||||
Expect.equals(9, list.indexOf(19));
|
||||
Expect.equals(-1, list.indexOf(20));
|
||||
}
|
||||
|
||||
void testBadValues64() {
|
||||
var list = new Float64List(10);
|
||||
list[0] = 2.0;
|
||||
/*@compile-error=unspecified*/ list[0] = 2;
|
||||
/*@compile-error=unspecified*/ list[0] = "hello";
|
||||
list[0] = 2; // Not an error because of int-to-double.
|
||||
list[0] = "hello";
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'double'.
|
||||
}
|
||||
|
||||
main() {
|
||||
|
|
|
@ -19,17 +19,23 @@ void testIndexOf32() {
|
|||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
/*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10));
|
||||
/*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15));
|
||||
/*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19));
|
||||
/*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20));
|
||||
|
||||
// These used to be type errors when passing integers to indexOf() which
|
||||
// expects a double, but are no longer an error because of int-to-double.
|
||||
Expect.equals(0, list.indexOf(10));
|
||||
Expect.equals(5, list.indexOf(15));
|
||||
Expect.equals(9, list.indexOf(19));
|
||||
Expect.equals(-1, list.indexOf(20));
|
||||
}
|
||||
|
||||
void testBadValues32() {
|
||||
var list = new Float32List(10);
|
||||
list[0] = 2.0;
|
||||
/*@compile-error=unspecified*/ list[0] = 2;
|
||||
/*@compile-error=unspecified*/ list[0] = "hello";
|
||||
list[0] = 2; // Not an error because of int-to-double.
|
||||
list[0] = "hello";
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'double'.
|
||||
}
|
||||
|
||||
void testIndexOf64() {
|
||||
|
@ -37,17 +43,23 @@ void testIndexOf64() {
|
|||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = i + 10.0;
|
||||
}
|
||||
/*@compile-error=unspecified*/ Expect.equals(0, list.indexOf(10));
|
||||
/*@compile-error=unspecified*/ Expect.equals(5, list.indexOf(15));
|
||||
/*@compile-error=unspecified*/ Expect.equals(9, list.indexOf(19));
|
||||
/*@compile-error=unspecified*/ Expect.equals(-1, list.indexOf(20));
|
||||
|
||||
// These used to be type errors when passing integers to indexOf() which
|
||||
// expects a double, but are no longer an error because of int-to-double.
|
||||
Expect.equals(0, list.indexOf(10));
|
||||
Expect.equals(5, list.indexOf(15));
|
||||
Expect.equals(9, list.indexOf(19));
|
||||
Expect.equals(-1, list.indexOf(20));
|
||||
}
|
||||
|
||||
void testBadValues64() {
|
||||
var list = new Float64List(10);
|
||||
list[0] = 2.0;
|
||||
/*@compile-error=unspecified*/ list[0] = 2;
|
||||
/*@compile-error=unspecified*/ list[0] = "hello";
|
||||
list[0] = 2; // Not an error because of int-to-double.
|
||||
list[0] = "hello";
|
||||
// ^^^^^^^
|
||||
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
|
||||
// [cfe] A value of type 'String' can't be assigned to a variable of type 'double'.
|
||||
}
|
||||
|
||||
main() {
|
||||
|
|
Loading…
Reference in a new issue