Skip to content

Commit

Permalink
test/ruby/test_ast.rb: Avoid a "method redefined" warning
Browse files Browse the repository at this point in the history
  • Loading branch information
mame committed Dec 20, 2021
1 parent 26c9ef6 commit 1c72c95
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/ruby/test_ast.rb
Expand Up @@ -258,25 +258,25 @@ def test_of_proc_and_method_under_eval_with_keep_script_lines
keep_script_lines_back = RubyVM.keep_script_lines
RubyVM.keep_script_lines = true

method = self.method(eval("def example_method_#{$$}; end"))
method = self.method(eval("def example_method_#{$$}_with_keep_script_lines; end"))
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

method = self.method(eval("def self.example_singleton_method_#{$$}; end"))
method = self.method(eval("def self.example_singleton_method_#{$$}_with_keep_script_lines; end"))
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

method = eval("proc{}")
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

method = self.method(eval("singleton_class.define_method(:example_define_method_#{$$}){}"))
method = self.method(eval("singleton_class.define_method(:example_define_method_#{$$}_with_keep_script_lines){}"))
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

method = self.method(eval("define_singleton_method(:example_dsm_#{$$}){}"))
method = self.method(eval("define_singleton_method(:example_dsm_#{$$}_with_keep_script_lines){}"))
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

method = eval("Class.new{def example_method; end}.instance_method(:example_method)")
method = eval("Class.new{def example_method_with_keep_script_lines; end}.instance_method(:example_method_with_keep_script_lines)")
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

method = eval("Class.new{def example_method; end}.instance_method(:example_method)")
method = eval("Class.new{def example_method_with_keep_script_lines; end}.instance_method(:example_method_with_keep_script_lines)")
assert_instance_of(RubyVM::AbstractSyntaxTree::Node, RubyVM::AbstractSyntaxTree.of(method))

ensure
Expand Down

0 comments on commit 1c72c95

Please sign in to comment.