/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
bool testUtf8() { // Bad unit with nothing before it. staticconstchar badLeadingUnit[] = "\x80";
CHECK(testOmittedWindow(badLeadingUnit, JSMSG_BAD_LEADING_UTF8_UNIT, "0x80"));
// Bad unit at start of a fresh line. staticconstchar badStartingFreshLine[] = "var x = 5;\n\x98";
CHECK(testOmittedWindow(badStartingFreshLine, JSMSG_BAD_LEADING_UTF8_UNIT, "0x98"));
// Bad trailing unit in initial code point. staticconstchar badTrailingUnit[] = "\xD8\x20";
CHECK(testOmittedWindow(badTrailingUnit, JSMSG_BAD_TRAILING_UTF8_UNIT, "0xD8 0x20"));
// Bad trailing unit at start of a fresh line. staticconstchar badTrailingUnitFreshLine[] = "var x = 5;\n\xD8\x20";
CHECK(testOmittedWindow(badTrailingUnitFreshLine,
JSMSG_BAD_TRAILING_UTF8_UNIT, "0xD8 0x20"));
// Overlong at start of a fresh line. staticconstchar overlongFreshLine[] = "var x = 5;\n\xC0\x81";
CHECK(testOmittedWindow(overlongFreshLine, JSMSG_FORBIDDEN_UTF8_CODE_POINT, "0xC0 0x81"));
// Not-enough at start of a fresh line. staticconstchar notEnoughFreshLine[] = "var x = 5;\n\xF0";
CHECK(testOmittedWindow(notEnoughFreshLine, JSMSG_NOT_ENOUGH_CODE_UNITS, "0xF0"));
returntrue;
}
bool testUtf16() { // Bad unit with nothing before it. staticconst char16_t badLeadingUnit[] = u"\xDFFF";
CHECK(testOmittedWindow(badLeadingUnit, JSMSG_ILLEGAL_CHARACTER));
// Bad unit at start of a fresh line. staticconst char16_t badStartingFreshLine[] = u"var x = 5;\n\xDFFF";
CHECK(testOmittedWindow(badStartingFreshLine, JSMSG_ILLEGAL_CHARACTER));
// The prefix ought always be the same. static constexpr char expectedPrefix[] = "the code units comprising this invalid code point were: ";
constexpr size_t expectedPrefixLen = js_strlen(expectedPrefix);
CHECK(startsWith(noteMessage, expectedPrefix));
// The end of the prefix is the bad code units.
CHECK(equals(noteMessage + expectedPrefixLen, badCodeUnits));
// UTF-16 encoding "errors" are not categorical errors, so the errors // are just of the invalid-character sort, without an accompanying note // spelling out a series of invalid code units.
CHECK(!badCodeUnits);
}
CHECK(!errorReport->linebuf());
returntrue;
}
END_TEST(testEmptyWindow)
¤ Dauer der Verarbeitung: 0.14 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.