Chromium Code Reviews| Index: dart/tests/language/src/SyntaxTest.dart |
| diff --git a/dart/tests/language/src/SyntaxTest.dart b/dart/tests/language/src/SyntaxTest.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6f2208709cccdb2a354baa0c5bf5ea4cd96990a4 |
| --- /dev/null |
| +++ b/dart/tests/language/src/SyntaxTest.dart |
| @@ -0,0 +1,234 @@ |
| +// 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: compile-time error |
| + |
| + // Syntax error. |
| + foo {} /// 02: compile-time error |
| + |
| + // Syntax error. |
| + static foo {} /// 03: compile-time error |
| + |
| + // Syntax error. |
| + operator +=() {} /// 04: compile-time error |
| + |
| + // Syntax error. |
| + operator -=() {} /// 05: compile-time error |
| + |
| + // Syntax error. |
| + operator *=() {} /// 06: compile-time error |
| + |
| + // Syntax error. |
| + operator /=() {} /// 07: compile-time error |
| + |
| + // Syntax error. |
| + operator ~/=() {} /// 08: compile-time error |
| + |
| + // Syntax error. |
| + operator %=() {} /// 09: compile-time error |
| + |
| + // Syntax error. |
| + operator <<=() {} /// 10: compile-time error |
| + |
| + // Syntax error. |
| + operator >>=() {} /// 11: compile-time error |
| + |
| + // Syntax error. |
| + operator >>>=() {} /// 12: compile-time error |
| + |
| + // Syntax error. |
| + operator &=() {} /// 13: compile-time error |
| + |
| + // Syntax error. |
| + operator ^=() {} /// 14: compile-time error |
| + |
| + // Syntax error. |
| + operator |=() {} /// 15: compile-time error |
| + |
| + // Syntax error. |
| + operator ?() {} /// 16: compile-time error |
| + |
| + // Syntax error. |
| + operator ||() {} /// 17: compile-time error |
| + |
| + // Syntax error. |
| + operator &&() {} /// 18: compile-time error |
| + |
| + // Syntax error. |
| + operator !=() {} /// 19: compile-time error |
| + |
| + // Syntax error. |
| + operator ===() {} /// 20: compile-time error |
| + |
| + // Syntax error. |
| + operator !==() {} /// 21: compile-time error |
| + |
| + // Syntax error. |
| + operator is() {} /// 22: compile-time error |
| + |
| + // Syntax error. |
| + operator !() {} /// 23: compile-time error |
| + |
| + // Syntax error. |
| + operator ++() {} /// 24: compile-time error |
| + |
| + // Syntax error. |
| + operator --() {} /// 25: compile-time error |
| + |
| + // Syntax error. |
| + bool operator ===(A other) { return true; } /// 26: compile-time error |
| + |
| + int sample; |
| +} |
| + |
| +fisk {} /// 27: compile-time error |
| + |
| +class DOMWindow {} |
| + |
| +class Window extends DOMWindow |
| +native "*Window" /// 28: compile-time error |
| +{} |
| + |
| +class Console |
| +native "=(typeof console == 'undefined' ? {} : console)" /// 29: compile-time error |
| +{} |
| + |
| +class NativeClass |
| +native "FooBar" /// 30: compile-time error |
| +{} |
| + |
| +interface Fisk {} |
| + |
| +class BoolImplementation implements Fisk |
| +native "Boolean" /// 31: compile-time error |
| +{} |
| + |
| +class _JSON |
| +native 'JSON' /// 32: compile-time error |
| +{} |
| + |
| +class ListFactory<E> implements List<E> |
| +native "Array" /// 33: compile-time error |
| +{} |
| + |
| +interface I extends UNKNOWN; /// 34: compile-time error |
| + |
| +class XWindow extends DOMWindow |
| +hest "*Window" /// 35: compile-time error |
| +{} |
| + |
| +class XConsole |
| +hest "=(typeof console == 'undefined' ? {} : console)" /// 36: compile-time error |
| +{} |
| + |
| +class XNativeClass |
| +hest "FooBar" /// 37: compile-time error |
| +{} |
| + |
| +class XBoolImplementation implements Fisk |
| +hest "Boolean" /// 38: compile-time error |
| +{} |
| + |
| +class _JSONX |
| +hest 'JSON' /// 39: compile-time error |
| +{} |
| + |
| +class XListFactory<E> implements List<E> |
| +hest "Array" /// 40: compile-time error |
| +{} |
| + |
| +class YWindow extends DOMWindow |
| +for "*Window" /// 41: compile-time error |
| +{} |
| + |
| +class YConsole |
| +for "=(typeof console == 'undefined' ? {} : console)" /// 42: compile-time error |
| +{} |
| + |
| +class YNativeClass |
| +for "FooBar" /// 43: compile-time error |
| +{} |
| + |
| +class YBoolImplementation implements Fisk |
| +for "Boolean" /// 44: compile-time error |
| +{} |
| + |
| +class _JSONY |
| +for 'JSON' /// 45: compile-time error |
| +{} |
| + |
| +class YListFactory<E> implements List<E> |
| +for "Array" /// 46: compile-time error |
| +{} |
| + |
| +class A { |
| + const A() |
| + {} /// 47: compile-time error |
| + ; |
| +} |
| + |
| +interface G<T> {} |
| + |
| +main() { |
| + try { |
| + new SyntaxTest(); |
| + 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))) {} /// 48: compile-time error |
| + if (!(await futureOf(false))) {} /// 49: compile-time error |
| + |
| + void f{} /// 50: compile-time error |
| + G<int double> g; /// 51: compile-time error |
| + f(void) {}; /// 52: compile-time error |
| + |
| + optionalArg([x]) {} |
| + optionalArg( |
| + void (var i) {} /// 53: compile-time error |
| + ); |
| + |
| + function __PROTO__$(...args) { return 12; } /// 54: compile-time error |
| + void v; /// 55: compile-time error |
| + G<> t; /// 56: compile-time error |
| + G<null> t; /// 57: compile-time error |
| + A<void> a = null; /// 58: compile-time error |
| + void v; /// 59: compile-time error |
| + void v = null; /// 60: compile-time error |
| + assert(null is void); /// 61: compile-time error |
|
ngeoffray
2012/01/10 08:07:09
assert -> print? Just to make sure no one skips th
ahe
2012/01/10 08:32:33
Done.
|
| + |
| + |
| + } catch (var ex) { |
| + // Swallowing exceptions. Any error should be a compile-time error |
| + // which kills the current isolate. |
| + } |
| +} |
| + |
| +typedef <T>(); /// 62: compile-time error |
|
ahe
2012/01/10 08:05:56
I should move this up before the main method and r
ahe
2012/01/10 08:32:33
Done.
|
| +class B extends void {} /// 63: compile-time error |
|
ahe
2012/01/10 08:05:56
I should also move this. This should be:
class B
ahe
2012/01/10 08:32:33
Done.
|