diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/-ext-/postponed_job/test_postponed_job.rb | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/test/-ext-/postponed_job/test_postponed_job.rb b/test/-ext-/postponed_job/test_postponed_job.rb index fee0172d11..6831ef7b37 100644 --- a/test/-ext-/postponed_job/test_postponed_job.rb +++ b/test/-ext-/postponed_job/test_postponed_job.rb @@ -2,34 +2,62 @@ require 'test/unit' require '-test-/postponed_job' -module Bug - def self.postponed_job_call_direct_wrapper(*args) - postponed_job_call_direct(*args) +class TestPostponed_job < Test::Unit::TestCase + def test_preregister_and_trigger + assert_separately([], __FILE__, __LINE__, <<-'RUBY') + require '-test-/postponed_job' + Bug.postponed_job_preregister_and_call_without_sleep(counters = []) + # i.e. rb_postponed_job_trigger performs coalescing + assert_equal([3], counters) + + # i.e. rb_postponed_job_trigger resets after interrupts are checked + Bug.postponed_job_preregister_and_call_with_sleep(counters = []) + assert_equal([1, 2, 3], counters) + RUBY end - def self.postponed_job_register_wrapper(*args) - postponed_job_register(*args) + def test_multiple_preregistration + assert_separately([], __FILE__, __LINE__, <<-'RUBY') + require '-test-/postponed_job' + handles = Bug.postponed_job_preregister_multiple_times + # i.e. rb_postponed_job_preregister returns the same handle if preregistered multiple times + assert_equal [handles[0]], handles.uniq + RUBY end -end -class TestPostponed_job < Test::Unit::TestCase - def test_register - direct, registered = [], [] - Bug.postponed_job_call_direct_wrapper(direct) - Bug.postponed_job_register_wrapper(registered) + def test_legacy_register + assert_separately([], __FILE__, __LINE__, <<-'RUBY') + require '-test-/postponed_job' + direct, registered = [], [] + + Bug.postponed_job_call_direct(direct) + Bug.postponed_job_register(registered) - assert_equal([0], direct) - assert_equal([3], registered) + assert_equal([0], direct) + assert_equal([3], registered) - Bug.postponed_job_register_one(ary = []) - assert_equal [1], ary + Bug.postponed_job_register_one(ary = []) + assert_equal [1], ary + RUBY + end + + def test_legacy_register_one_same + assert_separately([], __FILE__, __LINE__, <<-'RUBY') + require '-test-/postponed_job' + # Registering the same job three times should result in three of the same handle + handles = Bug.postponed_job_register_one_same + assert_equal [handles[0]], handles.uniq + RUBY end if Bug.respond_to?(:postponed_job_register_in_c_thread) - def test_register_in_c_thread - assert Bug.postponed_job_register_in_c_thread(ary = []) - assert_equal [1], ary + def test_legacy_register_in_c_thread + assert_separately([], __FILE__, __LINE__, <<-'RUBY') + require '-test-/postponed_job' + assert Bug.postponed_job_register_in_c_thread(ary = []) + assert_equal [1], ary + RUBY end end end |
