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