From f953dd2c34e71de6309035eb6c98539f0d944436 Mon Sep 17 00:00:00 2001 From: SamW Date: Fri, 12 Jul 2024 19:36:15 -0700 Subject: [PATCH] Update Symbol --- core/symbol.rbs | 62 ++--- test/stdlib/Symbol_test.rb | 450 +++++++++++++++++-------------------- 2 files changed, 248 insertions(+), 264 deletions(-) diff --git a/core/symbol.rbs b/core/symbol.rbs index da9d75801..fafd9c578 100644 --- a/core/symbol.rbs +++ b/core/symbol.rbs @@ -131,9 +131,7 @@ class Symbol # Symbol.all_symbols.size # => 9334 # Symbol.all_symbols.take(3) # => [:!, :"\"", :"#"] # - def self.all_symbols: () -> ::Array[Symbol] - - public + def self.all_symbols: () -> Array[Symbol] # # Returns `true` if `object` is the same object as `self`, `false` otherwise. # - def ==: (untyped obj) -> bool + def ==: (untyped object) -> bool # # Returns `true` if `object` is the same object as `self`, `false` otherwise. # - def ===: (untyped obj) -> bool + alias === == # # Equivalent to `symbol.to_s[]`; see String#[]. # - def []: (int index) -> String? - | (int start, int length) -> String? - | (Range[Integer?] range) -> String? - | (Regexp regexp) -> String? - | (Regexp regexp, int | String capture) -> String? - | (String match_str) -> String? + def []: (int start, ?int length) -> String? + | (range[int?] range) -> String? + | (Regexp regexp, ?MatchData::capture backref) -> String? + | (String substring) -> String? # # - def intern: () -> Symbol + alias intern to_sym # # Equivalent to `sym.to_s.match?`; see String#match. # - def match?: (Regexp | string pattern, ?int pos) -> bool + def match?: (Regexp | string pattern, ?int offset) -> bool # # Equivalent to `self.to_s.succ.to_sym`: @@ -378,6 +376,20 @@ class Symbol # def next: () -> Symbol + # + # Returns a frozen string representation of `self` (not including the leading + # colon): + # + # :foo.name # => "foo" + # :foo.name.frozen? # => true + # + # Related: Symbol#to_s, Symbol#inspect. + # + def name: () -> String + # # Equivalent to `self.to_s.length`; see String#length. # @@ -394,7 +406,7 @@ class Symbol # --> # Equivalent to `self.to_s.start_with?`; see String#start_with?. # - def start_with?: (*string | Regexp prefixes) -> bool + def start_with?: (*Regexp | string prefixes) -> bool #