aboutsummaryrefslogtreecommitdiffstats
path: root/test/strscan
diff options
context:
space:
mode:
authorKenta Murata <mrkn@users.noreply.github.com>2020-12-17 18:29:21 +0900
committerKenta Murata <mrkn@mrkn.jp>2020-12-18 14:25:41 +0900
commit985f0af2576c4b4f9f4e75dce7299ba9d55d9419 (patch)
tree252a2cad5a81e803279da82949d7b701ea846c37 /test/strscan
parentcfa124ef05e1b899c1953888c0fb3076388a0d8e (diff)
downloadruby-985f0af2576c4b4f9f4e75dce7299ba9d55d9419.tar.gz
[strscan] Make strscan Ractor safe (#17)
* Make strscan Ractor safe * Add test-unit in the development dependencies https://github.com/ruby/strscan/commit/3c93c2bebe
Diffstat (limited to 'test/strscan')
-rw-r--r--test/strscan/test_ractor.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/strscan/test_ractor.rb b/test/strscan/test_ractor.rb
new file mode 100644
index 0000000000..0d44242304
--- /dev/null
+++ b/test/strscan/test_ractor.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+require 'test/unit'
+
+class TestStringScannerRactor < Test::Unit::TestCase
+ def setup
+ skip unless defined? Ractor
+ end
+
+ def test_ractor
+ assert_in_out_err([], <<-"end;", ["stra", " ", "strb", " ", "strc"], [])
+ require "strscan"
+ $VERBOSE = nil
+ r = Ractor.new do
+ s = StringScanner.new("stra strb strc", true)
+ [
+ s.scan(/\\w+/),
+ s.scan(/\\s+/),
+ s.scan(/\\w+/),
+ s.scan(/\\s+/),
+ s.scan(/\\w+/),
+ s.scan(/\\w+/),
+ s.scan(/\\w+/)
+ ]
+ end
+ puts r.take.compact
+ end;
+ end
+end