Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit a71d336

Browse files
committed
* Fixed problem with the a private variable overriding the count operator in the prototype chain.
* Added regression tests
1 parent b022ed8 commit a71d336

4 files changed

Lines changed: 42 additions & 6 deletions

File tree

src/core/perf/operators/range.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
inherits(RangeObservable, __super__);
33
function RangeObservable(start, count, scheduler) {
44
this.start = start;
5-
this.count = count;
5+
this.rangeCount = count;
66
this.scheduler = scheduler;
77
__super__.call(this);
88
}
@@ -22,7 +22,7 @@
2222
}
2323

2424
RangeSink.prototype.run = function () {
25-
var start = this.parent.start, count = this.parent.count, observer = this.observer;
25+
var start = this.parent.start, count = this.parent.rangeCount, observer = this.observer;
2626
function loopRecursive(i, recurse) {
2727
if (i < count) {
2828
observer.onNext(start + i);

src/core/perf/operators/skip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
inherits(SkipObservable, __super__);
33
function SkipObservable(source, count) {
44
this.source = source;
5-
this.count = count;
5+
this.skipCount = count;
66
__super__.call(this);
77
}
88

99
SkipObservable.prototype.subscribeCore = function (o) {
10-
return this.source.subscribe(new InnerObserver(o, this.count));
10+
return this.source.subscribe(new InnerObserver(o, this.skipCount));
1111
};
1212

1313
function InnerObserver(o, c) {

src/core/perf/operators/take.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
function TakeObservable(source, count) {
55
this.source = source;
6-
this.count = count;
6+
this.takeCount = count;
77
__super__.call(this);
88
}
99

1010
TakeObservable.prototype.subscribeCore = function (o) {
11-
return this.source.subscribe(new InnerObserver(o, this.count));
11+
return this.source.subscribe(new InnerObserver(o, this.takeCount));
1212
};
1313

1414
function InnerObserver(o, c) {

tests/observable/count.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,39 @@ test('Count_Predicate_PredicateThrows', function () {
206206
res.messages.assertEqual(onError(230, ex));
207207
xs.subscriptions.assertEqual(subscribe(200, 230));
208208
});
209+
210+
test('Count_After_Range', function() {
211+
212+
var scheduler = new TestScheduler();
213+
var xs = Rx.Observable.range(1, 10, scheduler);
214+
215+
var result = scheduler.startWithCreate(function(){
216+
return xs.count();
217+
});
218+
219+
result.messages.assertEqual(onNext(211, 10), onCompleted(211));
220+
});
221+
222+
test('Count_After_Skip', function() {
223+
224+
var scheduler = new TestScheduler();
225+
var xs = Rx.Observable.range(1, 10, scheduler).skip(1);
226+
227+
var result = scheduler.startWithCreate(function(){
228+
return xs.count();
229+
});
230+
231+
result.messages.assertEqual(onNext(211, 9), onCompleted(211));
232+
});
233+
234+
test('Count_After_Take', function() {
235+
236+
var scheduler = new TestScheduler();
237+
var xs = Rx.Observable.range(1, 10, scheduler).take(1);
238+
239+
var result = scheduler.startWithCreate(function(){
240+
return xs.count();
241+
});
242+
243+
result.messages.assertEqual(onNext(201, 1), onCompleted(201));
244+
});

0 commit comments

Comments
 (0)