From 8117e5450693d19726da877bce8aacf5c7aa53af Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 25 Jun 2026 15:12:06 +0900 Subject: test: port 44 vcs/downloader/version tests using mock infra Port git, version_guesser, gitlab_driver, github_driver, and git_downloader tests using the ProcessExecutor/HttpDownloader mocks and IO/Config stubs. Fix production regex-porting bugs surfaced by the now-reachable paths: Url::sanitize and Response::find_header_value had non-delimited PCRE patterns; implement array_search_mixed non-strict branch and a datetime format mapping. Add HttpDownloader::__new_mock so mocked downloaders skip curl construction. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe-php-shim/src/array.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/shirabe-php-shim/src/array.rs') diff --git a/crates/shirabe-php-shim/src/array.rs b/crates/shirabe-php-shim/src/array.rs index 280ec64..ace6a72 100644 --- a/crates/shirabe-php-shim/src/array.rs +++ b/crates/shirabe-php-shim/src/array.rs @@ -233,20 +233,21 @@ pub fn array_search_mixed( haystack: &PhpMixed, strict: bool, ) -> Option { - if !strict { - // TODO(phase-c): non-strict array_search needs PHP's loose `==` comparison - // semantics. Only the strict path is implemented; loose comparison is - // deferred rather than approximated. - todo!("non-strict array_search (PHP loose comparison)"); - } + let matches = |value: &PhpMixed| -> bool { + if strict { + value == needle + } else { + loose_eq(value, needle) + } + }; match haystack { PhpMixed::List(items) => items .iter() - .position(|value| value == needle) + .position(matches) .map(|i| PhpMixed::Int(i as i64)), PhpMixed::Array(map) => map .iter() - .find(|(_, value)| *value == needle) + .find(|(_, value)| matches(value)) .map(|(key, _)| php_key_to_mixed(key)), _ => None, } -- cgit v1.3.1