mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 07:31:33 +00:00
40b6741778
This CL modifies the Dart source used from test.py such that it takes `syntax error` into account as an expected outcome in test files (so that we can have `//# 01: syntax error` with a similar meaning as `//# 01: compile-time error`). For all tools except the spec_parser, `syntax error` is the same outcome as `compile-time error`; that is, nobody else will see the difference. For the spec_parser, `syntax error` is the outcome where parsing has failed; `compile-time error` is taken to mean some other compile-time error, i.e., the spec_parser is expected to _succeed_ when the expected outcome is `compile-time error`. Test files in language and language_2 have been adjusted to use the outcome `syntax error` where appropriate. The status files in language and language_2 for the spec_parser have been adjusted such that they fit all the new `syntax error` outcomes in test files. Other status files have been adjusted in a few cases where tests were corrected (because a compile-time error which was clearly not intended to be a syntax error turned out to be caused by a typo, which means that the actual compile-time error has never been tested). The spec grammar Dart.g was adjusted in a few cases, when some bugs were discovered. In particular, the treatment of Function has been changed: It is now known by the parser that Function does not take any type arguments. This makes no difference for developers, because they cannot declare a type named Function anyway, but it means that a number of tricky parsing issues were resolved. Dart.g was also adjusted to allow `qualified` to contain three identifiers, which is an old bug (preventing things like metadata on the form `@p.C.myConst`). Change-Id: Ie420887d45c882ef97c84143365219f8aa0d2933 Reviewed-on: https://dart-review.googlesource.com/18262 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
250 lines
5.1 KiB
Dart
250 lines
5.1 KiB
Dart
// Copyright (c) 2012, 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 SyntaxTest {
|
|
// "this" cannot be used as a field name.
|
|
SyntaxTest this; //# 01: syntax error
|
|
|
|
// Syntax error.
|
|
foo {} //# 02: syntax error
|
|
|
|
// Syntax error.
|
|
static foo {} //# 03: syntax error
|
|
|
|
// Syntax error.
|
|
operator +=() {} //# 04: syntax error
|
|
|
|
// Syntax error.
|
|
operator -=() {} //# 05: syntax error
|
|
|
|
// Syntax error.
|
|
operator *=() {} //# 06: syntax error
|
|
|
|
// Syntax error.
|
|
operator /=() {} //# 07: syntax error
|
|
|
|
// Syntax error.
|
|
operator ~/=() {} //# 08: syntax error
|
|
|
|
// Syntax error.
|
|
operator %=() {} //# 09: syntax error
|
|
|
|
// Syntax error.
|
|
operator <<=() {} //# 10: syntax error
|
|
|
|
// Syntax error.
|
|
operator >>=() {} //# 11: syntax error
|
|
|
|
// Syntax error.
|
|
operator >>>=() {} //# 12: syntax error
|
|
|
|
// Syntax error.
|
|
operator &=() {} //# 13: syntax error
|
|
|
|
// Syntax error.
|
|
operator ^=() {} //# 14: syntax error
|
|
|
|
// Syntax error.
|
|
operator |=() {} //# 15: syntax error
|
|
|
|
// Syntax error.
|
|
operator ?() {} //# 16: syntax error
|
|
|
|
// Syntax error.
|
|
operator ||() {} //# 17: syntax error
|
|
|
|
// Syntax error.
|
|
operator &&() {} //# 18: syntax error
|
|
|
|
// Syntax error.
|
|
operator !=() {} //# 19: syntax error
|
|
|
|
// Syntax error.
|
|
operator ===() {} //# 20: syntax error
|
|
|
|
// Syntax error.
|
|
operator !==() {} //# 21: syntax error
|
|
|
|
// Syntax error.
|
|
operator is() {} //# 22: syntax error
|
|
|
|
// Syntax error.
|
|
operator !() {} //# 23: syntax error
|
|
|
|
// Syntax error.
|
|
operator ++() {} //# 24: syntax error
|
|
|
|
// Syntax error.
|
|
operator --() {} //# 25: syntax error
|
|
|
|
// Syntax error.
|
|
bool operator ===(A other) { return true; } //# 26: syntax error
|
|
|
|
int sample;
|
|
}
|
|
|
|
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
|
|
{}
|
|
|
|
abstract class I implements UNKNOWN; //# 34: syntax error
|
|
|
|
class XWindow extends DOMWindow
|
|
hest "*Window" //# 35: syntax error
|
|
{}
|
|
|
|
class XConsole
|
|
hest "=(typeof console == 'undefined' ? {} : console)" //# 36: syntax error
|
|
{}
|
|
|
|
class XNativeClass
|
|
hest "FooBar" //# 37: syntax error
|
|
{}
|
|
|
|
class XBoolImplementation implements Fisk
|
|
hest "Boolean" //# 38: syntax error
|
|
{}
|
|
|
|
class _JSONX
|
|
hest 'JSON' //# 39: syntax error
|
|
{}
|
|
|
|
class XListFactory<E> implements List<E>
|
|
hest "Array" //# 40: syntax error
|
|
{}
|
|
|
|
class YWindow extends DOMWindow
|
|
for "*Window" //# 41: syntax error
|
|
{}
|
|
|
|
class YConsole
|
|
for "=(typeof console == 'undefined' ? {} : console)" //# 42: syntax error
|
|
{}
|
|
|
|
class YNativeClass
|
|
for "FooBar" //# 43: syntax error
|
|
{}
|
|
|
|
class YBoolImplementation implements Fisk
|
|
for "Boolean" //# 44: syntax error
|
|
{}
|
|
|
|
class _JSONY
|
|
for 'JSON' //# 45: syntax error
|
|
{}
|
|
|
|
class YListFactory<E> implements List<E>
|
|
for "Array" //# 46: syntax error
|
|
{}
|
|
|
|
class A {
|
|
const A()
|
|
{} //# 47: syntax error
|
|
;
|
|
}
|
|
|
|
abstract class G<T> {}
|
|
|
|
typedef <T>(); //# 48: syntax error
|
|
|
|
class B
|
|
extends void //# 49: syntax error
|
|
{}
|
|
|
|
main() {
|
|
try {
|
|
new SyntaxTest();
|
|
new SyntaxTest().foo(); //# 02: continued
|
|
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
|
|
|
|
new XConsole();
|
|
new XNativeClass();
|
|
new XBoolImplementation();
|
|
new _JSONX();
|
|
new XListFactory();
|
|
new XListFactory<Object>();
|
|
|
|
new YConsole();
|
|
new YNativeClass();
|
|
new YBoolImplementation();
|
|
new _JSONY();
|
|
new YListFactory();
|
|
new YListFactory<Object>();
|
|
|
|
futureOf(x) {}
|
|
if (!(fisk futureOf(false))) {} //# 50: syntax error
|
|
if (!(await futureOf(false))) {} //# 51: compile-time error
|
|
|
|
void f{} //# 52: syntax error
|
|
G<int double> g; //# 53: syntax error
|
|
f(void) {}; //# 54: syntax error
|
|
|
|
optionalArg([x]) {}
|
|
optionalArg(
|
|
void (var i) {} //# 55: syntax error
|
|
);
|
|
|
|
function __PROTO__$(...args) { return 12; } //# 56: syntax error
|
|
G<> t; //# 57: syntax error
|
|
G<null> t; //# 58: syntax error
|
|
A<void> a = null; //# 59: compile-time error
|
|
void v; //# 60: compile-time error
|
|
void v = null; //# 61: compile-time error
|
|
print(null is void); //# 62: syntax error
|
|
new A();
|
|
new B();
|
|
|
|
new Bad();
|
|
|
|
1 + 2 = 1; //# 63: syntax error
|
|
new SyntaxTest() = 1; //# 64: syntax error
|
|
futureOf(null) = 1; //# 65: syntax error
|
|
|
|
} catch (ex) {
|
|
// Swallowing exceptions. Any error should be a compile-time error
|
|
// which kills the current isolate.
|
|
}
|
|
}
|
|
|
|
class Bad {
|
|
factory Bad<Bad(String type) { return null; } //# 63: syntax error
|
|
}
|