3af367cfd9
When we moved to make errors non-nullable in the async API, I added legacy tests, but not NNBD tests because it is a static error in NNBD. However, we've since started testing that null is caught dynamically when flowing into those APIs from legacy code. So this migrates those tests over. Change-Id: I8002bacb45e947ef8c93dca10c7c1fd41afaa696 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152614 Auto-Submit: Bob Nystrom <rnystrom@google.com> Commit-Queue: Bob Nystrom <rnystrom@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
50 lines
1.2 KiB
Dart
50 lines
1.2 KiB
Dart
// Copyright (c) 2020, 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 'dart:async';
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
main() {
|
|
// Single-cast async.
|
|
var controller = StreamController();
|
|
Expect.throwsNullCheckError(() {
|
|
controller.addError(null as dynamic);
|
|
});
|
|
|
|
Expect.throwsNullCheckError(() {
|
|
controller.sink.addError(null as dynamic);
|
|
});
|
|
|
|
// Single-cast sync.
|
|
controller = StreamController(sync: true);
|
|
Expect.throwsNullCheckError(() {
|
|
controller.addError(null as dynamic);
|
|
});
|
|
|
|
Expect.throwsNullCheckError(() {
|
|
controller.sink.addError(null as dynamic);
|
|
});
|
|
|
|
// Broadcast async.
|
|
controller = StreamController.broadcast();
|
|
Expect.throwsNullCheckError(() {
|
|
controller.addError(null as dynamic);
|
|
});
|
|
|
|
Expect.throwsNullCheckError(() {
|
|
controller.sink.addError(null as dynamic);
|
|
});
|
|
|
|
// Broadcast sync.
|
|
controller = StreamController.broadcast(sync: true);
|
|
Expect.throwsNullCheckError(() {
|
|
controller.addError(null as dynamic);
|
|
});
|
|
|
|
Expect.throwsNullCheckError(() {
|
|
controller.sink.addError(null as dynamic);
|
|
});
|
|
}
|