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: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 39db72c6731f
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9115f8450946
Choose a head ref
  • 3 commits
  • 3 files changed
  • 2 contributors

Commits on Feb 14, 2014

  1. Verified

    This commit was signed with the committer’s verified signature.
    alexarice Alex Rice
    Copy the full SHA
    cd504b4 View commit details

Commits on Sep 5, 2014

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    mweinelt Martin Weinelt
    Copy the full SHA
    069d2f7 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    mweinelt Martin Weinelt
    Copy the full SHA
    9115f84 View commit details
Showing with 14 additions and 8 deletions.
  1. +6 −2 opal/corelib/numeric.rb
  2. +7 −6 spec/filters/bugs/numeric.rb
  3. +1 −0 spec/rubyspecs
8 changes: 6 additions & 2 deletions opal/corelib/numeric.rb
Original file line number Diff line number Diff line change
@@ -188,11 +188,15 @@ def <=>(other)
end

def <<(count)
`self << #{count.to_int}`
count = Opal.coerce_to! count, Integer, :to_int

`#{count} > 0 ? self << #{count} : self >> -#{count}`
end

def >>(count)
`self >> #{count.to_int}`
count = Opal.coerce_to! count, Integer, :to_int

`#{count} > 0 ? self >> #{count} : self << -#{count}`
end

def [](bit)
13 changes: 7 additions & 6 deletions spec/filters/bugs/numeric.rb
Original file line number Diff line number Diff line change
@@ -6,14 +6,15 @@
fails "Fixnum#zero? returns true if self is 0"
end

opal_filter "Fixnum#<< doesn't handle non-integers" do
fails "Fixnum#<< with n << m raises a TypeError when passed a String"
fails "Fixnum#<< with n << m raises a TypeError when passed nil"
fails "Fixnum#<< with n << m raises a TypeError when #to_int does not return an Integer"
opal_filter "Fixnum#<< doesn't handle Bignum and large number checks" do
fails "Fixnum#<< with n << m returns a Bignum == fixnum_min() * 2 when fixnum_min() << 1 and n < 0"
fails "Fixnum#<< with n << m returns a Bignum == fixnum_max() * 2 when fixnum_max() << 1 and n > 0"
fails "Fixnum#<< with n << m returns 0 when m < 0 and m is a Bignum"
fails "Fixnum#<< with n << m returns 0 when m < 0 and m == p where 2**p > n >= 2**(p-1)"
fails "Fixnum#<< with n << m returns n shifted right m bits when n < 0, m < 0"
fails "Fixnum#<< with n << m returns n shifted right m bits when n > 0, m < 0"
end

opal_filter "Fixnum#>> doesn't handle Bignum" do
fails "Fixnum#>> with n >> m returns a Bignum == fixnum_max() * 2 when fixnum_max() >> -1 and n > 0"
fails "Fixnum#>> with n >> m returns a Bignum == fixnum_min() * 2 when fixnum_min() >> -1 and n < 0"
fails "Fixnum#>> with n >> m returns 0 when m is a Bignum"
end
1 change: 1 addition & 0 deletions spec/rubyspecs
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@ corelib/core/fixnum/even_spec
corelib/core/fixnum/gt_spec
corelib/core/fixnum/gte_spec
corelib/core/fixnum/left_shift_spec
corelib/core/fixnum/right_shift_spec
corelib/core/fixnum/lt_spec
corelib/core/fixnum/lte_spec
corelib/core/fixnum/magnitude_spec