Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: af5b2edfa2d1
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 15bb1495ccdb
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Sep 26, 2014

  1. Fixed C-API specs for rb_std{in,out,err,defout}

    * the rb_std{stream} methods return their respective global variables,
      not their constants.
    * $defout was deprecated in MRI 1.8 and removed in 1.9+, but rb_defout
      persists past 1.9.
    sshao committed Sep 26, 2014
    Copy the full SHA
    25c353e View commit details
  2. Copy the full SHA
    15bb149 View commit details
Showing with 51 additions and 22 deletions.
  1. +0 −3 spec/ruby/optional/capi/ext/rubyspec.h
  2. +47 −15 spec/ruby/optional/capi/globals_spec.rb
  3. +4 −4 vm/include/capi/ruby.h
3 changes: 0 additions & 3 deletions spec/ruby/optional/capi/ext/rubyspec.h
Original file line number Diff line number Diff line change
@@ -294,10 +294,7 @@
#define HAVE_RB_STDERR 1
#define HAVE_RB_STDIN 1
#define HAVE_RB_STDOUT 1

#ifdef RUBY_VERSION_IS_1_8_EX_1_9
#define HAVE_RB_DEFOUT 1
#endif

#define HAVE_RB_LASTLINE_SET 1
#define HAVE_RB_LASTLINE_GET 1
62 changes: 47 additions & 15 deletions spec/ruby/optional/capi/globals_spec.rb
Original file line number Diff line number Diff line change
@@ -124,27 +124,59 @@
end
end

describe "rb_stdin" do
it "returns STDIN" do
@f.rb_stdin.should equal(STDIN)
context "rb_std streams" do
before :each do
@name = tmp("rb_std_streams")
@stream = new_io @name
end
end

describe "rb_stdout" do
it "returns STDOUT" do
@f.rb_stdout.should equal(STDOUT)
after :each do
@stream.close
rm_r @name
end
end

describe "rb_stderr" do
it "returns STDERR" do
@f.rb_stderr.should equal(STDERR)
describe "rb_stdin" do
after :each do
$stdin = STDIN
end

it "returns $stdin" do
$stdin = @stream
@f.rb_stdin.should equal($stdin)
end
end
end

describe "rb_defout" do
it "returns STDOUT" do
@f.rb_defout.should equal(STDOUT)
describe "rb_stdout" do
after :each do
$stdout = STDOUT
end

it "returns $stdout" do
$stdout = @stream
@f.rb_stdout.should equal($stdout)
end
end

describe "rb_stderr" do
after :each do
$stderr = STDERR
end

it "returns $stderr" do
$stderr = @stream
@f.rb_stderr.should equal($stderr)
end
end

describe "rb_defout" do
after :each do
$stdout = STDOUT
end

it "returns $stdout" do
$stdout = @stream
@f.rb_defout.should equal($stdout)
end
end
end

8 changes: 4 additions & 4 deletions vm/include/capi/ruby.h
Original file line number Diff line number Diff line change
@@ -289,10 +289,10 @@ struct RFile {
#define rb_output_rs mri_global_rb_output_rs()
#define rb_output_fs mri_global_rb_output_fs()

#define rb_stdin rb_const_get(rb_cObject, rb_intern("STDIN"))
#define rb_stdout rb_const_get(rb_cObject, rb_intern("STDOUT"))
#define rb_stderr rb_const_get(rb_cObject, rb_intern("STDERR"))
#define rb_defout rb_const_get(rb_cObject, rb_intern("STDOUT"))
#define rb_stdin rb_gv_get("$stdin")
#define rb_stdout rb_gv_get("$stdout")
#define rb_stderr rb_gv_get("$stderr")
#define rb_defout rb_gv_get("$stdout")

/* Global Class objects */