Skip to content

Commit d845846

Browse files
committed
[GH #1161]: Add Binding#irb.
PullRequest: truffleruby/690
2 parents 95235a5 + 0c378c7 commit d845846

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
a = 10
2+
3+
binding.irb

spec/ruby/core/binding/irb_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
require_relative '../../spec_helper'
2+
3+
ruby_version_is "2.5" do
4+
describe "Binding#irb" do
5+
it "creates an IRB session with the binding in scope" do
6+
irb_fixture = fixture __FILE__, "irb.rb"
7+
8+
out = IO.popen([*ruby_exe, irb_fixture], "r+") do |pipe|
9+
pipe.puts "a ** 2"
10+
pipe.puts "exit"
11+
pipe.readlines.map(&:chomp)
12+
end
13+
14+
out[-3..-1].should == ["a ** 2", "100", "exit"]
15+
end
16+
end
17+
end

spec/tags/core/binding/irb_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
slow:Binding#irb creates an IRB session with the binding in scope

src/main/ruby/core/binding.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ def local_variables
2020
Truffle.invoke_primitive(:local_variable_names, self).dup
2121
end
2222
Truffle::Graal.always_split(method(:local_variables))
23+
24+
def irb
25+
require 'irb'
26+
irb
27+
end
2328
end

0 commit comments

Comments
 (0)