blob: d3ce82450e4fef4bc36daff0fae20ec5fc52961a [file] [log] [blame]
// Copyright (c) 2017, 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.
/// @assertion Match matchAsPrefix(String string, [int start = 0])
/// Match this pattern against the start of string.
/// ...
/// Returns null if the pattern doesn't match.
/// @description Checks that null is returned when appropriate. Test not null
/// start argument
/// @author
import "../../../Utils/expect.dart";
main() {
check(r"\d+", "adasfjkasfjkhasfj", 2);
check(r"^m", "mpairs\nmakes\tdouble", 1);
check(r"s$", "spairs\nmakes\tdouble", 1);
check(r"^p[b-z]", "1pairs\nmakes\tdouble\npesos", 1);
check(r"^..^e", "eeab\ncde", 2);
check(r"\bot", "botpilot\nsoviet robot\topenoffice", 3);
check("bot", "abcbotttt", 2);
check("bot", "abcbotttt", 4);
void check(String pattern, String str, int start) {
Expect.equals(null, pattern.matchAsPrefix(str, start));