mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[test] Convert syntax_native_test to a static error test
Multitests of compile-time errors should be converted to static error tests, so they don't run on runtime configurations. Static error tests also test for all the static errors, their positions, and error message, in a single test run. This test is currently failing on the common front end, and on all runtimes, and passing on the analyzer. The change keeps the failure on common front end by adding expectations for an error to be reported at the right places. Bug: https://github.com/dart-lang/sdk/issues/54153 Change-Id: Ic64961f6e0e575ec60626d4f70a0fdc5d71d024e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363085 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: William Hesse <whesse@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com>
This commit is contained in:
parent
26652c6d31
commit
d6c9c9f8bf
|
@ -4,31 +4,37 @@
|
|||
|
||||
class DOMWindow {}
|
||||
|
||||
class Window extends DOMWindow
|
||||
native "*Window" //# 28: syntax error
|
||||
{}
|
||||
class Window extends DOMWindow native "*Window" {}
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
|
||||
class Console
|
||||
native "=(typeof console == 'undefined' ? {} : console)" //# 29: syntax error
|
||||
{}
|
||||
class Console native "=(typeof console == 'undefined' ? {} : console)" {}
|
||||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
|
||||
class NativeClass
|
||||
native "FooBar" //# 30: syntax error
|
||||
{}
|
||||
class NativeClass native "FooBar" {}
|
||||
// ^^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
|
||||
abstract class Fisk {}
|
||||
|
||||
class BoolImplementation implements Fisk
|
||||
native "Boolean" //# 31: syntax error
|
||||
{}
|
||||
class BoolImplementation implements Fisk native "Boolean" {}
|
||||
// ^^^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
|
||||
class _JSON
|
||||
native 'JSON' //# 32: syntax error
|
||||
{}
|
||||
class _JSON native 'JSON' {}
|
||||
// ^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
|
||||
class ListFactory<E> implements List<E>
|
||||
native "Array" //# 33: syntax error
|
||||
{
|
||||
class ListFactory<E> implements List<E> native "Array" {
|
||||
// ^^^^^^^^^^^^^^
|
||||
// [analyzer] SYNTACTIC_ERROR.NATIVE_CLAUSE_IN_NON_SDK_CODE
|
||||
// [cfe] expect cfe to report an error here
|
||||
noSuchMethod(_) => null; // Allow unimplemented methods
|
||||
}
|
||||
|
||||
|
@ -45,4 +51,5 @@ main() {
|
|||
// Swallowing exceptions. Any error should be a compile-time error
|
||||
// which kills the current isolate.
|
||||
}
|
||||
throw 'This test should fail to compile, not throw a run-time error.';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue