spec/unicode_emoji_spec.rb in unicode-emoji-3.8.0 vs spec/unicode_emoji_spec.rb in unicode-emoji-4.0.0

- old
+ new

@@ -37,13 +37,24 @@ it "matches textual singleton emoji in combination with emoji variation selector" do "β–Ά\u{FE0F} play button" =~ Unicode::Emoji::REGEX assert_equal "β–Ά\u{FE0F}", $& end - it "does not match singleton 'component' emoji codepoints" do + it "matches singleton skin tone modifiers and hair components" do "🏻 light skin tone" =~ Unicode::Emoji::REGEX + assert_equal "🏻", $& + + "🦰 emoji component red hair" =~ Unicode::Emoji::REGEX + assert_equal "🦰", $& + end + + it "does not match singleton components that are not skin tone modifiers or hair components" do + "1 digit one" =~ Unicode::Emoji::REGEX assert_nil $& + + "πŸ‡¦ regional indicator symbol letter a" =~ Unicode::Emoji::REGEX + assert_nil $& end it "matches modified emoji if modifier base emoji is used" do "πŸ›ŒπŸ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX assert_equal "πŸ›ŒπŸ½", $& @@ -92,16 +103,16 @@ assert_equal "πŸ€ΎπŸ½β€β™€οΈ", $& end it "does not match MQE zwj sequences" do "πŸ€ΎπŸ½β€β™€ woman playing handball: medium skin tone, missing VS16" =~ Unicode::Emoji::REGEX - refute_equal `πŸ€ΎπŸ½β€β™€`, $& + refute_equal "πŸ€ΎπŸ½β€β™€", $& end it "does not match UQE emoji" do "πŸŒβ€β™‚οΈ man golfing, missing VS16" =~ Unicode::Emoji::REGEX - refute_equal `πŸŒβ€β™‚οΈ`, $& + refute_equal "πŸŒβ€β™‚οΈ", $& end it "does not match valid zwj sequences that are not recommended" do "πŸ€ β€πŸ€’ vomiting cowboy" =~ Unicode::Emoji::REGEX assert_equal "🀠", $& @@ -151,28 +162,28 @@ end describe "REGEX_INCLUDE_MQE" do it "matches MQE emoji" do "πŸ€ΎπŸ½β€β™€ woman playing handball: medium skin tone, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE - assert_equal `πŸ€ΎπŸ½β€β™€`, $& + assert_equal "πŸ€ΎπŸ½β€β™€", $& end it "does not match UQE emoji" do "πŸŒβ€β™‚οΈ man golfing, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE - refute_equal `πŸŒβ€β™‚οΈ`, $& + refute_equal "πŸŒβ€β™‚οΈ", $& end end describe "REGEX_INCLUDE_MQE_UQE" do it "matches MQE emoji" do "πŸ€ΎπŸ½β€β™€ woman playing handball: medium skin tone, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE_UQE - assert_equal `πŸ€ΎπŸ½β€β™€`, $& + assert_equal "πŸ€ΎπŸ½β€β™€", $& end it "matches UQE emoji" do "πŸŒβ€β™‚οΈ man golfing, missing VS16" =~ Unicode::Emoji::REGEX_INCLUDE_MQE_UQE - assert_equal `πŸŒβ€β™‚οΈ`, $& + assert_equal "πŸŒβ€β™‚οΈ", $& end end describe "REGEX_VALID" do it "matches most singleton emoji codepoints" do @@ -198,13 +209,24 @@ it "matches textual singleton emoji in combination with emoji variation selector" do "β–Ά\u{FE0F} play button" =~ Unicode::Emoji::REGEX_VALID assert_equal "β–Ά\u{FE0F}", $& end - it "does not match singleton 'component' emoji codepoints" do + it "matches singleton skin tone modifiers and hair components" do "🏻 light skin tone" =~ Unicode::Emoji::REGEX_VALID + assert_equal "🏻", $& + + "🦰 emoji component red hair" =~ Unicode::Emoji::REGEX_VALID + assert_equal "🦰", $& + end + + it "does not match singleton components that are not skin tone modifiers or hair components" do + "1 digit one" =~ Unicode::Emoji::REGEX_VALID assert_nil $& + + "πŸ‡¦ regional indicator symbol letter a" =~ Unicode::Emoji::REGEX_VALID + assert_nil $& end it "matches modified emoji if modifier base emoji is used" do "πŸ›ŒπŸ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX_VALID assert_equal "πŸ›ŒπŸ½", $& @@ -293,13 +315,24 @@ it "matches textual singleton emoji in combination with emoji variation selector" do "β–Ά\u{FE0F} play button" =~ Unicode::Emoji::REGEX_WELL_FORMED assert_equal "β–Ά\u{FE0F}", $& end - it "does not match singleton 'component' emoji codepoints" do + it "matches singleton skin tone modifiers and hair components" do "🏻 light skin tone" =~ Unicode::Emoji::REGEX_WELL_FORMED + assert_equal "🏻", $& + + "🦰 emoji component red hair" =~ Unicode::Emoji::REGEX_WELL_FORMED + assert_equal "🦰", $& + end + + it "does not match singleton components that are not skin tone modifiers or hair components" do + "1 digit one" =~ Unicode::Emoji::REGEX_WELL_FORMED assert_nil $& + + "πŸ‡¦ regional indicator symbol letter a" =~ Unicode::Emoji::REGEX_WELL_FORMED + assert_nil $& end it "matches modified emoji if modifier base emoji is used" do "πŸ›ŒπŸ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX_WELL_FORMED assert_equal "πŸ›ŒπŸ½", $& @@ -393,15 +426,26 @@ 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 + it "matches singleton skin tone modifiers and hair components" do "🏻 light skin tone" =~ Unicode::Emoji::REGEX_POSSIBLE assert_equal "🏻", $& + + "🦰 emoji component red hair" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "🦰", $& end + it "matches singleton components that are not skin tone modifiers or hair components" do + "1 digit one" =~ Unicode::Emoji::REGEX_POSSIBLE + assert_equal "1", $& + + "πŸ‡¦ regional indicator symbol letter a" =~ 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 @@ -484,22 +528,33 @@ "😴\u{FE0E} sleeping face" =~ Unicode::Emoji::REGEX_BASIC assert_nil $& end it "does not match textual singleton emoji" do - "β–Ά play button" =~ Unicode::Emoji::REGEX + "β–Ά play button" =~ Unicode::Emoji::REGEX_BASIC assert_nil $& end it "matches textual singleton emoji in combination with emoji variation selector" do - "β–Ά\u{FE0F} play button" =~ Unicode::Emoji::REGEX + "β–Ά\u{FE0F} play button" =~ Unicode::Emoji::REGEX_BASIC assert_equal "β–Ά\u{FE0F}", $& end - it "does not match singleton 'component' emoji codepoints" do + it "matches singleton skin tone modifiers and hair components" do "🏻 light skin tone" =~ Unicode::Emoji::REGEX_BASIC + assert_equal "🏻", $& + + "🦰 emoji component red hair" =~ Unicode::Emoji::REGEX_BASIC + assert_equal "🦰", $& + end + + it "does not match singleton components that are not skin tone modifiers or hair components" do + "1 digit one" =~ Unicode::Emoji::REGEX_BASIC assert_nil $& + + "πŸ‡¦ regional indicator symbol letter a" =~ Unicode::Emoji::REGEX_BASIC + assert_nil $& end it "does not match modified emoji" do "πŸ›ŒπŸ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX_BASIC assert_equal "πŸ›Œ", $& @@ -555,15 +610,26 @@ it "does not match textual singleton emoji in combination with emoji modifiers" do "✌🏻 victory hand" =~ Unicode::Emoji::REGEX_TEXT assert_nil $& end - it "does not match singleton 'component' emoji codepoints" do + it "does not match singleton skin tone modifiers and hair components" do "🏻 light skin tone" =~ Unicode::Emoji::REGEX_TEXT assert_nil $& + + "🦰 emoji component red hair" =~ Unicode::Emoji::REGEX_TEXT + assert_nil $& end + it "does not match singleton components that are not skin tone modifiers or hair components" do + "1 digit one" =~ Unicode::Emoji::REGEX_TEXT + assert_nil $& + + "πŸ‡¦ regional indicator symbol letter a" =~ Unicode::Emoji::REGEX_TEXT + assert_nil $& + end + it "does not match modified emoji" do "πŸ›ŒπŸ½ person in bed: medium skin tone" =~ Unicode::Emoji::REGEX_TEXT assert_nil $& end @@ -594,13 +660,28 @@ "πŸ€ΎπŸ½β€β™€οΈ woman playing handball: medium skin tone" =~ Unicode::Emoji::REGEX_TEXT assert_nil $& end end - describe "REGEX_ANY" do + describe "REGEX_PROP_EMOJI" do it "returns any emoji-related codepoint (but no variation selectors or tags)" do - matches = "1 string 😴\u{FE0F} sleeping face with πŸ‡΅ and modifier 🏾, also 🏴󠁧󠁒󠁳󠁣󠁴󠁿 Scotland".scan(Unicode::Emoji::REGEX_ANY) + matches = "1 string 😴\u{FE0F} sleeping face with πŸ‡΅ and modifier 🏾, also 🏴󠁧󠁒󠁳󠁣󠁴󠁿 Scotland".scan(Unicode::Emoji::REGEX_PROP_EMOJI) assert_equal ["1", "😴", "πŸ‡΅", "🏾", "🏴"], matches + end + end + + describe "REGEX_EMOJI_KEYCAP" do + it "matches emoji keycap sequences" do + "2️⃣ keycap: 2" =~ Unicode::Emoji::REGEX_EMOJI_KEYCAP + assert_equal "2️⃣", $& + end + + it "does not match non-emoji keycap sequences" do + "8⃣ text keycap: 8" =~ Unicode::Emoji::REGEX_EMOJI_KEYCAP + assert_nil $& + + "#⃣ text keycap: #" =~ Unicode::Emoji::REGEX_EMOJI_KEYCAP + assert_nil $& end end describe "REGEX_PICTO" do it "matches codepoints with Extended_Pictograph property (almost all emoji are, but also others)" do