Skip to content

Commit bc73388

Browse files
bjfisheregon
authored andcommitted
Update Kernel#print to print $_ when no arguments are given
1 parent 0698777 commit bc73388

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

core/kernel/print_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
it "is a private method" do
66
Kernel.should have_private_instance_method(:print)
77
end
8+
9+
it "delegates to $stdout" do
10+
-> { print :arg }.should output("arg")
11+
end
12+
13+
it "prints $_ when no arguments are given" do
14+
orig_value = $_
15+
$_ = 'foo'
16+
-> { print }.should output("foo")
17+
ensure
18+
$_ = orig_value
19+
end
820
end
921

1022
describe "Kernel.print" do

0 commit comments

Comments
 (0)