示例#1
0
 protected function _test_match_capture()
 {
     $messages = array('Regex capture');
     $expected_exception = null;
     foreach (array(array('^(?:(\\w+)\\s?)*$', 'Bonjour le monde', true, 1, 'monde')) as $target) {
         $callback = function () use($target) {
             list($re, $subject, $expected_matching, $expected_capture_index, $expected_capture) = $target;
             $re = h\regex($re);
             $subject = h\string($subject);
             $result = $re->do_execute($subject);
             return $expected_matching === $result->is_match() && $result->has_captured(0) && $result->has_captured($expected_capture_index) && $subject == $subject->slice($result->iterate_matches()[0]->begin, $result->iterate_matches()[0]->end) && $expected_capture == $subject->slice($result->iterate_captures_by_index($expected_capture_index)[0]->begin, $result->iterate_captures_by_index($expected_capture_index)[0]->end);
         };
         $this->add_test($callback, $messages, $expected_exception);
     }
 }
示例#2
0
 public function do_create_relative_path(h\string $meat)
 {
     $impl = new relative_path();
     $re = h\regex(RE_PATH);
     if ($re->match($meat)) {
         $path = $re->get_result(0);
     }
     return $impl;
 }