Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

2.2 KB
Raw Blame
<!doctype html>
<meta charset="utf-8">
<body>
<script src="/wpt/resources/testharness.js"></script>
<script src="/wpt/resources/testharnessreport.js"></script>
<script src="/wpt/resources/moli-wpt-adapter.js"></script>
<script>
function textInput(value, pattern) {
  const input = document.createElement("input");
  input.type = "text";
  input.value = value;
  input.pattern = pattern;
  document.body.appendChild(input);
  return input;
}

test(function () {
  const singleCodePoint = textInput("βœ…", "\\p{RGI_Emoji}");
  assert_false(singleCodePoint.validity.patternMismatch, "single-code-point RGI emoji should satisfy the string property");
  assert_true(singleCodePoint.validity.valid, "matching emoji string property should keep the control valid");

  const familySequence = textInput("πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦", "\\p{RGI_Emoji}");
  assert_false(familySequence.validity.patternMismatch, "multi-code-point RGI emoji sequence should satisfy the string property");
}, "patternMismatch supports v-flag properties of strings");

test(function () {
  const plainText = textInput("moli", "\\p{RGI_Emoji}");
  assert_true(plainText.validity.patternMismatch, "plain text should not satisfy an RGI emoji string property");

  const repeatedEmoji = textInput("βœ…βœ…", "\\p{RGI_Emoji}");
  assert_true(repeatedEmoji.validity.patternMismatch, "whole-value matching should reject multiple emoji for a single string-property atom");
}, "patternMismatch applies whole-value matching to string-property atoms");

test(function () {
  const twoEmoji = textInput("βœ…βœ…", "(?:\\p{RGI_Emoji}){2}");
  assert_false(twoEmoji.validity.patternMismatch, "quantified string-property atoms should match repeated emoji sequences");
  assert_true(twoEmoji.validity.valid, "quantified string-property pattern should keep the control valid");

  const oneEmoji = textInput("βœ…", "(?:\\p{RGI_Emoji}){2}");
  assert_true(oneEmoji.validity.patternMismatch, "quantified string-property atoms should still enforce the count");

  const emojiAndText = textInput("βœ…x", "(?:\\p{RGI_Emoji}){2}");
  assert_true(emojiAndText.validity.patternMismatch, "quantified string-property atoms should reject non-emoji trailing text");
}, "patternMismatch supports quantifiers around v-flag string-property atoms");
</script>