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. lib/
  3. test/
  4. .gitignore
  5. analysis_options.yaml
  6. AUTHORS
  7. CHANGELOG.md
  8. CONTRIBUTING.md
  9. LICENSE
  10. pubspec.yaml
  11. README.md
README.md

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