[regexp] Expand test coverage for sequence properties
Port the remaining tests from: https://chromium-review.googlesource.com/c/v8/v8/+/1227974/1/test/mjsunit/harmony/regexp-property-emoji-flag-sequence-generated.js#9 Bug: v8:7467 Change-Id: Ib187c93cb38befbbba31bdf93a0f5d8f1bee3d13 Reviewed-on: https://chromium-review.googlesource.com/1230098 Reviewed-by: Mathias Bynens <mathias@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Commit-Queue: Mathias Bynens <mathias@chromium.org> Cr-Commit-Position: refs/heads/master@{#56083}
This commit is contained in:
parent
3424fb9b05
commit
1b7abc42be
@ -9,13 +9,13 @@ assertDoesNotThrow("/\\p{Emoji_Flag_Sequence}/u");
|
||||
assertTrue(/\p{Emoji_Flag_Sequence}/u.test("\u{1F1E9}\u{1F1EA}"));
|
||||
|
||||
assertDoesNotThrow("/\\p{Emoji_Keycap_Sequence}/u");
|
||||
assertTrue(/\p{Emoji_Keycap_Sequence}/u.test("\u0023\ufe0f\u20e3"));
|
||||
assertTrue(/\p{Emoji_Keycap_Sequence}/u.test("\u0023\uFE0F\u20E3"));
|
||||
|
||||
assertDoesNotThrow("/\\p{Emoji_Keycap_Sequence}/u");
|
||||
assertFalse(/\p{Emoji_Keycap_Sequence}/u.test("\u0022\ufe0f\u20e3"));
|
||||
assertFalse(/\p{Emoji_Keycap_Sequence}/u.test("\u0022\uFE0F\u20E3"));
|
||||
|
||||
assertDoesNotThrow("/\\p{Emoji_Modifier_Sequence}/u");
|
||||
assertTrue(/\p{Emoji_Modifier_Sequence}/u.test("\u26f9\u{1f3ff}"));
|
||||
assertTrue(/\p{Emoji_Modifier_Sequence}/u.test("\u26F9\u{1F3FF}"));
|
||||
|
||||
assertDoesNotThrow("/\\p{Emoji_ZWJ_Sequence}/u");
|
||||
assertTrue(/\p{Emoji_ZWJ_Sequence}/u.test("\u{1F468}\u{200D}\u{1F467}"));
|
||||
@ -27,10 +27,34 @@ assertTrue(/\p{Emoji_Flag_Sequence}/.test("\\p{Emoji_Flag_Sequence}"));
|
||||
|
||||
// Negated and/or inside a character class.
|
||||
assertThrows("/\\P{Emoji_Flag_Sequence}/u");
|
||||
assertThrows("/\\P{Emoji_Keycap_Sequence}/u");
|
||||
assertThrows("/\\P{Emoji_Modifier_Sequence}/u");
|
||||
assertThrows("/\\P{Emoji_Tag_Sequence}/u");
|
||||
assertThrows("/\\P{Emoji_ZWJ_Sequence}/u");
|
||||
|
||||
assertThrows("/[\\p{Emoji_Flag_Sequence}]/u");
|
||||
assertThrows("/[\\p{Emoji_Keycap_Sequence}]/u");
|
||||
assertThrows("/[\\p{Emoji_Modifier_Sequence}]/u");
|
||||
assertThrows("/[\\p{Emoji_Tag_Sequence}]/u");
|
||||
assertThrows("/[\\p{Emoji_ZWJ_Sequence}]/u");
|
||||
|
||||
assertThrows("/[\\P{Emoji_Flag_Sequence}]/u");
|
||||
assertThrows("/[\\P{Emoji_Keycap_Sequence}]/u");
|
||||
assertThrows("/[\\P{Emoji_Modifier_Sequence}]/u");
|
||||
assertThrows("/[\\P{Emoji_Tag_Sequence}]/u");
|
||||
assertThrows("/[\\P{Emoji_ZWJ_Sequence}]/u");
|
||||
|
||||
assertThrows("/[\\w\\p{Emoji_Flag_Sequence}]/u");
|
||||
assertThrows("/[\\w\\p{Emoji_Keycap_Sequence}]/u");
|
||||
assertThrows("/[\\w\\p{Emoji_Modifier_Sequence}]/u");
|
||||
assertThrows("/[\\w\\p{Emoji_Tag_Sequence}]/u");
|
||||
assertThrows("/[\\w\\p{Emoji_ZWJ_Sequence}]/u");
|
||||
|
||||
assertThrows("/[\\w\\P{Emoji_Flag_Sequence}]/u");
|
||||
assertThrows("/[\\w\\P{Emoji_Keycap_Sequence}]/u");
|
||||
assertThrows("/[\\w\\P{Emoji_Modifier_Sequence}]/u");
|
||||
assertThrows("/[\\w\\P{Emoji_Tag_Sequence}]/u");
|
||||
assertThrows("/[\\w\\P{Emoji_ZWJ_Sequence}]/u");
|
||||
|
||||
// Two regional indicators, but not a country.
|
||||
assertFalse(/\p{Emoji_Flag_Sequence}/u.test("\u{1F1E6}\u{1F1E6}"));
|
||||
@ -42,16 +66,23 @@ assertFalse(/\p{Emoji_ZWJ_Sequence}/u.test("\u{1F467}\u{200D}\u{1F468}"));
|
||||
assertEquals(
|
||||
["country flag: \u{1F1E6}\u{1F1F9}"],
|
||||
/Country Flag: \p{Emoji_Flag_Sequence}/iu.exec(
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austra"));
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austria"));
|
||||
assertEquals(
|
||||
["country flag: \u{1F1E6}\u{1F1F9}", "\u{1F1E6}\u{1F1F9}"],
|
||||
/Country Flag: (\p{Emoji_Flag_Sequence})/iu.exec(
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austra"));
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austria"));
|
||||
assertEquals(
|
||||
["country flag: \u{1F1E6}\u{1F1F9}"],
|
||||
/Country Flag: ..(?<=\p{Emoji_Flag_Sequence})/iu.exec(
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austra"));
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austria"));
|
||||
assertEquals(
|
||||
["flag: \u{1F1E6}\u{1F1F9}", "\u{1F1E6}\u{1F1F9}"],
|
||||
/Flag: ..(?<=(\p{Emoji_Flag_Sequence})|\p{Emoji_Keycap_Sequence})/iu.exec(
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austra"));
|
||||
"this is an example of a country flag: \u{1F1E6}\u{1F1F9} is Austria"));
|
||||
|
||||
// Partial sequences.
|
||||
assertFalse(/\p{Emoji_Flag_Sequence}/u.test("\u{1F1E6}_"));
|
||||
assertFalse(/\p{Emoji_Keycap_Sequence}/u.test("2\uFE0F_"));
|
||||
assertFalse(/\p{Emoji_Modifier_Sequence}/u.test("\u261D_"));
|
||||
assertFalse(/\p{Emoji_Tag_Sequence}/u.test("\u{1F3F4}\u{E0067}\u{E0062}\u{E0065}\u{E006E}\u{E0067}_"));
|
||||
assertFalse(/\p{Emoji_ZWJ_Sequence}/u.test("\u{1F468}\u200D\u2764\uFE0F\u200D_"));
|
||||
|
Loading…
Reference in New Issue
Block a user