summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
authorQuang-Minh Nguyen <nguyenquangminh0711@gmail.com>2020-09-18 13:02:14 +0700
committerKoichi Sasada <ko1@atdot.net>2020-09-20 23:10:44 +0900
commit398da71175ef9154be505155c0b1c0b2efb20445 (patch)
tree1a06a4e5c65e15c40f3a55649eedd2b8bc7d93f0 /bootstraptest
parentd5fa66156ab116df558448402b93c9c129b30291 (diff)
Validate name during initialization
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3555
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/test_ractor.rb50
1 files changed, 33 insertions, 17 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index 4b6afc2c53..9cfd42c5f4 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -8,6 +8,37 @@ assert_equal 'Ractor', %q{
Ractor.new{}.class
}
+# A Ractor can have a name
+assert_equal 'test-name', %q{
+ r = Ractor.new name: 'test-name' do
+ end
+ r.name
+}
+
+# If Ractor doesn't have a name, Ractor#name returns nil.
+assert_equal 'nil', %q{
+ r = Ractor.new do
+ end
+ r.name.inspect
+}
+
+# Raises exceptions if initialize with invalid name
+assert_equal 'no implicit conversion of Array into String', %q{
+ begin
+ r = Ractor.new(name: [{}]) {}
+ rescue TypeError => e
+ e.message
+ end
+}
+
+assert_equal 'ASCII incompatible encoding (UTF-16BE)', %q{
+ begin
+ r = Ractor.new(name: String.new('Invalid encoding', encoding: 'UTF-16BE')) {}
+ rescue ArgumentError => e
+ e.message
+ end
+}
+
# Ractor.new must call with a block
assert_equal "must be called with a block", %q{
begin
@@ -263,7 +294,7 @@ assert_equal 'false', %q{
r = Ractor.new obj do |msg|
msg.object_id
end
-
+
obj.object_id == r.take
}
@@ -360,7 +391,7 @@ assert_equal 'hello', %q{
str = r.take
begin
- r.take
+ r.take
rescue Ractor::RemoteError
str #=> "hello"
end
@@ -528,20 +559,6 @@ assert_equal '[1000, 3]', %q{
Ractor.new{ [A.size, H.size] }.take
}
-# A Ractor can have a name
-assert_equal 'test-name', %q{
- r = Ractor.new name: 'test-name' do
- end
- r.name
-}
-
-# If Ractor doesn't have a name, Ractor#name returns nil.
-assert_equal 'nil', %q{
- r = Ractor.new do
- end
- r.name.inspect
-}
-
###
### Synchronization tests
###
@@ -559,4 +576,3 @@ assert_equal "#{N}#{N}", %Q{
}
end # if !ENV['GITHUB_WORKFLOW']
-