Skip to content

Commit

Permalink
Improve isSubscribable's type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
lempiji committed Oct 14, 2017
1 parent e5568f7 commit 98aa405
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/rx/algorithm/all.d
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,16 @@ unittest

unittest
{
alias TObserver = AllObserver!(Observer!bool, int);
alias TObserver = AllObserver!(Observer!bool, string);

static assert(isOutputRange!(TObserver, bool));
static assert(isOutputRange!(TObserver, string));
static assert(hasFailure!(TObserver));
static assert(hasCompleted!(TObserver));
}

unittest
{
alias TObserver = AllObserver!(Observer!bool, int);
alias TObserver = AllObserver!(Observer!bool, string);

static class CounterObserver : Observer!bool
{
Expand Down Expand Up @@ -183,7 +183,7 @@ unittest
auto counterDisposable = new CounterDisposable;
auto observer = TObserver(counterObserver, counterDisposable);

.put(observer, 0);
.put(observer, "TEST");
observer.completed();
assert(counterObserver.putCount == 1);
assert(counterObserver.lastValue == true);
Expand Down
4 changes: 4 additions & 0 deletions source/rx/observable.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ unittest
template isSubscribable(TObservable, TObserver)
{
enum bool isSubscribable = is(typeof({
static assert(isOutputRange!(TObserver, TObservable.ElementType));

TObservable observable = void;
TObserver observer = void;
auto d = observable.subscribe(observer);
Expand Down Expand Up @@ -75,6 +77,8 @@ unittest

struct TestObservable
{
alias ElementType = int;

TestDisposable subscribe(TestObserver observer)
{
return TestDisposable();
Expand Down

0 comments on commit 98aa405

Please sign in to comment.