Skip to content

Commit aef41c1

Browse files
committed
[ractor] Implement feedback when testing ractors
1 parent b2ae64e commit aef41c1

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# shareable_constant_value: literal
22

3-
A = [1, 2]
4-
H = {a: "a"}
3+
A = "rac"
4+
H = "tor"
55

66
Ractor.new do
7-
A
8-
H
9-
en.take
7+
print A
8+
print H
9+
end.take

Diff for: language/ractor_spec.rb

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
1-
require_relative '../spec_helper'
1+
require_relative "../spec_helper"
22

3-
describe "Magic comments" do
3+
describe "magic comments in ractors" do
44
ruby_version_is "3.0" do
5-
it 'makes constants shareable between ractors' do
6-
-> { ruby_exe(fixture(__FILE__, 'shareable_constant_value_magic_comment.rb'), options: '-W0')}.should_not raise_error
5+
it "makes constants shareable between ractors" do
6+
out = ruby_exe(fixture(__FILE__, "shareable_constant_value_magic_comment.rb"), options: "-W0")
7+
out.should == "ractor"
78
end
89

9-
it 'makes constants shareable between ractors' do
10-
a, b, c = Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}")
11-
begin;
10+
it "makes constants shareable between ractors" do
11+
a, b, c = Class.new.class_eval(<<~RUBY, __FILE__, __LINE__ + 1)
1212
# shareable_constant_value: experimental_everything
1313
A = [[1]]
1414
# shareable_constant_value: none
1515
B = [[2]]
1616
# shareable_constant_value: literal
17-
C = [["shareable", "constant#{nil}"]]
17+
C = [["shareable", "constant#{self.class.name}"]]
1818
[A, B, C]
19-
end;
19+
RUBY
2020
Ractor.shareable?(a).should == true
2121
Ractor.shareable?(b).should == false
2222
Ractor.shareable?(c).should == true
2323
end
2424

25-
it 'raises an error whenn shared constant is not a literal' do
26-
-> { Class.new.class_eval("#{<<~"begin;"}\n#{<<~'end;'}", /unshareable expression/) }.should raise_error
27-
begin;
25+
it "raises an error when shared constant is not a literal" do
26+
-> { Class.new.class_eval(<<~RUBY, __FILE__, __LINE__ + 1) }.should raise_error(Ractor::IsolationError, "cannot assign unshareable object to C")
2827
# shareable_constant_value: literal
2928
C = ["Not " + "shareable"]
30-
end;
29+
RUBY
3130
end
3231
end
3332
end

0 commit comments

Comments
 (0)