Don't invoke onValue for a canceled operation (#177)

Fixes #172

The `isCompleted` boolean does not necessarily indicate that
`valueOrCancellation` will complete with a value. If the completer was
completed with a `Future` and then canceled before that argument
invokes the listener callback, the `valueOrCancellation` future will
complete with `null` but `isCompleted` will be true. We only have a
value to pass to `onValue` when the completer was completed and not
canceled.

Add tests for the behavior of `then` when `cancel` is called after
`completer.complete`, both when it was completed with a Future and a
non-Future value.

Move the initialization for `originalCompleter` to the `setup` for the
tests so that it can be used before calling `then`.
3 files changed
tree: dc81fd3c474677414dd2ec2c3002f72c5ecb31c9
  1. .github/
  2. .gitignore
  3. AUTHORS
  4. CHANGELOG.md
  5. CONTRIBUTING.md
  6. LICENSE
  7. README.md
  8. analysis_options.yaml
  9. lib/
  10. pubspec.yaml
  11. test/
README.md

Contains utility classes in the style of dart:async to work with asynchronous computations.