[test] Extract test for "native"

This move the test of the "native" syntax, support by the CFE, to
a separate test. The test (expecting the syntax to _not_ be supported)
fails on the CFE but that has nothing to with the records/patterns
features which the remaining tests in syntax_test.dart require.

Change-Id: Idef0d8b58b24488bcd4e3318eac9638152056b2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280111
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Johnni Winther 2023-02-01 10:06:37 +00:00 committed by Commit Queue
parent 6074b4ff0d
commit e77907f755
2 changed files with 48 additions and 33 deletions

View file

@ -0,0 +1,48 @@
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class DOMWindow {}
class Window extends DOMWindow
native "*Window" //# 28: syntax error
{}
class Console
native "=(typeof console == 'undefined' ? {} : console)" //# 29: syntax error
{}
class NativeClass
native "FooBar" //# 30: syntax error
{}
abstract class Fisk {}
class BoolImplementation implements Fisk
native "Boolean" //# 31: syntax error
{}
class _JSON
native 'JSON' //# 32: syntax error
{}
class ListFactory<E> implements List<E>
native "Array" //# 33: syntax error
{
noSuchMethod(_) => null; // Allow unimplemented methods
}
main() {
try {
new Window();
new Console();
new NativeClass();
new BoolImplementation();
new _JSON();
new ListFactory();
new ListFactory<Object>();
} catch (ex) {
// Swallowing exceptions. Any error should be a compile-time error
// which kills the current isolate.
}
}

View file

@ -90,34 +90,8 @@ fisk {} //# 27: syntax error
class DOMWindow {}
class Window extends DOMWindow
native "*Window" //# 28: syntax error
{}
class Console
native "=(typeof console == 'undefined' ? {} : console)" //# 29: syntax error
{}
class NativeClass
native "FooBar" //# 30: syntax error
{}
abstract class Fisk {}
class BoolImplementation implements Fisk
native "Boolean" //# 31: syntax error
{}
class _JSON
native 'JSON' //# 32: syntax error
{}
class ListFactory<E> implements List<E>
native "Array" //# 33: syntax error
{
noSuchMethod(_) => null; // Allow unimplemented methods
}
abstract class I implements UNKNOWN; //# 34: syntax error
class XWindow extends DOMWindow
@ -193,13 +167,6 @@ main() {
SyntaxTest.foo(); //# 03: continued
fisk(); //# 27: continued
new Window();
new Console();
new NativeClass();
new BoolImplementation();
new _JSON();
new ListFactory();
new ListFactory<Object>();
var x = null;
x is I; //# 34: continued