5bb9e922db
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. Unfortunately, this doesn't opt out 100# of the multitests. There are a handful of multitests that also contain "@dart=" comments and are thus formatted using the old style where the "// dart format off" marker has no effect. For those, we'll have to still be careful to not accidentally format them. Change-Id: I257d0ee1eb44eee57047be06b8520f0ccc7b56d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/396162 Auto-Submit: Bob Nystrom <rnystrom@google.com> Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Erik Ernst <eernst@google.com>
39 lines
1.1 KiB
Dart
39 lines
1.1 KiB
Dart
// Copyright (c) 2018, 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
|
|
|
|
// Test that various invalid uses of `yield` are disallowed.
|
|
|
|
import "dart:async";
|
|
import "package:expect/async_helper.dart";
|
|
import "package:expect/expect.dart";
|
|
|
|
var yield = 42;
|
|
|
|
main() async {
|
|
asyncStart();
|
|
Stream<String> f() async* {
|
|
// Invalid syntax.
|
|
yield ("a", "b"); //# 01: compile-time error
|
|
yield yield "twice"; //# 02: syntax error
|
|
|
|
// Valid but curious syntax.
|
|
yield throw "throw"; //# 03: runtime error
|
|
|
|
// Type error.
|
|
yield* "one"; //# 04: compile-time error
|
|
|
|
label: yield "ok";
|
|
}
|
|
var completer = Completer();
|
|
f().listen(completer.complete, onError: completer.completeError,
|
|
onDone: () {
|
|
if (!completer.isCompleted) completer.completeError("not ok?");
|
|
});
|
|
Expect.equals("ok", await completer.future);
|
|
asyncEnd();
|
|
}
|