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