mirror of
https://github.com/dart-lang/sdk
synced 2024-10-03 13:31:47 +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>
78 lines
1.9 KiB
Dart
78 lines
1.9 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.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
main() {
|
|
final f0 = 42;
|
|
final f1; //# 01: compile-time error
|
|
final int f2 = 87;
|
|
final int f3; //# 02: compile-time error
|
|
Expect.equals(42, f0);
|
|
Expect.equals(87, f2);
|
|
|
|
Expect.equals(42, F0);
|
|
Expect.equals(null, F1); //# 03: continued
|
|
Expect.equals(87, F2);
|
|
Expect.equals(null, F3); //# 04: continued
|
|
|
|
Expect.isTrue(P0 is Point);
|
|
Expect.isTrue(P1 is int);
|
|
Expect.isTrue(P2 is Point);
|
|
Expect.isTrue(P3 is int);
|
|
|
|
Expect.isTrue(A0 is int);
|
|
Expect.isTrue(A1 is int);
|
|
Expect.isTrue(A2 is int); //# 08: runtime error
|
|
Expect.isTrue(A3 is int); //# 08: continued
|
|
|
|
Expect.isTrue(C0.X is C1);
|
|
Expect.isTrue(C0.X.x is C1); //# 09: compile-time error
|
|
|
|
Expect.equals("Hello 42", B2);
|
|
Expect.equals("42Hello", B3); //# 10: runtime error
|
|
}
|
|
|
|
final F0 = 42;
|
|
final F1; // //# 03: syntax error
|
|
final int F2 = 87;
|
|
final int F3; // //# 04: syntax error
|
|
|
|
class Point {
|
|
final x, y;
|
|
const Point(this.x, this.y);
|
|
operator +(int other) => x;
|
|
}
|
|
|
|
// Check that compile time expressions can include invocations of
|
|
// user-defined final constructors.
|
|
final P0 = const Point(0, 0);
|
|
final P1 = const Point(0, 0) + 1;
|
|
final P2 = new Point(0, 0);
|
|
final P3 = new Point(0, 0) + 1;
|
|
|
|
// Check that we cannot have cyclic references in compile time
|
|
// expressions.
|
|
final A0 = 42;
|
|
final A1 = A0 + 1;
|
|
final A2 = A3 + 1; //# 08: continued
|
|
final A3 = A2 + 1; //# 08: continued
|
|
|
|
class C0 {
|
|
static final X = const C1();
|
|
}
|
|
|
|
class C1 {
|
|
const C1()
|
|
: x = C0.X //# 09: continued
|
|
;
|
|
final x = null;
|
|
}
|
|
|
|
// Check that sub-expressions of binary + are numeric.
|
|
final B0 = 42;
|
|
final B1 = "Hello";
|
|
final B2 = "$B1 $B0";
|
|
final B3 = B0 + B1; //# 10: continued
|