mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00

(https://github.com/ruby/strscan/pull/157)
This is same as https://github.com/ruby/stringio/pull/134
---------
141f9cf9b6
Co-authored-by: Koichi Sasada <ko1@atdot.net>
32 lines
771 B
Ruby
32 lines
771 B
Ruby
# frozen_string_literal: true
|
|
require 'test/unit'
|
|
|
|
class TestStringScannerRactor < Test::Unit::TestCase
|
|
def setup
|
|
omit("Ractor not defined") unless defined? Ractor
|
|
end
|
|
|
|
def test_ractor
|
|
assert_in_out_err([], <<-"end;", ["stra", " ", "strb", " ", "strc"], [])
|
|
class Ractor
|
|
alias value take unless method_defined? :value # compat with Ruby 3.4 and olders
|
|
end
|
|
|
|
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.value.compact
|
|
end;
|
|
end
|
|
end
|