Files
sdk/tests/corelib/bool_parse_test.dart
T
Lasse R.H. Nielsen c974c70f31 Add boolean parse
Closes https://github.com/dart-lang/sdk/pull/51026

Co-authored-by: Renato Burton <renatoburton96@gmail.com>
GitOrigin-RevId: e85a56ce338476b38eac890fac2b8ca193ca42e8
Change-Id: I60f92c594830ef0438ecd92b4c83cec609054326
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279746
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-03-09 15:14:32 +00:00

24 lines
1013 B
Dart

// Copyright (c) 2023, 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.
// SharedOptions=-Da=true -Db=false -Dc=NOTBOOL -Dd=True
import "package:expect/expect.dart";
main() {
Expect.isTrue(bool.parse('true'));
Expect.isFalse(bool.parse('false'));
Expect.isTrue(bool.parse('TRUE', caseSensitive: false));
Expect.isFalse(bool.parse('FALSE', caseSensitive: false));
Expect.isTrue(bool.parse('true', caseSensitive: true));
Expect.isFalse(bool.parse('false', caseSensitive: true));
Expect.throws(() => bool.parse('True'));
Expect.throws(() => bool.parse('False'));
Expect.throws(() => bool.parse('y'));
Expect.throws(() => bool.parse('n'));
Expect.throws(() => bool.parse('0'));
Expect.throws(() => bool.parse('1'));
Expect.throws(() => bool.parse('TRUE', caseSensitive: true));
Expect.throws(() => bool.parse('FALSE', caseSensitive: true));
}