summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/irb/command/chws.rb5
-rw-r--r--lib/irb/command/subirb.rb5
-rw-r--r--lib/irb/context.rb7
-rw-r--r--test/irb/test_command.rb14
4 files changed, 17 insertions, 14 deletions
diff --git a/lib/irb/command/chws.rb b/lib/irb/command/chws.rb
index e0a406885f..ef456d0961 100644
--- a/lib/irb/command/chws.rb
+++ b/lib/irb/command/chws.rb
@@ -15,7 +15,7 @@ module IRB
description "Show the current workspace."
def execute(_arg)
- irb_context.main
+ puts "Current workspace: #{irb_context.main}"
end
end
@@ -30,7 +30,8 @@ module IRB
obj = eval(arg, irb_context.workspace.binding)
irb_context.change_workspace(obj)
end
- irb_context.main
+
+ puts "Current workspace: #{irb_context.main}"
end
end
end
diff --git a/lib/irb/command/subirb.rb b/lib/irb/command/subirb.rb
index 138d61c930..85af28c1a5 100644
--- a/lib/irb/command/subirb.rb
+++ b/lib/irb/command/subirb.rb
@@ -49,6 +49,7 @@ module IRB
extend_irb_context
IRB.irb(nil, *obj)
+ puts IRB.JobManager.inspect
end
end
@@ -65,7 +66,7 @@ module IRB
end
extend_irb_context
- IRB.JobManager
+ puts IRB.JobManager.inspect
end
end
@@ -90,6 +91,7 @@ module IRB
raise CommandArgumentError.new("Please specify the id of target IRB job (listed in the `jobs` command).") unless key
IRB.JobManager.switch(key)
+ puts IRB.JobManager.inspect
end
end
@@ -112,6 +114,7 @@ module IRB
extend_irb_context
IRB.JobManager.kill(*keys)
+ puts IRB.JobManager.inspect
end
end
end
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index 836b8d2625..22e855f1ef 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -587,18 +587,19 @@ module IRB
def evaluate(statement, line_no) # :nodoc:
@line_no = line_no
- result = nil
case statement
when Statement::EmptyInput
return
when Statement::Expression
result = evaluate_expression(statement.code, line_no)
+ set_last_value(result)
when Statement::Command
- result = statement.command_class.execute(self, statement.arg)
+ statement.command_class.execute(self, statement.arg)
+ set_last_value(nil)
end
- set_last_value(result)
+ nil
end
def evaluate_expression(code, line_no) # :nodoc:
diff --git a/test/irb/test_command.rb b/test/irb/test_command.rb
index 76789216c2..8cb8928adb 100644
--- a/test/irb/test_command.rb
+++ b/test/irb/test_command.rb
@@ -485,12 +485,11 @@ module TestIRB
class CwwsTest < WorkspaceCommandTestCase
def test_cwws_returns_the_current_workspace_object
out, err = execute_lines(
- "cwws",
- "self.class"
+ "cwws"
)
assert_empty err
- assert_include(out, self.class.name)
+ assert_include(out, "Current workspace: #{self}")
end
end
@@ -556,7 +555,7 @@ module TestIRB
"pushws Foo.new\n",
"popws\n",
"cwws\n",
- "_.class",
+ "self.class",
)
assert_empty err
assert_include(out, "=> #{self.class}")
@@ -576,20 +575,19 @@ module TestIRB
out, err = execute_lines(
"chws #{self.class}::Foo.new\n",
"cwws\n",
- "_.class",
+ "self.class\n"
)
assert_empty err
+ assert_include(out, "Current workspace: #<#{self.class.name}::Foo")
assert_include(out, "=> #{self.class}::Foo")
end
def test_chws_does_nothing_when_receiving_no_argument
out, err = execute_lines(
"chws\n",
- "cwws\n",
- "_.class",
)
assert_empty err
- assert_include(out, "=> #{self.class}")
+ assert_include(out, "Current workspace: #{self}")
end
end