Files
sdk/tests/language/nnbd/boolean_conversion/boolean_conversion_weak_test.dart
T
Paul Berry def50905c2 Make flow analysis handling of is/==/??=/?. consistent with mixed mode semantics
Bug: https://github.com/dart-lang/language/issues/1143
Change-Id: Id177f8b19c15ef246f21ddd840410cddfee2e5cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163600
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-09-25 08:35:03 +00:00

34 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.
// @dart=2.7
// Requirements=nnbd-weak
// Test implicit casts and null conversions for boolean expressions
// in weak mode.
import 'package:expect/expect.dart';
import 'boolean_conversion_lib1.dart';
void main() {
check(neverAsBoolean, null, Expect.throwsReachabilityError);
check(booleanAsBoolean, null, Expect.throwsAssertionError);
check(booleanAsBoolean, true, expectOk);
check(booleanAsBoolean, false, expectOk);
check(dynamicAsBoolean, null, Expect.throwsAssertionError);
check(dynamicAsBoolean, true, expectOk);
check(dynamicAsBoolean, false, expectOk);
check(dynamicAsBoolean, "", Expect.throwsTypeError);
check(dynamicAsBoolean, "true", Expect.throwsTypeError);
check(dynamicAsBoolean, "null", Expect.throwsTypeError);
check(dynamicAsBoolean, "undefined", Expect.throwsTypeError);
check(dynamicAsBoolean, 0, Expect.throwsTypeError);
check(dynamicAsBoolean, 1, Expect.throwsTypeError);
check(dynamicAsBoolean, [true], Expect.throwsTypeError);
}