Migrate "s" directory language tests off @compile-error.

The "@compile-error" comment is an old not-great way of defining static
error tests.

See: https://github.com/dart-lang/sdk/issues/45634
Change-Id: I6218c6ea339b6c19c1495b1db9b2da3fe1654718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296440
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
This commit is contained in:
Robert Nystrom 2023-04-20 17:59:44 +00:00 committed by Commit Queue
parent cd5883fa85
commit 1b422af61f
10 changed files with 42 additions and 24 deletions

View file

@ -4,12 +4,9 @@
/// Part file has library and import directives. /// Part file has library and import directives.
/*@compile-error=unspecified*/ // TODO(rnystrom): Using a multitest instead of making this a static error test
// TODO(rnystrom): Using the above tag instead of making this a static error // because the error is reported in the part file and not in this file. Once
// test because the error is reported in the part file and not in this file. // issue #44990 is fixed, this can be a static error test.
// Static error tests only support errors reported in the main test file itself. part "script2_part.dart"; //# 01: compile-time error
part "script2_part.dart";
main() { main() {}
print("Should not reach here.");
}

View file

@ -10,7 +10,9 @@ class A {
} }
void set a(var val) { void set a(var val) {
/*@compile-error=unspecified*/ // ^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [cfe] 'a' is already declared in this scope.
int i = val; int i = val;
} }
} }

View file

@ -4,7 +4,10 @@
import "package:expect/expect.dart"; import "package:expect/expect.dart";
int x = "milou"; /*@compile-error=unspecified*/ int x = "milou";
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
bool readXThrows() { bool readXThrows() {
try { try {

View file

@ -21,7 +21,11 @@ class C extends B {
void foo([x]) { void foo([x]) {
// But it is a problem to try to pass `x` along to super, since the super // But it is a problem to try to pass `x` along to super, since the super
// method is A.foo. // method is A.foo.
super.foo(/*@compile-error=unspecified*/ x); super.foo(x);
// ^
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
} }
} }

View file

@ -17,7 +17,10 @@ class EmptyBlockCaseTest {
static testMain() { static testMain() {
var exception = null; var exception = null;
switch (1) { switch (1) {
case 1: /*@compile-error=unspecified*/ case 1:
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.SWITCH_CASE_COMPLETES_NORMALLY
// [cfe] Switch case may fall through to the next case.
{} {}
case 2: case 2:
Expect.equals(true, false); Expect.equals(true, false);

View file

@ -6,12 +6,9 @@
/// Part file has library and import directives. /// Part file has library and import directives.
/*@compile-error=unspecified*/ // TODO(rnystrom): Using a multitest instead of making this a static error test
// TODO(rnystrom): Using the above tag instead of making this a static error // because the error is reported in the part file and not in this file. Once
// test because the error is reported in the part file and not in this file. // issue #44990 is fixed, this can be a static error test.
// Static error tests only support errors reported in the main test file itself. part "script2_part.dart"; //# 01: compile-time error
part "script2_part.dart";
main() { main() {}
print("Should not reach here.");
}

View file

@ -12,7 +12,9 @@ class A {
} }
void set a(var val) { void set a(var val) {
/*@compile-error=unspecified*/ // ^
// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
// [cfe] 'a' is already declared in this scope.
int i = val; int i = val;
} }
} }

View file

@ -6,7 +6,10 @@
import "package:expect/expect.dart"; import "package:expect/expect.dart";
int x = "milou"; /*@compile-error=unspecified*/ int x = "milou";
// ^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
bool readXThrows() { bool readXThrows() {
try { try {

View file

@ -23,7 +23,11 @@ class C extends B {
void foo([x]) { void foo([x]) {
// But it is a problem to try to pass `x` along to super, since the super // But it is a problem to try to pass `x` along to super, since the super
// method is A.foo. // method is A.foo.
super.foo(/*@compile-error=unspecified*/ x); super.foo(x);
// ^
// [cfe] Too many positional arguments: 0 allowed, but 1 found.
// ^
// [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
} }
} }

View file

@ -16,7 +16,10 @@ import "package:expect/expect.dart";
class EmptyBlockCaseTest { class EmptyBlockCaseTest {
static testMain() { static testMain() {
switch (1) { switch (1) {
case 1: /*@compile-error=unspecified*/ case 1:
// ^^^^
// [analyzer] COMPILE_TIME_ERROR.CASE_BLOCK_NOT_TERMINATED
// [cfe] Switch case may fall through to the next case.
{} {}
case 2: case 2:
Expect.equals(true, false); Expect.equals(true, false);