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: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 90591e81b422
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 99aec54b7a27
Choose a head ref
  • 4 commits
  • 9 files changed
  • 1 contributor

Commits on Apr 17, 2015

  1. Squashed 'spec/mspec/' changes from 6676cd6..2045fe1

    2045fe1 Fix typo in the tmp helper constants.
    b1ac248 Ensure to restore arguments in the argv helper with a block.
    9ce0864 Fix (non_)?compliant_on specs to not rely on the current ruby engine.
    
    git-subtree-dir: spec/mspec
    git-subtree-split: 2045fe13c45dac6f70adf42695d9bd3adfda656c
    eregon committed Apr 17, 2015
    Copy the full SHA
    0e821de View commit details
  2. Copy the full SHA
    c447b07 View commit details
  3. Squashed 'spec/ruby/' changes from a34895b7..44248dc

    44248dc Update the Travis build to use the dotted formatter.
    376c9ea Don't test initial_state argument since Ruby 2.3.
    d290624 Fix specs of Kernel#{freeze,frozen?}.
    7f5985c Merge pull request #60 from anthonycrumley/fix_oversight
    5db63f8 Removed accidentally committed code
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 44248dc79405c9c771a2f907b88c5196a383c2d7
    eregon committed Apr 17, 2015
    Copy the full SHA
    3319bc3 View commit details
  4. Copy the full SHA
    99aec54 View commit details
7 changes: 5 additions & 2 deletions spec/mspec/lib/mspec/helpers/argv.rb
Original file line number Diff line number Diff line change
@@ -35,8 +35,11 @@ def argv(args)
@__mspec_saved_argv__ = ARGV
ARGV.replace args
if block_given?
yield
argv :restore
begin
yield
ensure
argv :restore
end
end
end
end
4 changes: 2 additions & 2 deletions spec/mspec/lib/mspec/helpers/tmp.rb
Original file line number Diff line number Diff line change
@@ -7,11 +7,11 @@

SPEC_TEMP_UNIQUIFIER = "0"

SPEC_TMEM_DIR_PID = Process.pid
SPEC_TEMP_DIR_PID = Process.pid

at_exit do
begin
if SPEC_TMEM_DIR_PID == Process.pid
if SPEC_TEMP_DIR_PID == Process.pid
Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR
end
rescue SystemCallError
14 changes: 8 additions & 6 deletions spec/mspec/spec/guards/compliance_spec.rb
Original file line number Diff line number Diff line change
@@ -56,19 +56,20 @@

describe Object, "#compliant_on" do
before :each do
@guard = CompliantOnGuard.new :any
@guard = CompliantOnGuard.new :stub
@guard.stub(:match?).and_return(true)
CompliantOnGuard.stub(:new).and_return(@guard)
end

it "sets the name of the guard to :compliant_on" do
compliant_on(:rubinius) { }
compliant_on(:stubbed) { }
@guard.name.should == :compliant_on
end

it "calls #unregister even when an exception is raised in the guard block" do
@guard.should_receive(:unregister)
lambda do
compliant_on(:rubinius) { raise Exception }
compliant_on(:stubbed) { raise Exception }
end.should raise_error(Exception)
end
end
@@ -122,19 +123,20 @@

describe Object, "#not_compliant_on" do
before :each do
@guard = NotCompliantOnGuard.new :any
@guard = NotCompliantOnGuard.new :stub
@guard.stub(:match?).and_return(true)
NotCompliantOnGuard.stub(:new).and_return(@guard)
end

it "sets the name of the guard to :not_compliant_on" do
not_compliant_on(:rubinius) { }
not_compliant_on(:stubbed) { }
@guard.name.should == :not_compliant_on
end

it "calls #unregister even when an exception is raised in the guard block" do
@guard.should_receive(:unregister)
lambda do
not_compliant_on(:rubinius) { raise Exception }
not_compliant_on(:stubbed) { raise Exception }
end.should raise_error(Exception)
end
end
2 changes: 1 addition & 1 deletion spec/ruby/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: ruby
script:
- bundle exec mspec -t ruby
- bundle exec mspec -fd -t ruby
notifications:
email: false
rvm:
30 changes: 16 additions & 14 deletions spec/ruby/core/enumerable/chunk_spec.rb
Original file line number Diff line number Diff line change
@@ -51,22 +51,24 @@
lambda { e.chunk { |x| :_arbitrary }.to_a }.should raise_error(RuntimeError)
end

describe "with [initial_state]" do
it "yields an element and an object value-equal but not identical to the object passed to #chunk" do
e = EnumerableSpecs::Numerous.new(1)
value = "value"
ruby_version_is ""..."2.3" do
describe "with [initial_state]" do
it "yields an element and an object value-equal but not identical to the object passed to #chunk" do
e = EnumerableSpecs::Numerous.new(1)
value = "value"

e.chunk(value) do |x, v|
x.should == 1
v.should == value
v.should_not equal(value)
end.to_a
end
e.chunk(value) do |x, v|
x.should == 1
v.should == value
v.should_not equal(value)
end.to_a
end

it "does not yield the object passed to #chunk if it is nil" do
e = EnumerableSpecs::Numerous.new(1)
e.chunk(nil) { |*x| ScratchPad << x }.to_a
ScratchPad.recorded.should == [[1]]
it "does not yield the object passed to #chunk if it is nil" do
e = EnumerableSpecs::Numerous.new(1)
e.chunk(nil) { |*x| ScratchPad << x }.to_a
ScratchPad.recorded.should == [[1]]
end
end
end
end
48 changes: 25 additions & 23 deletions spec/ruby/core/enumerable/slice_before_spec.rb
Original file line number Diff line number Diff line change
@@ -39,32 +39,34 @@
end
end

describe "and an argument" do
it "calls the block with a copy of that argument" do
arg = [:foo]
first = nil
e = @enum.slice_before(arg) do |i, init|
init.should == arg
init.should_not equal(arg)
first = init
i == 6 || i == 2
end
e.should be_an_instance_of(enumerator_class)
e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]]
e = @enum.slice_before(arg) do |i, init|
init.should_not equal(first)
ruby_version_is ""..."2.3" do
describe "and an argument" do
it "calls the block with a copy of that argument" do
arg = [:foo]
first = nil
e = @enum.slice_before(arg) do |i, init|
init.should == arg
init.should_not equal(arg)
first = init
i == 6 || i == 2
end
e.should be_an_instance_of(enumerator_class)
e.to_a.should == [[7], [6, 5, 4, 3], [2, 1]]
e = @enum.slice_before(arg) do |i, init|
init.should_not equal(first)
end
e.to_a
end
e.to_a
end

quarantine! do # need to double-check with ruby-core. Might be wrong or too specific
it "duplicates the argument directly without calling dup" do
arg = EnumerableSpecs::Undupable.new
e = @enum.slice_before(arg) do |i, init|
init.initialize_dup_called.should be_true
false
quarantine! do # need to double-check with ruby-core. Might be wrong or too specific
it "duplicates the argument directly without calling dup" do
arg = EnumerableSpecs::Undupable.new
e = @enum.slice_before(arg) do |i, init|
init.initialize_dup_called.should be_true
false
end
e.to_a.should == [[7, 6, 5, 4, 3, 2, 1]]
end
e.to_a.should == [[7, 6, 5, 4, 3, 2, 1]]
end
end
end
65 changes: 60 additions & 5 deletions spec/ruby/core/kernel/freeze_spec.rb
Original file line number Diff line number Diff line change
@@ -14,11 +14,66 @@
o.freeze.should equal(o)
end

# 1.9 allows immediates to be frozen #1747. Test in a separate process so
# as to avoid polluting the spec process with frozen immediates.
it "freezes immediate values" do
ruby_exe("print [nil, true, false, 1, :sym].map {|o| o.freeze; o.frozen? }").should ==
"[true, true, true, true, true]"
describe "on integers" do
it "has no effect since they are already frozen" do
1.frozen?.should be_true
1.freeze

bignum = bignum_value
bignum.frozen?.should be_true
bignum.freeze
end
end

describe "on a Float" do
it "has no effect since it is already frozen" do
1.2.frozen?.should be_true
1.2.freeze
end
end

describe "on a Symbol" do
ruby_version_is ""..."2.1" do
it "actually freezes it" do
:sym.frozen?.should be_false
:sym.freeze
:sym.frozen?.should be_true
end
end

ruby_version_is "2.1" do
it "has no effect since it is already frozen" do
:sym.frozen?.should be_true
:sym.freeze
end
end
end

describe "on true, false and nil" do
ruby_version_is ""..."2.2" do
it "actually freezes them" do
true.frozen?.should be_false
false.frozen?.should be_false
nil.frozen?.should be_false

# Test in a separate process so as to avoid polluting
# the spec process with frozen true, false and nil.
ruby_exe("print [true, false, nil].map { |o| o.freeze; o.frozen? }").should ==
"[true, true, true]"
end
end

ruby_version_is "2.2" do
it "has no effect since they are already frozen" do
nil.frozen?.should be_true
true.frozen?.should be_true
false.frozen?.should be_true

nil.freeze
true.freeze
false.freeze
end
end
end

it "causes mutative calls to raise RuntimeError" do
18 changes: 18 additions & 0 deletions spec/ruby/core/kernel/frozen_spec.rb
Original file line number Diff line number Diff line change
@@ -10,6 +10,24 @@
p.frozen?.should == true
end

describe "on true, false and nil" do
ruby_version_is ""..."2.2" do
it "returns false" do
true.frozen?.should be_false
false.frozen?.should be_false
nil.frozen?.should be_false
end
end

ruby_version_is "2.2" do
it "returns true" do
true.frozen?.should be_true
false.frozen?.should be_true
nil.frozen?.should be_true
end
end
end

describe "on integers" do
before(:each) do
@fixnum = 1
3 changes: 1 addition & 2 deletions spec/ruby/library/thread/sizedqueue/shared/enque.rb
Original file line number Diff line number Diff line change
@@ -22,10 +22,9 @@
ruby_version_is "2.2" do
it "raises a ThreadError if queued elements exceed size when not blocking" do
q = @object.new(2)
method = @method

non_blocking = true
add_to_queue = lambda { q.send(method, Object.new, non_blocking) }
add_to_queue = lambda { q.send(@method, Object.new, non_blocking) }

q.size.should == 0
add_to_queue.call