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: a3e9e3e457d7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 78228a59765f
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 19, 2016

  1. Squashed 'spec/ruby/' changes from ced79c8..9601c82

    9601c82 Add a spec for the combination of the safe navigation operator and assignment methods
    bbb9c11 Use a Hash literal instead of new_hash
    
    git-subtree-dir: spec/ruby
    git-subtree-split: 9601c82c6e4cfef60fef28f71310acdf1dea768a
    eregon committed Jul 19, 2016
    Copy the full SHA
    e8eb2dd View commit details
  2. Copy the full SHA
    78228a5 View commit details
Showing with 19 additions and 2 deletions.
  1. +1 −1 spec/ruby/core/hash/shift_spec.rb
  2. +18 −1 spec/ruby/language/safe_navigator_spec.rb
2 changes: 1 addition & 1 deletion spec/ruby/core/hash/shift_spec.rb
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
end

it "preserves Hash invariants when removing the last item" do
h = new_hash(:a => 1, :b => 2)
h = { :a => 1, :b => 2 }
h.shift.should == [:a, 1]
h.shift.should == [:b, 2]
h[:c] = 3
19 changes: 18 additions & 1 deletion spec/ruby/language/safe_navigator_spec.rb
Original file line number Diff line number Diff line change
@@ -47,7 +47,24 @@
eval("[1,2]&.map { |i| i * 2 }").should == [2, 4]
end

it "allows attribute assignment" do
it "allows assignment methods" do
klass = Class.new do
attr_reader :foo
def foo=(val)
@foo = val
42
end
end
obj = klass.new

eval("obj&.foo = 3").should == 3
obj.foo.should == 3

obj = nil
eval("obj&.foo = 3").should == nil
end

it "allows assignment operators" do
klass = Class.new do
attr_accessor :m