From a4fbd8314f06c9af1588b14c2b526b6351cbd970 Mon Sep 17 00:00:00 2001 From: USAMI Kenta Date: Sun, 27 Sep 2026 07:47:03 +0900 Subject: [PATCH] Add missing definitions for text processing standard libraries (pp, shellwords, strscan) Add missing methods, classes, and constants for `pp`, `shellwords`, and `strscan`. Note: `abbrev`, `base64`, and `nkf` have been excluded as they are in `ALUMNI_STDLIBS` and planned to be removed from the rbs repo. | Ruby Method | Change | C function | |---|---|---| | `PP#pp_hash_pair` | Add method `pp_hash_pair` returning `void` | https://github.com/ruby/pp/blob/master/lib/pp.rb | | `PP::VERSION` | Add constant `VERSION` | https://github.com/ruby/pp/blob/master/lib/pp.rb | | `Shellwords::VERSION` | Add constant `VERSION` | https://github.com/ruby/shellwords/blob/master/lib/shellwords.rb | | `StringScanner::Error` | Add exception class inheriting `StandardError` | https://github.com/ruby/strscan/blob/master/ext/strscan/strscan.c | --- stdlib/pp/0/pp.rbs | 13 +++++++++++++ stdlib/shellwords/0/shellwords.rbs | 4 ++++ stdlib/strscan/0/string_scanner.rbs | 6 ++++++ test/stdlib/PP_test.rb | 9 +++++++++ test/stdlib/Shellwords_test.rb | 4 ++++ test/stdlib/StringScanner_test.rb | 4 ++++ 6 files changed, 40 insertions(+) diff --git a/stdlib/pp/0/pp.rbs b/stdlib/pp/0/pp.rbs index 1ff8090d9f..c543439a5c 100644 --- a/stdlib/pp/0/pp.rbs +++ b/stdlib/pp/0/pp.rbs @@ -53,6 +53,11 @@ # Tanaka Akira # class PP < PrettyPrint + # + # The version string + # + VERSION: String + interface _PrettyPrint def pretty_print: (untyped q) -> untyped @@ -124,6 +129,14 @@ class PP < PrettyPrint # def pp: (_PrettyPrint obj) -> untyped + # + # A pretty print for a pair of Hash + # + def pp_hash_pair: (untyped k, untyped v) -> void + # + # The version number string. + # + VERSION: String # +# The error class for StringScanner. See StringScanner#unscan. +# +class StringScanner::Error < StandardError +end diff --git a/test/stdlib/PP_test.rb b/test/stdlib/PP_test.rb index 3068883396..b5f1562f6d 100644 --- a/test/stdlib/PP_test.rb +++ b/test/stdlib/PP_test.rb @@ -7,6 +7,10 @@ class PPSingletonTest < Test::Unit::TestCase library "pp" testing "singleton(::PP)" + def test_version + assert_const_type "String", "PP::VERSION" + end + def test_pp assert_send_type "(::PP::_PrettyPrint obj, ?::PP::_LeftShift out, ?::Integer width) -> untyped", PP, :pp, Object.new, ''.dup @@ -105,6 +109,11 @@ def test_pp_hash assert_send_type "(untyped obj) -> untyped", PP.new, :pp_hash, {} end + + def test_pp_hash_pair + assert_send_type "(untyped k, untyped v) -> void", + PP.new, :pp_hash_pair, :a, 1 + end end class PP::ObjectMixinTest < Test::Unit::TestCase diff --git a/test/stdlib/Shellwords_test.rb b/test/stdlib/Shellwords_test.rb index df593caaad..66ee9421cc 100644 --- a/test/stdlib/Shellwords_test.rb +++ b/test/stdlib/Shellwords_test.rb @@ -7,6 +7,10 @@ class ShellwordsSingletonTest < Test::Unit::TestCase library "shellwords" testing "singleton(::Shellwords)" + def test_version + assert_const_type "String", "Shellwords::VERSION" + end + def test_shellescape assert_send_type "(::String str) -> ::String", Shellwords, :shellescape, "shell" diff --git a/test/stdlib/StringScanner_test.rb b/test/stdlib/StringScanner_test.rb index 1a8b7cdce5..a5102980e3 100644 --- a/test/stdlib/StringScanner_test.rb +++ b/test/stdlib/StringScanner_test.rb @@ -18,6 +18,10 @@ def test_must_C_version assert_send_type "() -> singleton(::StringScanner)", StringScanner, :must_C_version end + + def test_error + assert_const_type "Class", "StringScanner::Error" + end end class StringScannerTest < Test::Unit::TestCase