summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/irb/extend-command.rb4
-rw-r--r--test/irb/test_cmd.rb4
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 55e7b3e0e6..02b7869569 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -177,8 +177,8 @@ module IRB # :nodoc:
args << "&block"
args = args.join(", ")
line = __LINE__; eval %[
- unless self.class.class_variable_defined?(:@@#{cmd_name}_)
- self.class.class_variable_set(:@@#{cmd_name}_, true)
+ unless self.singleton_class.class_variable_defined?(:@@#{cmd_name}_)
+ self.singleton_class.class_variable_set(:@@#{cmd_name}_, true)
def #{cmd_name}_(\#{args})
ExtendCommand::#{cmd_class}.execute(irb_context, \#{args})
end
diff --git a/test/irb/test_cmd.rb b/test/irb/test_cmd.rb
index 699c9cd655..55549d0d10 100644
--- a/test/irb/test_cmd.rb
+++ b/test/irb/test_cmd.rb
@@ -170,13 +170,15 @@ module TestIRB
"measure :off\n",
"3\n",
])
- irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
+ c = Class.new(Object)
+ irb = IRB::Irb.new(IRB::WorkSpace.new(c.new), input)
irb.context.return_format = "=> %s\n"
out, err = capture_output do
irb.eval_input
end
assert_empty err
assert_match(/\A=> 3\nTIME is added\.\n=> nil\nprocessing time: .+\n=> 3\n=> nil\n=> 3\n/, out)
+ assert_empty(c.class_variables)
end
def test_measure_enabled_by_rc