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

Commits on Mar 4, 2015

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    4582f82 View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    5cb0ff4 View commit details
  3. Copy the full SHA
    2a98e52 View commit details
  4. Merge pull request #725 from ryanstout/master

    Fix issue with @delayed ignoring falsy values in Promise.
    meh committed Mar 4, 2015
    Copy the full SHA
    6bb64f7 View commit details
Showing with 15 additions and 7 deletions.
  1. +8 −0 spec/opal/stdlib/promise/then_spec.rb
  2. +7 −7 stdlib/promise.rb
8 changes: 8 additions & 0 deletions spec/opal/stdlib/promise/then_spec.rb
Original file line number Diff line number Diff line change
@@ -60,4 +60,12 @@
p.then {}
}.should raise_error(ArgumentError)
end

it 'should pass a delayed falsy value' do
p = Promise.new.resolve(5).then { nil }

p.then do |value|
expect(value).to eq(nil)
end
end
end
14 changes: 7 additions & 7 deletions stdlib/promise.rb
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ def initialize(success = nil, failure = nil)
@exception = false
@value = nil
@error = nil
@delayed = nil
@delayed = false

@prev = nil
@next = nil
@@ -163,11 +163,11 @@ def >>(promise)
@next = promise

if exception?
promise.reject(@delayed)
promise.reject(@delayed[0])
elsif resolved?
promise.resolve(@delayed || value)
elsif rejected? && (!@failure || Promise === (@delayed || @error))
promise.reject(@delayed || error)
promise.resolve(@delayed ? @delayed[0] : value)
elsif rejected? && (!@failure || Promise === (@delayed ? @delayed[0] : @error))
promise.reject(@delayed ? @delayed[0] : error)
end

self
@@ -204,7 +204,7 @@ def resolve!(value)
if @next
@next.resolve(value)
else
@delayed = value
@delayed = [value]
end
end

@@ -243,7 +243,7 @@ def reject!(value)
if @next
@next.reject(value)
else
@delayed = value
@delayed = [value]
end
end