d7ed15658a
The new formatter supports opting a region of code out from being formatted. I'm applying this marker to all of the multitests since those tests are often very sensitive to formatting and easily broken. This way, anyone touching a multitest (including me when I reformat the tests) doesn't have to remember to not run the formatter on it. Change-Id: I3d6346d31581772dc8e1701594bf9d919f28db7d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396104 Commit-Queue: Bob Nystrom <rnystrom@google.com> Reviewed-by: Srujan Gaddam <srujzs@google.com> Reviewed-by: Nate Biggs <natebiggs@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
66 lines
1.9 KiB
Dart
66 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.
|
|
|
|
// Formatting can break multitests, so don't format them.
|
|
// dart format off
|
|
|
|
// A break label must be declared where it's used.
|
|
undeclaredBreakLabel1() {
|
|
foo: { break bar; break foo; } // //# 01: compile-time error
|
|
}
|
|
|
|
undeclaredBreakLabel2() {
|
|
foo: while (true) { break bar; break foo; } // //# 02: compile-time error
|
|
}
|
|
|
|
// An unlabeled break must be inside a loop or switch.
|
|
noBreakTarget() {
|
|
foo: if (true) { break; break foo; } // //# 03: compile-time error
|
|
}
|
|
|
|
// A continue label must be declared where it's used.
|
|
undeclaredContinueLabel() {
|
|
foo: for (;;) { continue bar; break foo; } // //# 04: compile-time error
|
|
}
|
|
|
|
// An unlabeled continue must be inside a loop.
|
|
noContinueTarget() {
|
|
foo: if (true) continue; else break foo; // //# 05: compile-time error
|
|
}
|
|
|
|
// A continue label must point to a continue-able statement.
|
|
wrongContinueLabel() {
|
|
foo: if (true) continue foo; // //# 06: compile-time error
|
|
}
|
|
|
|
// Labels are not captured by closures.
|
|
noncaptureLabel() {
|
|
foo: { // //# 07: compile-time error
|
|
(() { break foo; })(); // //# 07: continued
|
|
break foo; // //# 07: continued
|
|
} // //# 07: continued
|
|
}
|
|
|
|
// Implicit break targets are not captured by closures.
|
|
noncaptureBreak() {
|
|
while(true) (() { break; })(); // //# 08: compile-time error
|
|
}
|
|
|
|
// Implicit continue targets are not captured by closures.
|
|
noncaptureContinue() {
|
|
while(true) (() { continue; })(); // //# 09: compile-time error
|
|
}
|
|
|
|
main() {
|
|
undeclaredBreakLabel1();
|
|
undeclaredBreakLabel2();
|
|
noBreakTarget();
|
|
undeclaredContinueLabel();
|
|
noContinueTarget();
|
|
wrongContinueLabel();
|
|
noncaptureLabel();
|
|
noncaptureBreak();
|
|
noncaptureContinue();
|
|
}
|