Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions language/regexp/character_classes_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../fixtures/classes', __FILE__)

Expand Down Expand Up @@ -607,4 +608,26 @@
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