Skip to content

scan behaves on JRuby 9.4 differently from MRI  #45

@k77ch7

Description

@k77ch7

Environment Information
jruby -v

jruby 9.4.0.0-SNAPSHOT (3.1.0) 2022-07-11 99fe5ca788 OpenJDK 64-Bit Server VM 11.0.13+8-Ubuntu-0ubuntu1.20.04 on 11.0.13+8-Ubuntu-0ubuntu1.20.04 +jit [x86_64-linux]

Expected Behavior

require 'strscan'

s = StringScanner.new('test string')
s.scan(/\w(\w)(\w*)/) # => "test"
s[0]                  # => "test"
s[1]                  # => "e"
s[2]                  # => "st"
s.scan(/\w+/)         # => nil
s[0]                  # => nil
s[1]                  # => nil
s[2]                  # => nil
s.scan(/\s+/)         # => " "
s[0]                  # => " "
s[1]                  # => nil
s[2]                  # => nil
s.scan(/\w(\w)(\w*)/) # => "string"
s[0]                  # => "string"
s[1]                  # => "t"
s[2]                  # => "ring"

Actual Behavior(jruby 9.4.0.0-SNAPSHOT and strscan-3.0.3-java.gem)

require 'strscan'

s = StringScanner.new('test string')
s.scan(/\w(\w)(\w*)/) # => "test"
s[0]                  # => "test"
s[1]                  # => "e"
s[2]                  # => "st"
s.scan(/\w+/)         # => nil
s[0]                  # => nil
s[1]                  # => nil
s[2]                  # => nil
s.scan(/\s+/)         # => " "
s[0]                  # => " "
s[1]                  # => "s"
s[2]                  # => "tr"
s.scan(/\w(\w)(\w*)/) # => "string"
s[0]                  # => "string"
s[1]                  # => "t"
s[2]                  # => "ring"

I found this behavior by jruby/jruby#7247 .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions