diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-14 12:49:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-14 12:49:30 +0000 |
commit | d6dc676d07427e4c1459e9c7509329bb54cbdc7c (patch) | |
tree | 02b1ff7ce92874923cd7bf07097483b78e2e701b /test/irb | |
parent | 698407450b6a43e7295f19691fd0cf42d553b211 (diff) | |
download | ruby-d6dc676d07427e4c1459e9c7509329bb54cbdc7c.tar.gz |
irb/{context,workspace}.rb: use local_variable_set
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/irb')
-rw-r--r-- | test/irb/test_context.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/irb/test_context.rb b/test/irb/test_context.rb new file mode 100644 index 0000000000..35141a41a4 --- /dev/null +++ b/test/irb/test_context.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: false +require 'test/unit' +require 'tempfile' +require 'irb' +require 'rubygems' if defined?(Gem) + +module TestIRB + class TestContext < Test::Unit::TestCase + class TestInputMethod < ::IRB::InputMethod + attr_reader :line, :line_no + + def initialize(list = []) + super("test") + @line_no = 0 + @line = list + end + + def gets + @list[@line_no.tap {@line_no += 1}] + end + + def eof? + @line_no >= @list.size + end + end + + def setup + IRB.init_config(nil) + IRB.conf[:USE_READLINE] = false + IRB.conf[:VERBOSE] = false + workspace = IRB::WorkSpace.new(Object.new) + @context = IRB::Context.new(nil, workspace, TestInputMethod.new) + end + + def test_last_value + assert_nil(@context.last_value) + assert_nil(@context.evaluate('_', 1)) + obj = Object.new + @context.set_last_value(obj) + assert_same(obj, @context.last_value) + assert_same(obj, @context.evaluate('_', 1)) + end + end +end |