dart-sdk/tests/corelib/regexp/default_arguments_test.dart
Robert Nystrom 4eda30c5c2 Migrate corelib_2/regexp files to NNBD.
Change-Id: I5bacd28d806661b9190d4b097955263a56f19a4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128110
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2019-12-18 16:16:51 +00:00

32 lines
1.1 KiB
Dart

// Copyright (c) 2015, 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.
// Test that `null` is interpreted as `false` when passed as argument to
// `caseSensitive` and `multiLine`.
import 'package:expect/expect.dart';
main() {
testCaseSensitive();
testMultiLine();
}
testCaseSensitive() {
var r1 = new RegExp('foo');
var r2 = new RegExp('foo', caseSensitive: true);
var r3 = new RegExp('foo', caseSensitive: false);
Expect.isNull(r1.firstMatch('Foo'), "r1.firstMatch('Foo')");
Expect.isNull(r2.firstMatch('Foo'), "r2.firstMatch('Foo')");
Expect.isNotNull(r3.firstMatch('Foo'), "r3.firstMatch('Foo')");
}
testMultiLine() {
var r1 = new RegExp(r'^foo$');
var r2 = new RegExp(r'^foo$', multiLine: true);
var r3 = new RegExp(r'^foo$', multiLine: false);
Expect.isNull(r1.firstMatch('\nfoo\n'), "r1.firstMatch('\\nfoo\\n')");
Expect.isNotNull(r2.firstMatch('\nfoo\n'), "r2.firstMatch('\\nfoo\\n')");
Expect.isNull(r3.firstMatch('\nfoo\n'), "r3.firstMatch('\\nfoo\\n')");
}