Skip to content

Commit ca2ddb7

Browse files
committed
Use latest version of test-unit
1 parent dc2b5df commit ca2ddb7

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

numo-narray.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ Gem::Specification.new do |spec|
3535
end
3636
spec.add_development_dependency "rake", ">= 12.3.3"
3737
spec.add_development_dependency "rake-compiler", "~> 1.1"
38-
spec.add_development_dependency "test-unit", "~> 3.0"
38+
spec.add_development_dependency "test-unit"
3939
end

test/ractor_test.rb

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,50 @@
11
require_relative "test_helper"
22

33
class NArrayRactorTest < NArrayTestBase
4-
def setup
5-
super
6-
omit "Require Ractor" unless defined? Ractor
7-
end
8-
9-
data(:dtype, TYPES, keep: true)
10-
def test_non_frozen(data)
11-
dtype = data.fetch(:dtype)
12-
ary = random_array(dtype)
13-
r = Ractor.new(ary) {|x| x }
14-
ary2 = r.take
15-
assert_equal(ary, ary2)
16-
assert_not_same(ary, ary2)
17-
end
18-
19-
def test_frozen(data)
20-
dtype = data.fetch(:dtype)
21-
ary1 = random_array(dtype)
22-
ary1.freeze
23-
r = Ractor.new(ary1) do |ary2|
24-
[ary2, ary2 * 10]
4+
if respond_to?(:ractor)
5+
ractor keep: true
6+
data(:dtype, TYPES, keep: true)
7+
def test_non_frozen(data)
8+
dtype = data.fetch(:dtype)
9+
ary = random_array(dtype)
10+
r = Ractor.new(ary) {|x| x }
11+
ary2 = r.take
12+
assert_equal(ary, ary2)
13+
assert_not_same(ary, ary2)
2514
end
26-
ary2, res = r.take
27-
assert_equal((dtype != Numo::RObject),
28-
ary1.equal?(ary2))
29-
assert_equal(ary1*10, res)
30-
end
3115

32-
def test_parallel(data)
33-
dtype = data.fetch(:dtype)
34-
ary1 = random_array(dtype, 100000)
35-
r1 = Ractor.new(ary1) do |ary2|
36-
ary2 * 10
16+
def test_frozen(data)
17+
dtype = data.fetch(:dtype)
18+
ary1 = random_array(dtype)
19+
ary1.freeze
20+
r = Ractor.new(ary1) do |ary2|
21+
[ary2, ary2 * 10]
22+
end
23+
ary2, res = r.take
24+
assert_equal((dtype != Numo::RObject),
25+
ary1.equal?(ary2))
26+
assert_equal(ary1*10, res)
3727
end
38-
r2 = Ractor.new(ary1) do |ary4|
39-
ary4 * 10
28+
29+
def test_parallel(data)
30+
dtype = data.fetch(:dtype)
31+
ary1 = random_array(dtype, 100000)
32+
r1 = Ractor.new(ary1) do |ary2|
33+
ary2 * 10
34+
end
35+
r2 = Ractor.new(ary1) do |ary4|
36+
ary4 * 10
37+
end
38+
assert_equal(r1.take, r2.take)
4039
end
41-
assert_equal(r1.take, r2.take)
42-
end
4340

44-
def random_array(dtype, n=1000)
45-
case dtype
46-
when Numo::DFloat, Numo::SFloat, Numo::DComplex, Numo::SComplex
47-
dtype.new(n).rand_norm
48-
else
49-
dtype.new(n).rand(10)
41+
def random_array(dtype, n=1000)
42+
case dtype
43+
when Numo::DFloat, Numo::SFloat, Numo::DComplex, Numo::SComplex
44+
dtype.new(n).rand_norm
45+
else
46+
dtype.new(n).rand(10)
47+
end
5048
end
5149
end
5250
end

0 commit comments

Comments
 (0)