diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-07-20 05:55:46 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-07-20 05:55:46 +0900 |
| commit | 7f14217abbba2f89ae5845d63c8f97b606354f45 (patch) | |
| tree | a000f7297f8aff509b74ce25ff871b334bcfc191 /crates/shirabe/tests | |
| parent | b151ceaa798a7d2e9b55ffbc4e4b10ea8f0a59a8 (diff) | |
| download | php-shirabe-7f14217abbba2f89ae5845d63c8f97b606354f45.tar.gz php-shirabe-7f14217abbba2f89ae5845d63c8f97b606354f45.tar.zst php-shirabe-7f14217abbba2f89ae5845d63c8f97b606354f45.zip | |
fix(io): widen IOInterface::select choices to PhpMixed for assoc arrays
PHP's IOInterface::select accepts an associative choices array whose keys
are the selectable values, but the port narrowed it to Vec<String>, making
key-based selection unrepresentable. Accept PhpMixed (List or Array) like
PHP's array $choices; ConsoleIO already branched on both shapes internally.
Also mirror PHP in the single-select array_search fallback for numeric-keyed
arrays. All call sites keep their previous list-based behavior.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/tests')
| -rw-r--r-- | crates/shirabe/tests/common/io_mock.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/common/io_stub.rs | 2 | ||||
| -rw-r--r-- | crates/shirabe/tests/io/console_io_test.rs | 5 | ||||
| -rw-r--r-- | crates/shirabe/tests/io/null_io_test.rs | 5 |
4 files changed, 10 insertions, 4 deletions
diff --git a/crates/shirabe/tests/common/io_mock.rs b/crates/shirabe/tests/common/io_mock.rs index 47f4b66b..a658c5bc 100644 --- a/crates/shirabe/tests/common/io_mock.rs +++ b/crates/shirabe/tests/common/io_mock.rs @@ -258,7 +258,7 @@ impl IOInterfaceImmutable for IOMock { fn select( &self, question: String, - choices: Vec<String>, + choices: PhpMixed, default: PhpMixed, attempts: PhpMixed, error_message: String, diff --git a/crates/shirabe/tests/common/io_stub.rs b/crates/shirabe/tests/common/io_stub.rs index d582447c..b897305e 100644 --- a/crates/shirabe/tests/common/io_stub.rs +++ b/crates/shirabe/tests/common/io_stub.rs @@ -246,7 +246,7 @@ impl IOInterfaceImmutable for IOStub { fn select( &self, _question: String, - _choices: Vec<String>, + _choices: PhpMixed, default: PhpMixed, _attempts: PhpMixed, _error_message: String, diff --git a/crates/shirabe/tests/io/console_io_test.rs b/crates/shirabe/tests/io/console_io_test.rs index a924f0c7..03307e51 100644 --- a/crates/shirabe/tests/io/console_io_test.rs +++ b/crates/shirabe/tests/io/console_io_test.rs @@ -236,7 +236,10 @@ fn test_select() { let (console_io, _output) = make_console_io_with_answer("item2\n"); let result = console_io.select( "Select item".to_string(), - vec!["item1".to_string(), "item2".to_string()], + PhpMixed::List(vec![ + PhpMixed::String("item1".to_string()), + PhpMixed::String("item2".to_string()), + ]), PhpMixed::String("item1".to_string()), PhpMixed::Bool(false), "Error message".to_string(), diff --git a/crates/shirabe/tests/io/null_io_test.rs b/crates/shirabe/tests/io/null_io_test.rs index 75678b90..1627e91f 100644 --- a/crates/shirabe/tests/io/null_io_test.rs +++ b/crates/shirabe/tests/io/null_io_test.rs @@ -79,7 +79,10 @@ fn test_select() { PhpMixed::String("1".to_string()), io.select( "question".to_string(), - vec!["item1".to_string(), "item2".to_string()], + PhpMixed::List(vec![ + PhpMixed::String("item1".to_string()), + PhpMixed::String("item2".to_string()), + ]), PhpMixed::String("1".to_string()), PhpMixed::Int(2), "foo".to_string(), |
