diff options
author | Aaron Patterson <[email protected]> | 2023-12-05 14:07:50 -0800 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2023-12-07 14:07:09 -0800 |
commit | 9d696aa20461d94c2d32e1e474bd036ade20c94d (patch) | |
tree | 9cf6a89ad9e87a3b01c94e776990f75b26759d90 /test | |
parent | f76881c9af4256d984c0cd59bc1f6929134eded0 (diff) |
Support method calls inside `defined?`
This commit supports all kinds of method calls (including methods with
parameters) inside `defined?` calls.
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_compile_prism.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/ruby/test_compile_prism.rb b/test/ruby/test_compile_prism.rb index 50bb61c99d..3d7e16a59a 100644 --- a/test/ruby/test_compile_prism.rb +++ b/test/ruby/test_compile_prism.rb @@ -181,6 +181,33 @@ module Prism assert_prism_eval("defined?(())") assert_prism_eval("defined?(('1'))") + + # method chain starting with self that's truthy + assert_prism_eval("defined?(self.itself.itself.itself)") + + # method chain starting with self that's false (exception swallowed) + assert_prism_eval("defined?(self.itself.itself.neat)") + + # single self with method, truthy + assert_prism_eval("defined?(self.itself)") + + # single self with method, false + assert_prism_eval("defined?(self.neat!)") + + # method chain implicit self that's truthy + assert_prism_eval("defined?(itself.itself.itself)") + + # method chain implicit self that's false + assert_prism_eval("defined?(itself.neat.itself)") + + ## single method implicit self that's truthy + assert_prism_eval("defined?(itself)") + + ## single method implicit self that's false + assert_prism_eval("defined?(neatneat)") + + assert_prism_eval("defined?(a(itself))") + assert_prism_eval("defined?(itself(itself))") end def test_GlobalVariableReadNode |