Files
sdk/tests/language/nnbd/boolean_conversion/boolean_conversion_strong_test.dart
T
Leaf Petersen e8ff0c884e Add tests for null safety boolean conversion.
Tests for the null safety spec clarification landed in
https://github.com/dart-lang/language/pull/917 .

Change-Id: Ieafe5315c31919c01ff816a26d29fa0d1cbc8c9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142782
Reviewed-by: Erik Ernst <eernst@google.com>
2020-04-10 00:46:06 +00:00

29 lines
1.0 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.
// Requirements=nnbd-strong
// Test implicit casts and null conversions for boolean expressions
// in strong mode.
import 'package:expect/expect.dart';
import 'boolean_conversion_lib1.dart';
void main() {
check(booleanAsBoolean, true, expectOk);
check(booleanAsBoolean, false, expectOk);
check(dynamicAsBoolean, null, Expect.throwsTypeError);
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);
}