rx 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +1 -1
- data/examples/aggregate.rb +3 -3
- data/examples/amb.rb +4 -4
- data/examples/ambproto.rb +3 -3
- data/examples/and.rb +4 -4
- data/examples/as_observable.rb +2 -2
- data/examples/average.rb +3 -3
- data/examples/buffer_with_count.rb +3 -3
- data/examples/buffer_with_time.rb +3 -3
- data/examples/case.rb +5 -5
- data/examples/catch.rb +4 -4
- data/examples/catchproto.rb +5 -5
- data/examples/combine_latest.rb +4 -4
- data/examples/combine_latestproto.rb +3 -3
- data/examples/concat.rb +4 -4
- data/examples/concat_all.rb +3 -3
- data/examples/concat_map.rb +4 -4
- data/examples/concat_map_observer.rb +5 -5
- data/examples/concatproto.rb +3 -3
- data/examples/connect.rb +3 -3
- data/examples/contains.rb +3 -3
- data/examples/count.rb +3 -3
- data/examples/create.rb +4 -4
- data/examples/debounce.rb +3 -3
- data/examples/default_if_empty.rb +3 -3
- data/examples/defer.rb +3 -3
- data/examples/delay.rb +3 -3
- data/examples/delay_with_selector.rb +6 -6
- data/examples/dematerialize.rb +4 -4
- data/examples/disposable.rb +3 -3
- data/examples/distinct.rb +3 -3
- data/examples/distinct_until_changed.rb +3 -3
- data/examples/do.rb +4 -4
- data/examples/empty.rb +2 -2
- data/examples/for.rb +3 -3
- data/examples/fork_join.rb +6 -6
- data/examples/from.rb +7 -7
- data/examples/from_array.rb +2 -2
- data/examples/from_callback.rb +2 -2
- data/examples/generate.rb +2 -2
- data/examples/group_join.rb +5 -5
- data/examples/if.rb +6 -6
- data/examples/intervals.rb +2 -2
- data/examples/merge.rb +4 -4
- data/examples/merge_all.rb +3 -3
- data/examples/multicast.rb +4 -4
- data/examples/never.rb +2 -2
- data/examples/of.rb +2 -2
- data/examples/on_error_resume_next.rb +5 -5
- data/examples/pairs.rb +2 -2
- data/examples/publish.rb +5 -5
- data/examples/range.rb +2 -2
- data/examples/reduce.rb +2 -2
- data/examples/repeat.rb +2 -2
- data/examples/return.rb +2 -2
- data/examples/scan.rb +3 -3
- data/examples/start.rb +3 -3
- data/examples/throw.rb +3 -3
- data/examples/time_intervals.rb +2 -2
- data/examples/timer.rb +2 -2
- data/examples/timestamp.rb +2 -2
- data/examples/to_a.rb +2 -2
- data/examples/to_async.rb +2 -2
- data/examples/using.rb +3 -3
- data/examples/when.rb +4 -4
- data/examples/while.rb +3 -3
- data/examples/window_with_time.rb +3 -3
- data/examples/zip.rb +3 -3
- data/examples/zip_array.rb +3 -3
- data/lib/core_ext/enumerable.rb +3 -3
- data/lib/{rx_ruby.rb → rx.rb} +11 -11
- data/lib/{rx_ruby → rx}/concurrency/async_lock.rb +1 -1
- data/lib/{rx_ruby → rx}/concurrency/current_thread_scheduler.rb +6 -6
- data/lib/{rx_ruby → rx}/concurrency/default_scheduler.rb +8 -8
- data/lib/{rx_ruby → rx}/concurrency/historical_scheduler.rb +3 -3
- data/lib/{rx_ruby → rx}/concurrency/immediate_scheduler.rb +4 -4
- data/lib/{rx_ruby → rx}/concurrency/local_scheduler.rb +3 -3
- data/lib/{rx_ruby → rx}/concurrency/periodic_scheduler.rb +1 -1
- data/lib/{rx_ruby → rx}/concurrency/scheduled_item.rb +2 -2
- data/lib/{rx_ruby → rx}/concurrency/scheduler.rb +1 -1
- data/lib/{rx_ruby → rx}/concurrency/virtual_time_scheduler.rb +4 -4
- data/lib/{rx_ruby → rx}/core/async_lock_observer.rb +4 -4
- data/lib/{rx_ruby → rx}/core/auto_detach_observer.rb +4 -4
- data/lib/{rx_ruby → rx}/core/checked_observer.rb +2 -2
- data/lib/{rx_ruby → rx}/core/notification.rb +3 -3
- data/lib/{rx_ruby → rx}/core/observable.rb +6 -6
- data/lib/{rx_ruby → rx}/core/observe_on_observer.rb +2 -2
- data/lib/{rx_ruby → rx}/core/observer.rb +1 -1
- data/lib/{rx_ruby → rx}/core/scheduled_observer.rb +3 -3
- data/lib/{rx_ruby → rx}/core/synchronized_observer.rb +3 -3
- data/lib/{rx_ruby → rx}/core/time_interval.rb +1 -1
- data/lib/{rx_ruby → rx}/internal/priority_queue.rb +1 -1
- data/lib/{rx_ruby → rx}/internal/util.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/active_plan.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/join_observer.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/pattern.rb +1 -1
- data/lib/{rx_ruby → rx}/joins/plan.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/connectable_observable.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/_observable_timer_date_and_period.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/_observable_timer_time_span.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/_observable_timer_time_span_and_period.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/aggregate.rb +2 -2
- data/lib/{rx_ruby → rx}/linq/observable/and.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/case.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/concat_all.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/concat_map.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/concat_map_observer.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/contains.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/debounce.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/delay.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/delay_with_selector.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/do.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/for.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/fork_join.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/from.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/group_join.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/if.rb +1 -1
- data/lib/rx/linq/observable/interval.rb +5 -0
- data/lib/{rx_ruby → rx}/linq/observable/multicast.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/of.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/pairs.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/pluck.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/publish.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/start.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/time_interval.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/timer.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/timestamp.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/to_async.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/when.rb +1 -1
- data/lib/{rx_ruby → rx}/linq/observable/while.rb +1 -1
- data/lib/{rx_ruby → rx}/operators/aggregates.rb +31 -31
- data/lib/{rx_ruby → rx}/operators/creation.rb +6 -6
- data/lib/{rx_ruby → rx}/operators/multiple.rb +22 -23
- data/lib/{rx_ruby → rx}/operators/single.rb +14 -14
- data/lib/{rx_ruby → rx}/operators/standard_query_operators.rb +6 -6
- data/lib/{rx_ruby → rx}/operators/synchronization.rb +8 -8
- data/lib/{rx_ruby → rx}/operators/time.rb +12 -12
- data/lib/{rx_ruby → rx}/subjects/async_subject.rb +4 -4
- data/lib/{rx_ruby → rx}/subjects/behavior_subject.rb +3 -3
- data/lib/{rx_ruby → rx}/subjects/replay_subject.rb +5 -5
- data/lib/{rx_ruby → rx}/subjects/subject.rb +4 -4
- data/lib/{rx_ruby → rx}/subjects/subject_extensions.rb +3 -3
- data/lib/{rx_ruby → rx}/subscriptions/composite_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/ref_count_subscription.rb +2 -2
- data/lib/{rx_ruby → rx}/subscriptions/scheduled_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/serial_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/single_assignment_subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/subscriptions/subscription.rb +1 -1
- data/lib/{rx_ruby → rx}/testing/cold_observable.rb +4 -4
- data/lib/{rx_ruby → rx}/testing/hot_observable.rb +4 -4
- data/lib/{rx_ruby → rx}/testing/mock_observer.rb +4 -4
- data/lib/{rx_ruby → rx}/testing/reactive_test.rb +3 -3
- data/lib/{rx_ruby → rx}/testing/recorded.rb +1 -1
- data/lib/{rx_ruby → rx}/testing/test_scheduler.rb +8 -8
- data/lib/{rx_ruby → rx}/testing/test_subscription.rb +1 -1
- data/lib/rx/version.rb +3 -0
- data/readme.md +19 -19
- data/{rx_ruby.gemspec → rx.gemspec} +2 -2
- data/test/{rx_ruby → rx}/concurrency/helpers/historical_virtual_scheduler_helper.rb +0 -0
- data/test/{rx_ruby → rx}/concurrency/helpers/immediate_local_scheduler_helper.rb +0 -0
- data/test/{rx_ruby → rx}/concurrency/test_async_lock.rb +1 -1
- data/test/{rx_ruby → rx}/concurrency/test_current_thread_scheduler.rb +3 -3
- data/test/{rx_ruby → rx}/concurrency/test_default_scheduler.rb +1 -1
- data/test/{rx_ruby → rx}/concurrency/test_historical_scheduler.rb +3 -3
- data/test/{rx_ruby → rx}/concurrency/test_immediate_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/concurrency/test_local_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/concurrency/test_periodic_scheduler.rb +1 -1
- data/test/{rx_ruby → rx}/concurrency/test_scheduled_item.rb +4 -4
- data/test/{rx_ruby → rx}/concurrency/test_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/concurrency/test_virtual_time_scheduler.rb +2 -2
- data/test/{rx_ruby → rx}/core/test_notification.rb +20 -20
- data/test/{rx_ruby → rx}/core/test_observable_creation.rb +220 -63
- data/test/{rx_ruby → rx}/core/test_observer.rb +39 -39
- data/test/{rx_ruby → rx}/internal/test_priority_queue.rb +6 -6
- data/test/{rx_ruby → rx}/subscriptions/test_composite_subscription.rb +20 -20
- data/test/{rx_ruby → rx}/subscriptions/test_serial_subscription.rb +9 -9
- data/test/{rx_ruby → rx}/subscriptions/test_singleassignment_subscription.rb +8 -8
- data/test/{rx_ruby → rx}/subscriptions/test_subscription.rb +3 -3
- data/test/test_helper.rb +1 -1
- metadata +129 -129
- data/lib/rx_ruby/linq/observable/interval.rb +0 -5
- data/lib/rx_ruby/version.rb +0 -3
@@ -5,7 +5,7 @@ require 'thread'
|
|
5
5
|
require 'test_helper'
|
6
6
|
|
7
7
|
class MyObserver
|
8
|
-
include
|
8
|
+
include Rx::Observer
|
9
9
|
|
10
10
|
attr_reader :next, :error, :completed
|
11
11
|
|
@@ -33,7 +33,7 @@ class TestObserver < Minitest::Test
|
|
33
33
|
|
34
34
|
def test_from_notifier_notification_on_next
|
35
35
|
i = 0
|
36
|
-
obs =
|
36
|
+
obs = Rx::Observer.from_notifier do |n|
|
37
37
|
assert_equal i, 0
|
38
38
|
i += 1
|
39
39
|
assert n.on_next?
|
@@ -47,7 +47,7 @@ class TestObserver < Minitest::Test
|
|
47
47
|
def test_from_notifier_notification_on_error
|
48
48
|
err = RuntimeError.new
|
49
49
|
i = 0
|
50
|
-
obs =
|
50
|
+
obs = Rx::Observer.from_notifier do |n|
|
51
51
|
assert_equal i, 0
|
52
52
|
i += 1
|
53
53
|
assert n.on_error?
|
@@ -60,7 +60,7 @@ class TestObserver < Minitest::Test
|
|
60
60
|
|
61
61
|
def test_from_notifier_notification_on_completed
|
62
62
|
i = 0
|
63
|
-
obs =
|
63
|
+
obs = Rx::Observer.from_notifier do |n|
|
64
64
|
assert_equal i, 0
|
65
65
|
i += 1
|
66
66
|
assert n.on_completed?
|
@@ -72,16 +72,16 @@ class TestObserver < Minitest::Test
|
|
72
72
|
|
73
73
|
def test_to_notifier_forwards
|
74
74
|
obsn = MyObserver.new
|
75
|
-
obsn.to_notifier.call(
|
75
|
+
obsn.to_notifier.call(Rx::Notification.create_on_next 42)
|
76
76
|
assert_equal 42, obsn.next
|
77
77
|
|
78
78
|
err = RuntimeError.new
|
79
79
|
obse = MyObserver.new
|
80
|
-
obse.to_notifier.call(
|
80
|
+
obse.to_notifier.call(Rx::Notification.create_on_error err)
|
81
81
|
assert_same err, obse.error
|
82
82
|
|
83
83
|
obsc = MyObserver.new
|
84
|
-
obsc.to_notifier.call(
|
84
|
+
obsc.to_notifier.call(Rx::Notification.create_on_completed)
|
85
85
|
assert obsc.completed
|
86
86
|
end
|
87
87
|
|
@@ -109,7 +109,7 @@ class TestObserver < Minitest::Test
|
|
109
109
|
|
110
110
|
def test_configure_on_next
|
111
111
|
next_called = false
|
112
|
-
res =
|
112
|
+
res = Rx::Observer.configure do |o|
|
113
113
|
o.on_next do |x|
|
114
114
|
assert_equal 42, x
|
115
115
|
next_called = true
|
@@ -126,7 +126,7 @@ class TestObserver < Minitest::Test
|
|
126
126
|
e1 = nil
|
127
127
|
|
128
128
|
next_called = false
|
129
|
-
res =
|
129
|
+
res = Rx::Observer.configure do |o|
|
130
130
|
o.on_next do |x|
|
131
131
|
assert_equal 42, x
|
132
132
|
next_called = true
|
@@ -150,7 +150,7 @@ class TestObserver < Minitest::Test
|
|
150
150
|
next_called = false
|
151
151
|
completed = false
|
152
152
|
|
153
|
-
res =
|
153
|
+
res = Rx::Observer.configure do |o|
|
154
154
|
o.on_next do |x|
|
155
155
|
assert_equal 42, x
|
156
156
|
next_called = true
|
@@ -174,7 +174,7 @@ class TestObserver < Minitest::Test
|
|
174
174
|
next_called = false
|
175
175
|
completed = false
|
176
176
|
|
177
|
-
res =
|
177
|
+
res = Rx::Observer.configure do |o|
|
178
178
|
o.on_next do |x|
|
179
179
|
assert_equal 42, x
|
180
180
|
next_called = true
|
@@ -203,7 +203,7 @@ class TestObserver < Minitest::Test
|
|
203
203
|
next_called = false
|
204
204
|
error = false
|
205
205
|
|
206
|
-
res =
|
206
|
+
res = Rx::Observer.configure do |o|
|
207
207
|
o.on_next do |x|
|
208
208
|
assert_equal 42, x
|
209
209
|
next_called = true
|
@@ -228,7 +228,7 @@ class TestObserver < Minitest::Test
|
|
228
228
|
next_called = false
|
229
229
|
error = false
|
230
230
|
|
231
|
-
res =
|
231
|
+
res = Rx::Observer.configure do |o|
|
232
232
|
o.on_next do |x|
|
233
233
|
assert_equal 42, x
|
234
234
|
next_called = true
|
@@ -254,7 +254,7 @@ class TestObserver < Minitest::Test
|
|
254
254
|
error = false
|
255
255
|
completed = false
|
256
256
|
|
257
|
-
res =
|
257
|
+
res = Rx::Observer.configure do |o|
|
258
258
|
o.on_next do |x|
|
259
259
|
assert_equal 42, x
|
260
260
|
next_called = true
|
@@ -284,7 +284,7 @@ class TestObserver < Minitest::Test
|
|
284
284
|
error = false
|
285
285
|
completed = false
|
286
286
|
|
287
|
-
res =
|
287
|
+
res = Rx::Observer.configure do |o|
|
288
288
|
o.on_next do |x|
|
289
289
|
assert_equal 42, x
|
290
290
|
next_called = true
|
@@ -314,7 +314,7 @@ class TestObserver < Minitest::Test
|
|
314
314
|
error = false
|
315
315
|
completed = false
|
316
316
|
|
317
|
-
res =
|
317
|
+
res = Rx::Observer.configure do |o|
|
318
318
|
o.on_next do |x|
|
319
319
|
assert_equal 42, x
|
320
320
|
next_called = true
|
@@ -342,7 +342,7 @@ class TestObserver < Minitest::Test
|
|
342
342
|
m = 0
|
343
343
|
n = 0
|
344
344
|
|
345
|
-
o =
|
345
|
+
o = Rx::Observer.configure do |obs|
|
346
346
|
obs.on_next {|x| m += 1 }
|
347
347
|
obs.on_error {|err| flunk }
|
348
348
|
obs.on_completed { n += 1 }
|
@@ -365,7 +365,7 @@ class TestObserver < Minitest::Test
|
|
365
365
|
m = 0
|
366
366
|
n = 0
|
367
367
|
|
368
|
-
o =
|
368
|
+
o = Rx::Observer.configure do |obs|
|
369
369
|
obs.on_next {|x| m += 1 }
|
370
370
|
obs.on_error {|err| n += 1 }
|
371
371
|
obs.on_completed { flunk }
|
@@ -387,7 +387,7 @@ class TestObserver < Minitest::Test
|
|
387
387
|
def test_checked_reentrant_next
|
388
388
|
n = 0
|
389
389
|
|
390
|
-
o =
|
390
|
+
o = Rx::Observer.configure do |obs|
|
391
391
|
obs.on_next do |x|
|
392
392
|
n += 1
|
393
393
|
|
@@ -409,7 +409,7 @@ class TestObserver < Minitest::Test
|
|
409
409
|
def test_checked_reentrant_error
|
410
410
|
n = 0
|
411
411
|
|
412
|
-
o =
|
412
|
+
o = Rx::Observer.configure do |obs|
|
413
413
|
obs.on_next {|x| flunk }
|
414
414
|
|
415
415
|
obs.on_error do |err|
|
@@ -432,7 +432,7 @@ class TestObserver < Minitest::Test
|
|
432
432
|
def test_checked_reentrant_completed
|
433
433
|
n = 0
|
434
434
|
|
435
|
-
o =
|
435
|
+
o = Rx::Observer.configure do |obs|
|
436
436
|
obs.on_next {|x| flunk }
|
437
437
|
obs.on_error {|x| flunk }
|
438
438
|
|
@@ -456,7 +456,7 @@ class TestObserver < Minitest::Test
|
|
456
456
|
in_one = false
|
457
457
|
|
458
458
|
s = nil
|
459
|
-
o =
|
459
|
+
o = Rx::Observer.configure do |obs|
|
460
460
|
obs.on_next do |x|
|
461
461
|
if x == 1
|
462
462
|
in_one = true
|
@@ -468,7 +468,7 @@ class TestObserver < Minitest::Test
|
|
468
468
|
end
|
469
469
|
end
|
470
470
|
|
471
|
-
s =
|
471
|
+
s = Rx::Observer.allow_reentrancy o
|
472
472
|
s.on_next 1
|
473
473
|
assert res
|
474
474
|
end
|
@@ -478,7 +478,7 @@ class TestObserver < Minitest::Test
|
|
478
478
|
in_one = false
|
479
479
|
|
480
480
|
s = nil
|
481
|
-
o =
|
481
|
+
o = Rx::Observer.configure do |obs|
|
482
482
|
obs.on_next do |x|
|
483
483
|
if x == 1
|
484
484
|
in_one = true
|
@@ -490,7 +490,7 @@ class TestObserver < Minitest::Test
|
|
490
490
|
end
|
491
491
|
end
|
492
492
|
|
493
|
-
s =
|
493
|
+
s = Rx::Observer.allow_reentrancy o, Monitor.new
|
494
494
|
s.on_next 1
|
495
495
|
assert res
|
496
496
|
end
|
@@ -500,7 +500,7 @@ class TestObserver < Minitest::Test
|
|
500
500
|
in_one = false
|
501
501
|
|
502
502
|
s = nil
|
503
|
-
o =
|
503
|
+
o = Rx::Observer.configure do |obs|
|
504
504
|
obs.on_next do |x|
|
505
505
|
if x == 1
|
506
506
|
in_one = true
|
@@ -512,7 +512,7 @@ class TestObserver < Minitest::Test
|
|
512
512
|
end
|
513
513
|
end
|
514
514
|
|
515
|
-
s =
|
515
|
+
s = Rx::Observer.prevent_reentrancy o
|
516
516
|
s.on_next 1
|
517
517
|
assert res
|
518
518
|
end
|
@@ -522,7 +522,7 @@ class TestObserver < Minitest::Test
|
|
522
522
|
in_one = false
|
523
523
|
|
524
524
|
s = nil
|
525
|
-
o =
|
525
|
+
o = Rx::Observer.configure do |obs|
|
526
526
|
obs.on_next do |x|
|
527
527
|
if x == 1
|
528
528
|
in_one = true
|
@@ -534,7 +534,7 @@ class TestObserver < Minitest::Test
|
|
534
534
|
end
|
535
535
|
end
|
536
536
|
|
537
|
-
s =
|
537
|
+
s = Rx::Observer.prevent_reentrancy o, Rx::AsyncLock.new
|
538
538
|
s.on_next 1
|
539
539
|
assert res
|
540
540
|
end
|
@@ -543,13 +543,13 @@ class TestObserver < Minitest::Test
|
|
543
543
|
res = false
|
544
544
|
s = nil
|
545
545
|
|
546
|
-
o =
|
546
|
+
o = Rx::Observer.configure do |obs|
|
547
547
|
obs.on_next {|x| res = x == 1 }
|
548
548
|
obs.on_error {|err| flunk }
|
549
549
|
obs.on_completed { flunk }
|
550
550
|
end
|
551
551
|
|
552
|
-
s =
|
552
|
+
s = Rx::Observer.prevent_reentrancy o
|
553
553
|
s.on_next 1
|
554
554
|
|
555
555
|
assert res
|
@@ -560,13 +560,13 @@ class TestObserver < Minitest::Test
|
|
560
560
|
e = RuntimeError.new
|
561
561
|
s = nil
|
562
562
|
|
563
|
-
o =
|
563
|
+
o = Rx::Observer.configure do |obs|
|
564
564
|
obs.on_next {|x| flunk }
|
565
565
|
obs.on_error {|err| res = err }
|
566
566
|
obs.on_completed { flunk }
|
567
567
|
end
|
568
568
|
|
569
|
-
s =
|
569
|
+
s = Rx::Observer.prevent_reentrancy o
|
570
570
|
s.on_error e
|
571
571
|
|
572
572
|
assert_same e, res
|
@@ -576,13 +576,13 @@ class TestObserver < Minitest::Test
|
|
576
576
|
res = false
|
577
577
|
s = nil
|
578
578
|
|
579
|
-
o =
|
579
|
+
o = Rx::Observer.configure do |obs|
|
580
580
|
obs.on_next {|x| flunk }
|
581
581
|
obs.on_error {|err| flunk }
|
582
582
|
obs.on_completed { res = true }
|
583
583
|
end
|
584
584
|
|
585
|
-
s =
|
585
|
+
s = Rx::Observer.prevent_reentrancy o
|
586
586
|
s.on_completed
|
587
587
|
|
588
588
|
assert res
|
@@ -592,13 +592,13 @@ class TestObserver < Minitest::Test
|
|
592
592
|
c = 0
|
593
593
|
num = 100
|
594
594
|
|
595
|
-
o =
|
595
|
+
o = Rx::Observer.configure do |obs|
|
596
596
|
obs.on_next {|x| c += 1 }
|
597
597
|
obs.on_error {|err| flunk }
|
598
598
|
obs.on_completed { }
|
599
599
|
end
|
600
600
|
|
601
|
-
s =
|
601
|
+
s = Rx::ImmediateScheduler.instance
|
602
602
|
n = o.notify_on(s)
|
603
603
|
|
604
604
|
for i in 0..num
|
@@ -615,13 +615,13 @@ class TestObserver < Minitest::Test
|
|
615
615
|
num = 100
|
616
616
|
err = RuntimeError.new
|
617
617
|
|
618
|
-
o =
|
618
|
+
o = Rx::Observer.configure do |obs|
|
619
619
|
obs.on_next {|x| c += 1 }
|
620
620
|
obs.on_error {|e| assert_same err, e }
|
621
621
|
obs.on_completed { flunk }
|
622
622
|
end
|
623
623
|
|
624
|
-
s =
|
624
|
+
s = Rx::ImmediateScheduler.instance
|
625
625
|
n = o.notify_on(s)
|
626
626
|
|
627
627
|
for i in 0..num
|
@@ -5,7 +5,7 @@ require 'test_helper'
|
|
5
5
|
class TestPriorityQueue < Minitest::Test
|
6
6
|
|
7
7
|
def test_simple_push_and_shift
|
8
|
-
queue =
|
8
|
+
queue = Rx::PriorityQueue.new
|
9
9
|
queue.push 400
|
10
10
|
|
11
11
|
assert_equal 400, queue.shift
|
@@ -13,7 +13,7 @@ class TestPriorityQueue < Minitest::Test
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_shift_with_priority
|
16
|
-
queue =
|
16
|
+
queue = Rx::PriorityQueue.new
|
17
17
|
queue.push 400
|
18
18
|
queue.push 300
|
19
19
|
queue.push 500
|
@@ -24,7 +24,7 @@ class TestPriorityQueue < Minitest::Test
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_delete
|
27
|
-
queue =
|
27
|
+
queue = Rx::PriorityQueue.new
|
28
28
|
[1, 4, 5, 2, 3].each {|it| queue.push it }
|
29
29
|
|
30
30
|
assert !queue.delete(404)
|
@@ -36,7 +36,7 @@ class TestPriorityQueue < Minitest::Test
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_push_thread_safety
|
39
|
-
queue =
|
39
|
+
queue = Rx::PriorityQueue.new
|
40
40
|
5.times.map {
|
41
41
|
Thread.new do
|
42
42
|
100.times do |i|
|
@@ -48,7 +48,7 @@ class TestPriorityQueue < Minitest::Test
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def test_shift_thread_safety
|
51
|
-
queue =
|
51
|
+
queue = Rx::PriorityQueue.new
|
52
52
|
500.times {|i| queue.push i }
|
53
53
|
|
54
54
|
5.times.map {
|
@@ -62,7 +62,7 @@ class TestPriorityQueue < Minitest::Test
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_delete_same_item
|
65
|
-
queue =
|
65
|
+
queue = Rx::PriorityQueue.new
|
66
66
|
10.times { queue.push 42 }
|
67
67
|
queue.delete 42
|
68
68
|
assert_equal 9, queue.length
|
@@ -5,10 +5,10 @@ require 'test_helper'
|
|
5
5
|
class TestCompositeSubscription < Minitest::Test
|
6
6
|
|
7
7
|
def test_include
|
8
|
-
d1 =
|
9
|
-
d2 =
|
8
|
+
d1 = Rx::Subscription.create { }
|
9
|
+
d2 = Rx::Subscription.create { }
|
10
10
|
|
11
|
-
g =
|
11
|
+
g = Rx::CompositeSubscription.new([d1, d2])
|
12
12
|
|
13
13
|
assert_equal 2, g.length
|
14
14
|
assert g.include? d1
|
@@ -16,11 +16,11 @@ class TestCompositeSubscription < Minitest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_to_a
|
19
|
-
d1 =
|
20
|
-
d2 =
|
19
|
+
d1 = Rx::Subscription.create { }
|
20
|
+
d2 = Rx::Subscription.create { }
|
21
21
|
|
22
22
|
ds = [d1, d2]
|
23
|
-
g =
|
23
|
+
g = Rx::CompositeSubscription.new([d1, d2])
|
24
24
|
|
25
25
|
assert_equal 2, g.length
|
26
26
|
|
@@ -31,9 +31,9 @@ class TestCompositeSubscription < Minitest::Test
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_push
|
34
|
-
d1 =
|
35
|
-
d2 =
|
36
|
-
g =
|
34
|
+
d1 = Rx::Subscription.create { }
|
35
|
+
d2 = Rx::Subscription.create { }
|
36
|
+
g = Rx::CompositeSubscription.new([d1])
|
37
37
|
|
38
38
|
assert_equal 1, g.length
|
39
39
|
assert g.include? d1
|
@@ -48,9 +48,9 @@ class TestCompositeSubscription < Minitest::Test
|
|
48
48
|
disp1 = false
|
49
49
|
disp2 = false
|
50
50
|
|
51
|
-
d1 =
|
52
|
-
d2 =
|
53
|
-
g =
|
51
|
+
d1 = Rx::Subscription.create { disp1 = true }
|
52
|
+
d2 = Rx::Subscription.create { disp2 = true }
|
53
|
+
g = Rx::CompositeSubscription.new [d1]
|
54
54
|
assert_equal 1, g.length
|
55
55
|
|
56
56
|
g.unsubscribe
|
@@ -68,9 +68,9 @@ class TestCompositeSubscription < Minitest::Test
|
|
68
68
|
disp1 = false
|
69
69
|
disp2 = false
|
70
70
|
|
71
|
-
d1 =
|
72
|
-
d2 =
|
73
|
-
g =
|
71
|
+
d1 = Rx::Subscription.create { disp1 = true }
|
72
|
+
d2 = Rx::Subscription.create { disp2 = true }
|
73
|
+
g = Rx::CompositeSubscription.new [d1, d2]
|
74
74
|
|
75
75
|
assert_equal 2, g.length
|
76
76
|
assert g.include? d1
|
@@ -88,7 +88,7 @@ class TestCompositeSubscription < Minitest::Test
|
|
88
88
|
assert disp2
|
89
89
|
|
90
90
|
disp3 = false
|
91
|
-
d3 =
|
91
|
+
d3 = Rx::Subscription.create { disp3 = true }
|
92
92
|
assert_nil g.delete d3
|
93
93
|
refute disp3
|
94
94
|
end
|
@@ -97,9 +97,9 @@ class TestCompositeSubscription < Minitest::Test
|
|
97
97
|
disp1 = false
|
98
98
|
disp2 = false
|
99
99
|
|
100
|
-
d1 =
|
101
|
-
d2 =
|
102
|
-
g =
|
100
|
+
d1 = Rx::Subscription.create { disp1 = true }
|
101
|
+
d2 = Rx::Subscription.create { disp2 = true }
|
102
|
+
g = Rx::CompositeSubscription.new [d1, d2]
|
103
103
|
assert_equal 2, g.length
|
104
104
|
|
105
105
|
g.clear
|
@@ -108,7 +108,7 @@ class TestCompositeSubscription < Minitest::Test
|
|
108
108
|
assert_equal 0, g.length
|
109
109
|
|
110
110
|
disp3 = false
|
111
|
-
d3 =
|
111
|
+
d3 = Rx::Subscription.create { disp3 = true }
|
112
112
|
g.push d3
|
113
113
|
refute disp3
|
114
114
|
assert_equal 1, g.length
|