2 require 'concurrent/parallel'
5 class TestParallel < Test::Unit::TestCase
6 def check_parallel( enum, n, meth, *args, &block )
7 regular = enum.send( meth, *args, &block )
8 parallel = enum.send( "parallel_#{ meth }", n, *args, &block )
9 assert_equal regular, parallel
13 check_parallel( 0..100, 2, "map" ) { |x| x * 2 }
17 check_parallel( 0..100, 2, "any?" ) { |x| ( ( x + 1 ) % 48 ).zero? }
18 check_parallel( 0..100, 2, "any?" )
19 check_parallel( [ false ] * 100, 2, "any?" )
20 check_parallel( [ true ] * 100, 2, "any?" )
24 check_parallel( 0..100, 2, "all?" ) { |x| ( ( x + 1 ) % 48 ).zero? }
25 check_parallel( 0..100, 2, "all?" )
26 check_parallel( [ false ] * 100, 2, "all?" )
27 check_parallel( [ true ] * 100, 2, "all?" )
31 check_parallel( 0..100, 2, "include?", 5 )
32 check_parallel( 0..100, 2, "include?", 1000 )