blob: 0b7f4639e73ee4f102b380bf6e2954c414f9107a [file] [log] [blame]
/*
* 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.
*/
/**
* @assertion Returns the index in the string where the match starts.
* @description Checks that method returns correct value.
* @author rodionov
*/
import "../../../Utils/expect.dart";
void check(String str, String pattern, int start) {
RegExp re = new RegExp(pattern, multiLine: false, caseSensitive: true);
Match? m = re.firstMatch(str);
Expect.equals(start, m?.start);
}
main(){
check("", "", 0);
check("", ".*", 0);
check("a", "a", 0);
check("abcdef", "[a-z]", 0);
check("abcdef", "[a-z]+", 0);
check("abcdef", "[b-z]+", 1);
check("abcdef", "[a-e]+", 0);
}