spec/unicode_emoji_spec.rb in unicode-emoji-3.6.0 vs spec/unicode_emoji_spec.rb in unicode-emoji-3.7.0

- old
+ new

@@ -214,10 +214,15 @@ it "matches valid tag sequences, even though they are not recommended" do "🏴󠁧󠁒󠁑󠁧󠁒󠁿 GB AGB" =~ Unicode::Emoji::REGEX_VALID assert_equal "🏴󠁧󠁒󠁑󠁧󠁒󠁿", $& end + it "matches valid tag sequences (compressed one)" do + "πŸ΄σ ¬σ Άσ €°σ €΄σ €²σ Ώ lv042" =~ Unicode::Emoji::REGEX_VALID + assert_equal "πŸ΄σ ¬σ Άσ €°σ €΄σ €²σ Ώ", $& + end + it "does not match invalid tag sequences" do "🏴󠁧󠁒󠁑󠁑󠁑󠁿 GB AAA" =~ Unicode::Emoji::REGEX_VALID assert_equal "🏴", $& # only base flag is matched end @@ -304,21 +309,131 @@ it "matches valid tag sequences, even though they are not recommended" do "🏴󠁧󠁒󠁑󠁧󠁒󠁿 GB AGB" =~ Unicode::Emoji::REGEX_WELL_FORMED assert_equal "🏴󠁧󠁒󠁑󠁧󠁒󠁿", $& end - it "does match invalid tag sequences" do + it "matches invalid base tag sequences" do "😴󠁧󠁒󠁑󠁑󠁑󠁿 GB AAA" =~ Unicode::Emoji::REGEX_WELL_FORMED assert_equal "😴󠁧󠁒󠁑󠁑󠁑󠁿", $& end + it "does not match too long tag sequences (only black flag is matched)" do + "🏴󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁿 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" =~ Unicode::Emoji::REGEX_WELL_FORMED + assert_equal "🏴", $& + end + + it "does not match invalid tag sequences (only black flag is matched)" do + "πŸ΄σ €€σ Ώ $" =~ Unicode::Emoji::REGEX_WELL_FORMED + assert_equal "🏴", $& + end + it "matches recommended zwj sequences" do "πŸ€ΎπŸ½β€β™€οΈ woman playing handball: medium skin tone" =~ Unicode::Emoji::REGEX_WELL_FORMED assert_equal "πŸ€ΎπŸ½β€β™€οΈ", $& end it "matches valid zwj sequences, even though they are not recommended" do "πŸ€ β€πŸ€’ vomiting cowboy" =~ Unicode::Emoji::REGEX_WELL_FORMED + assert_equal "πŸ€ β€πŸ€’", $& + end + end + + describe "REGEX_POSSIBLE" do + it "matches most singleton emoji codepoints" do + "😴 sleeping face" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "😴", $& + end + + it "matches singleton emoji in combination with emoji variation selector" do + "😴\u{FE0F} sleeping face" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "😴\u{FE0F}", $& + end + + it "matches singleton emoji (without VS) when in combination with text variation selector" do + "😴\u{FE0E} sleeping face" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "😴", $& + end + + it "matches textual singleton emoji" do + "β–Ά play button" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "β–Ά", $& + end + + it "matches textual singleton emoji in combination with emoji variation selector" do + "β–Ά\u{FE0F} play button" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "β–Ά\u{FE0F}", $& + end + + it "matches singleton 'component' emoji codepoints" do + "🏻 light skin tone" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "🏻", $& + end + + it "matches modified emoji if modifier base emoji is used" do + "πŸ›ŒπŸ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "πŸ›ŒπŸ½", $& + end + + it "matches modified emoji even if no modifier base emoji is used" do + "🌡🏽 cactus" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "🌡🏽", $& + end + + it "matches valid region flags" do + "πŸ‡΅πŸ‡Ή Portugal" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "πŸ‡΅πŸ‡Ή", $& + end + + it "does match invalid region flags" do + "πŸ‡΅πŸ‡΅ PP Land" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "πŸ‡΅πŸ‡΅", $& + end + + it "matches emoji keycap sequences" do + "2️⃣ keycap: 2" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "2️⃣", $& + end + + it "matches only digit of non-emoji keycap sequences" do + "8⃣ text keycap: 8" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "8", $& + + "#⃣ text keycap: #" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "#", $& + end + + it "matches recommended tag sequences" do + "🏴󠁧󠁒󠁳󠁣󠁴󠁿 Scotland" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "🏴󠁧󠁒󠁳󠁣󠁴󠁿", $& + end + + it "matches valid tag sequences, even though they are not recommended" do + "🏴󠁧󠁒󠁑󠁧󠁒󠁿 GB AGB" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "🏴󠁧󠁒󠁑󠁧󠁒󠁿", $& + end + + it "matches invalid base tag sequences" do + "😴󠁧󠁒󠁑󠁑󠁑󠁿 GB AAA" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "😴󠁧󠁒󠁑󠁑󠁑󠁿", $& + end + + it "matches too long tag sequences" do + "🏴󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁿 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "🏴󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁁󠁿", $& + end + + it "machtes invalid tag sequences (only black flag is matched)" do + "πŸ΄σ €€σ Ώ $" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "πŸ΄σ €€σ Ώ", $& + end + + it "matches recommended zwj sequences" do + "πŸ€ΎπŸ½β€β™€οΈ woman playing handball: medium skin tone" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "πŸ€ΎπŸ½β€β™€οΈ", $& + end + + it "matches valid zwj sequences, even though they are not recommended" do + "πŸ€ β€πŸ€’ vomiting cowboy" =~ Unicode::Emoji::REGEX_POSSIBLE assert_equal "πŸ€ β€πŸ€’", $& end end describe "REGEX_BASIC" do