mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 09:43:08 +00:00
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:
parent
cd5883fa85
commit
1b422af61f
10 changed files with 42 additions and 24 deletions
|
@ -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.");
|
|
||||||
}
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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.");
|
|
||||||
}
|
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in a new issue