diff options
Diffstat (limited to 'spec/ruby/language/regexp/character_classes_spec.rb')
-rw-r--r-- | spec/ruby/language/regexp/character_classes_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/ruby/language/regexp/character_classes_spec.rb b/spec/ruby/language/regexp/character_classes_spec.rb index 74568a0beb..ce66d8e65f 100644 --- a/spec/ruby/language/regexp/character_classes_spec.rb +++ b/spec/ruby/language/regexp/character_classes_spec.rb @@ -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 |