1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
eregon 2017-10-28 15:15:48 +00:00
parent 6530b14cee
commit 8c5b60eb22
218 changed files with 4069 additions and 328 deletions

View file

@ -1,3 +1,4 @@
# coding: utf-8
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)
@ -607,4 +608,26 @@ describe "Regexp with character classes" do
it "matches unicode Hangul properties" do
"루비(Ruby)".match(/\p{Hangul}+/u).to_a.should == ["루비"]
end
ruby_version_is "2.4" do
it "supports \\X (unicode 9.0 with UTR #51 workarounds)" do
# simple emoji without any fancy modifier or ZWJ
/\X/.match("\u{1F98A}").to_a.should == ["🦊"]
# skin tone modifier
/\X/.match("\u{1F918}\u{1F3FD}").to_a.should == ["🤘🏽"]
# emoji joined with ZWJ
/\X/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}").to_a.should == ["🏳️‍🌈"]
/\X/.match("\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}").to_a.should == ["👩‍👩‍👧‍👦"]
# without the ZWJ
/\X+/.match("\u{1F3F3}\u{FE0F}\u{1F308}").to_a.should == ["🏳️🌈"]
/\X+/.match("\u{1F469}\u{1F469}\u{1F467}\u{1F466}").to_a.should == ["👩👩👧👦"]
# both of the ZWJ combined
/\X+/.match("\u{1F3F3}\u{FE0F}\u{200D}\u{1F308}\u{1F469}\u{200D}\u{1F469}\u{200D}\u{1F467}\u{200D}\u{1F466}")
.to_a.should == ["🏳️‍🌈👩‍👩‍👧‍👦"]
end
end
end

View file

@ -39,6 +39,13 @@ describe "Regexps with modifers" do
lambda { eval('/foo/a') }.should raise_error(SyntaxError)
end
ruby_version_is "2.4" do
it "supports (?~) (absent operator)" do
Regexp.new("(?~foo)").match("hello").to_a.should == ["hello"]
"foo".scan(Regexp.new("(?~foo)")).should == ["fo","o",""]
end
end
it "supports (?imx-imx) (inline modifiers)" do
/(?i)foo/.match("FOO").to_a.should == ["FOO"]
/foo(?i)/.match("FOO").should be_nil