-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1541 from sampersand/swesterman/23-09-22/make-tes…
…t-types-basicobject Remove all non-required methods from testing types
- Loading branch information
Showing
10 changed files
with
117 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module RBS | ||
module Test | ||
module Guaranteed | ||
module Inspect | ||
EQUAL = ::BasicObject.instance_method(:equal?) | ||
INSPECT = ::Kernel.instance_method(:inspect) | ||
private_constant :EQUAL, :INSPECT | ||
|
||
module_function def guaranteed_inspect(obj) | ||
obj.inspect | ||
rescue NoMethodError => err | ||
raise unless err.name == :inspect && EQUAL.bind_call(obj, err.receiver) | ||
INSPECT.bind_call(obj) | ||
end | ||
|
||
def inspect | ||
string = "<#{self.class.name}:" | ||
|
||
instance_variables.each_with_index do |variable, index| | ||
string.concat ', ' unless index.zero? | ||
string.concat "#{variable}: #{guaranteed_inspect(variable)}" | ||
end | ||
|
||
string.concat '>' | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.