2011-10-05 06:22:36 +00:00
|
|
|
// Copyright (c) 2011, 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 test for testing regular expressions in Dart.
|
|
|
|
|
2021-04-26 17:58:57 +00:00
|
|
|
// @dart = 2.9
|
|
|
|
|
2013-04-05 19:43:16 +00:00
|
|
|
import "package:expect/expect.dart";
|
|
|
|
|
2011-10-05 06:22:36 +00:00
|
|
|
class RegExp1Test {
|
|
|
|
static testMain() {
|
2012-11-13 10:18:06 +00:00
|
|
|
RegExp exp1 = new RegExp("bar|foo");
|
2011-10-05 06:22:36 +00:00
|
|
|
Expect.equals(true, exp1.hasMatch("foo"));
|
|
|
|
Expect.equals(true, exp1.hasMatch("bar"));
|
|
|
|
Expect.equals(false, exp1.hasMatch("gim"));
|
|
|
|
Expect.equals(true, exp1.hasMatch("just foo"));
|
|
|
|
Expect.equals("bar|foo", exp1.pattern);
|
2013-01-07 11:23:16 +00:00
|
|
|
Expect.equals(false, exp1.isMultiLine);
|
|
|
|
Expect.equals(true, exp1.isCaseSensitive);
|
2011-10-05 06:22:36 +00:00
|
|
|
|
2013-01-07 11:23:16 +00:00
|
|
|
RegExp exp2 = new RegExp("o+", caseSensitive: false);
|
2011-10-05 06:22:36 +00:00
|
|
|
Expect.equals(true, exp2.hasMatch("this looks good"));
|
|
|
|
Expect.equals(true, exp2.hasMatch("fOO"));
|
|
|
|
Expect.equals(false, exp2.hasMatch("bar"));
|
|
|
|
Expect.equals("o+", exp2.pattern);
|
2013-01-07 11:23:16 +00:00
|
|
|
Expect.equals(false, exp2.isCaseSensitive);
|
|
|
|
Expect.equals(false, exp2.isMultiLine);
|
2011-10-05 06:22:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
RegExp1Test.testMain();
|
|
|
|
}
|