Skip to content

Commit f85beb7

Browse files
committed
Add unit tests, refactor to remove DecodeInto variants from Utf8Codex
1 parent a468a07 commit f85beb7

File tree

17 files changed

+153
-77
lines changed

17 files changed

+153
-77
lines changed

bin/NativeTests/FileLoadHelpers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ HRESULT FileLoadHelpers::LoadScriptFromFile(LPCSTR filename, LPCWSTR& contents,
99
{
1010
HRESULT hr = S_OK;
1111
LPCWSTR contentsRaw = nullptr;
12-
byte * pRawBytes = nullptr;
12+
LPCUTF8 pRawBytes = nullptr;
1313
UINT lengthBytes = 0;
1414
bool isUtf8 = false;
1515
contents = nullptr;
@@ -119,7 +119,7 @@ HRESULT FileLoadHelpers::LoadScriptFromFile(LPCSTR filename, LPCWSTR& contents,
119119
IfFailGo(E_OUTOFMEMORY);
120120
}
121121

122-
utf8::DecodeIntoAndNullTerminate((char16*) contents, pRawBytes, pRawBytes + lengthBytes, cUtf16Chars, decodeOptions);
122+
utf8::DecodeUnitsIntoAndNullTerminate((char16*)contents, pRawBytes, pRawBytes + lengthBytes, decodeOptions);
123123
}
124124

125125
Error:

lib/Common/Codex/Utf8Codex.cpp

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -376,40 +376,9 @@ namespace utf8
376376
else
377377
return ptr;
378378
}
379-
380-
void DecodeInto(__out_ecount_full(cch) char16 *buffer, LPCUTF8 ptr, LPCUTF8 end, size_t cch, DecodeOptions options)
381-
{
382-
DecodeOptions localOptions = options;
383-
384-
if (!ShouldFastPath(ptr, buffer)) goto LSlowPath;
385-
386-
LFastPath:
387-
while (cch >= 4)
388-
{
389-
uint32 bytes = *(uint32 *)ptr;
390-
if ((bytes & 0x80808080) != 0) goto LSlowPath;
391-
((uint32 *)buffer)[0] = (bytes & 0x7F) | ((bytes << 8) & 0x7F0000);
392-
((uint32 *)buffer)[1] = ((bytes >> 16) & 0x7F) | ((bytes >> 8) & 0x7F0000);
393-
ptr += 4;
394-
buffer += 4;
395-
cch -= 4;
396-
}
397-
LSlowPath:
398-
while (cch-- > 0)
399-
{
400-
*buffer++ = Decode(ptr, end, localOptions);
401-
if (ShouldFastPath(ptr, buffer)) goto LFastPath;
402-
}
403-
}
404-
405-
void DecodeIntoAndNullTerminate(__out_ecount(cch+1) __nullterminated char16 *buffer, LPCUTF8 ptr, LPCUTF8 end, size_t cch, DecodeOptions options)
406-
{
407-
DecodeInto(buffer, ptr, end, cch, options);
408-
buffer[cch] = 0;
409-
}
410-
411-
_Ret_range_(0, pbEnd - _Old_(pbUtf8))
412-
size_t DecodeUnitsInto(_Out_writes_(pbEnd - pbUtf8) char16 *buffer, LPCUTF8& pbUtf8, LPCUTF8 pbEnd, DecodeOptions options)
379+
380+
_Use_decl_annotations_
381+
size_t DecodeUnitsInto(char16 *buffer, LPCUTF8& pbUtf8, LPCUTF8 pbEnd, DecodeOptions options)
413382
{
414383
DecodeOptions localOptions = options;
415384

@@ -454,13 +423,20 @@ namespace utf8
454423
return dest - buffer;
455424
}
456425

457-
size_t DecodeUnitsIntoAndNullTerminate(__out_ecount(pbEnd - pbUtf8 + 1) __nullterminated char16 *buffer, LPCUTF8& pbUtf8, LPCUTF8 pbEnd, DecodeOptions options)
426+
_Use_decl_annotations_
427+
size_t DecodeUnitsIntoAndNullTerminate(char16 *buffer, LPCUTF8& pbUtf8, LPCUTF8 pbEnd, DecodeOptions options)
458428
{
459429
size_t result = DecodeUnitsInto(buffer, pbUtf8, pbEnd, options);
460430
buffer[(int)result] = 0;
461431
return result;
462432
}
463433

434+
_Use_decl_annotations_
435+
size_t DecodeUnitsIntoAndNullTerminateNoAdvance(char16 *buffer, LPCUTF8 pbUtf8, LPCUTF8 pbEnd, DecodeOptions options)
436+
{
437+
return DecodeUnitsIntoAndNullTerminate(buffer, pbUtf8, pbEnd, options);
438+
}
439+
464440
bool CharsAreEqual(__in_ecount(cch) LPCOLESTR pch, LPCUTF8 bch, LPCUTF8 end, size_t cch, DecodeOptions options)
465441
{
466442
DecodeOptions localOptions = options;

lib/Common/Codex/Utf8Codex.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -273,28 +273,15 @@ namespace utf8
273273
return PrevCharFull(ptr, start);
274274
}
275275

276-
// Decode a UTF-8 sequence of cch UTF-16 characters into buffer. ptr could advance up to 3 times
277-
// longer than cch so DecodeInto should only be used when it is already known that
278-
// ptr refers to at least cch number of UTF-8 sequences.
279-
void DecodeInto(__out_ecount_full(cch) char16 *buffer, LPCUTF8 ptr, LPCUTF8 end, size_t cch, DecodeOptions options = doDefault);
280-
281-
// Provided for dual-mode templates
282-
inline void DecodeInto(__out_ecount_full(cch) char16 *buffer, const char16 *ptr, const char16 *end, size_t cch, DecodeOptions /* options */ = doDefault)
283-
{
284-
Unused(end);
285-
memcpy_s(buffer, cch * sizeof(char16), ptr, cch * sizeof(char16));
286-
}
287-
288-
// Like DecodeInto but ensures buffer ends with a NULL at buffer[cch].
289-
void DecodeIntoAndNullTerminate(__out_ecount(cch+1) __nullterminated char16 *buffer, LPCUTF8 ptr, LPCUTF8 end, size_t cch, DecodeOptions options = doDefault);
290-
291276
// Decode cb bytes from ptr to into buffer returning the number of characters converted and written to buffer
292277
_Ret_range_(0, pbEnd - _Old_(pbUtf8))
293278
size_t DecodeUnitsInto(_Out_writes_(pbEnd - pbUtf8) char16 *buffer, LPCUTF8& pbUtf8, LPCUTF8 pbEnd, DecodeOptions options = doDefault);
294279

295280
// Decode cb bytes from ptr to into buffer returning the number of characters converted and written to buffer (excluding the null terminator)
296281
size_t DecodeUnitsIntoAndNullTerminate(__out_ecount(pbEnd - pbUtf8 + 1) __nullterminated char16 *buffer, LPCUTF8& pbUtf8, LPCUTF8 pbEnd, DecodeOptions options = doDefault);
297282

283+
size_t DecodeUnitsIntoAndNullTerminateNoAdvance(__out_ecount(pbEnd - pbUtf8 + 1) __nullterminated char16 *buffer, LPCUTF8 pbUtf8, LPCUTF8 pbEnd, DecodeOptions options = doDefault);
284+
298285
// Encode a UTF-8 sequence into a UTF-8 sequence (which is just a memcpy). This is included for convenience in templates
299286
// when the character encoding is a template parameter.
300287
__range(cch, cch)

lib/Common/Codex/Utf8Helper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ namespace utf8
7373
// Some node tests depend on the utf8 decoder not swallowing invalid unicode characters
7474
// instead of replacing them with the "replacement" chracter. Pass a flag to our
7575
// decoder to require such behavior
76-
utf8::DecodeIntoAndNullTerminate(destString, (LPCUTF8) sourceString, (LPCUTF8) sourceString + cbSourceString, cchDestString, DecodeOptions::doAllowInvalidWCHARs);
76+
utf8::DecodeUnitsIntoAndNullTerminateNoAdvance(destString, (LPCUTF8) sourceString, (LPCUTF8) sourceString + cbSourceString, DecodeOptions::doAllowInvalidWCHARs);
7777
Assert(destString[cchDestString] == 0);
7878
static_assert(sizeof(utf8char_t) == sizeof(char), "Needs to be valid for cast");
7979
*destStringPtr = destString;

lib/Jsrt/JsrtDebugUtils.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,19 @@ void JsrtDebugUtils::AddSourceLengthAndTextToObject(Js::DynamicObject* object, J
6161
LPCUTF8 source = functionBody->GetStartOfDocument(_u("Source for debugging"));
6262
size_t cbLength = functionBody->GetUtf8SourceInfo()->GetCbLength();
6363
size_t startByte = utf8::CharacterIndexToByteIndex(source, cbLength, (const charcount_t)statementMap->sourceSpan.begin);
64+
size_t endByte = utf8::CharacterIndexToByteIndex(source, cbLength, (const charcount_t)statementMap->sourceSpan.end);
65+
int cch = statementMap->sourceSpan.end - statementMap->sourceSpan.begin;
6466

65-
int byteLength = statementMap->sourceSpan.end - statementMap->sourceSpan.begin;
67+
JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::sourceLength, (double)cch, functionBody->GetScriptContext());
6668

67-
JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::sourceLength, (double)byteLength, functionBody->GetScriptContext());
68-
69-
AutoArrayPtr<char16> sourceContent(HeapNewNoThrowArray(char16, byteLength + 1), byteLength + 1);
69+
AutoArrayPtr<char16> sourceContent(HeapNewNoThrowArray(char16, cch + 1), cch + 1);
7070
if (sourceContent != nullptr)
7171
{
72+
LPCUTF8 pbStart = source + startByte;
73+
LPCUTF8 pbEnd = pbStart + (endByte - startByte);
7274
utf8::DecodeOptions options = functionBody->GetUtf8SourceInfo()->IsCesu8() ? utf8::doAllowThreeByteSurrogates : utf8::doDefault;
73-
utf8::DecodeIntoAndNullTerminate(sourceContent, source + startByte, source + startByte + cbLength, byteLength, options);
74-
JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::sourceText, sourceContent, byteLength, functionBody->GetScriptContext());
75+
utf8::DecodeUnitsIntoAndNullTerminate(sourceContent, pbStart, pbEnd, options);
76+
JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::sourceText, sourceContent, cch, functionBody->GetScriptContext());
7577
}
7678
else
7779
{
@@ -96,7 +98,7 @@ void JsrtDebugUtils::AddSouceToObject(Js::DynamicObject * object, Js::Utf8Source
9698
LPCUTF8 source = utf8SourceInfo->GetSource();
9799
size_t cbLength = utf8SourceInfo->GetCbLength();
98100
utf8::DecodeOptions options = utf8SourceInfo->IsCesu8() ? utf8::doAllowThreeByteSurrogates : utf8::doDefault;
99-
utf8::DecodeIntoAndNullTerminate(sourceContent, source, source + cbLength, cchLength, options);
101+
utf8::DecodeUnitsIntoAndNullTerminate(sourceContent, source, source + cbLength, options);
100102
JsrtDebugUtils::AddPropertyToObject(object, JsrtDebugPropertyId::source, sourceContent, cchLength, utf8SourceInfo->GetScriptContext());
101103
}
102104
else

lib/Parser/Hash.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,8 @@ class HashTbl
434434
}
435435
static void CopyString(__in_ecount(cch + 1) LPOLESTR psz1, LPCUTF8 psz2, LPCUTF8 psz2end, int32 cch)
436436
{
437-
utf8::DecodeIntoAndNullTerminate(psz1, psz2, psz2end, cch);
437+
Unused(cch);
438+
utf8::DecodeUnitsIntoAndNullTerminate(psz1, psz2, psz2end);
438439
}
439440
static void CopyString(__in_ecount(cch + 1) LPOLESTR psz1, __in_ecount(cch) char const * psz2, char const * psz2end, int32 cch)
440441
{

lib/Parser/Scan.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,12 +2516,13 @@ HRESULT Scanner<EncodingPolicy>::SysAllocErrorLine(int32 ichMinLine, __out BSTR*
25162516
}
25172517

25182518
typename EncodingPolicy::EncodedCharPtr pStart = static_cast<size_t>(ichMinLine) == IchMinLine() ? m_pchMinLine : m_pchBase + this->CharacterOffsetToUnitOffset(m_pchBase, m_currentCharacter, m_pchLast, ichMinLine);
2519-
typename EncodingPolicy::EncodedCharPtr pEnd = AdjustedLast();
25202519

25212520
// Determine the length by scanning for the next newline
2522-
charcount_t cch = LineLength(pStart, pEnd);
2521+
charcount_t cch = LineLength(pStart, m_pchLast);
25232522
Assert(cch <= LONG_MAX);
25242523

2524+
typename EncodingPolicy::EncodedCharPtr pEnd = static_cast<size_t>(ichMinLine) == IchMinLine() ? m_pchMinLine + cch : m_pchBase + this->CharacterOffsetToUnitOffset(m_pchBase, m_currentCharacter, m_pchLast, cch);
2525+
25252526
*pbstrLine = SysAllocStringLen(NULL, cch);
25262527
if (!*pbstrLine)
25272528
{

lib/Parser/Scan.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class UTF8EncodingPolicyBase
294294
void ConvertToUnicode(__out_ecount_full(cch) LPOLESTR pch, charcount_t cch, EncodedCharPtr start, EncodedCharPtr end)
295295
{
296296
m_decodeOptions = (utf8::DecodeOptions)(m_decodeOptions & ~utf8::doSecondSurrogatePair);
297-
utf8::DecodeInto(pch, start, end, cch, m_decodeOptions);
297+
utf8::DecodeUnitsInto(pch, start, end, m_decodeOptions);
298298
}
299299

300300

lib/Runtime/Base/Utf8SourceInfo.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,22 @@ namespace Js
7878
void RetrieveSourceText(__out_ecount_full(cchLim - cchMin) LPOLESTR cpText, charcount_t cchMin, charcount_t cchLim) const
7979
{
8080
size_t cbLength = GetCbLength(_u("Utf8SourceInfo::RetrieveSourceText"));
81-
LPCUTF8 pSource = GetSource(_u("Utf8SourceInfo::RetrieveSourceText"));
82-
size_t cbMin = cbLength == GetCchLength() ? cchMin : utf8::CharacterIndexToByteIndex(pSource, cbLength, cchMin, utf8::doAllowThreeByteSurrogates);
81+
LPCUTF8 source = GetSource(_u("Utf8SourceInfo::RetrieveSourceText"));
82+
LPCUTF8 pbStart = nullptr;
83+
LPCUTF8 pbEnd = nullptr;
8384

84-
utf8::DecodeInto(cpText, pSource + cbMin, pSource + cbMin + cbLength, cchLim - cchMin, utf8::doAllowThreeByteSurrogates);
85+
if (cbLength == GetCchLength())
86+
{
87+
pbStart = source + cchMin;
88+
pbEnd = source + cchLim;
89+
}
90+
else
91+
{
92+
pbStart = source + utf8::CharacterIndexToByteIndex(source, cbLength, cchMin, utf8::doAllowThreeByteSurrogates);
93+
pbEnd = source + utf8::CharacterIndexToByteIndex(source, cbLength, cchLim, utf8::doAllowThreeByteSurrogates);
94+
}
95+
96+
utf8::DecodeUnitsInto(cpText, pbStart, pbEnd, utf8::doAllowThreeByteSurrogates);
8597
}
8698

8799
size_t CharacterIndexToByteIndex(charcount_t cchIndex) const

lib/Runtime/Language/DynamicProfileStorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ _Success_(return) bool DynamicProfileStorageReaderWriter::ReadUtf8String(__deref
110110
return false;
111111
}
112112

113-
utf8char_t * tempBuffer = NoCheckHeapNewArray(utf8char_t, urllen);
113+
utf8char_t* tempBuffer = NoCheckHeapNewArray(utf8char_t, urllen);
114114
if (tempBuffer == nullptr)
115115
{
116116
Output::Print(_u("ERROR: DynamicProfileStorage: Out of memory reading '%s'\n"), filename);
@@ -133,7 +133,7 @@ _Success_(return) bool DynamicProfileStorageReaderWriter::ReadUtf8String(__deref
133133
HeapDeleteArray(urllen, tempBuffer);
134134
return false;
135135
}
136-
utf8::DecodeIntoAndNullTerminate(name, tempBuffer, tempBuffer + urllen, length);
136+
utf8::DecodeUnitsIntoAndNullTerminateNoAdvance(name, tempBuffer, tempBuffer + urllen);
137137
NoCheckHeapDeleteArray(urllen, tempBuffer);
138138
*str = name;
139139
*len = length;

lib/Runtime/Library/JavascriptFunction.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3058,7 +3058,9 @@ void __cdecl _alloca_probe_16()
30583058
charcount_t count = min(DIAG_MAX_FUNCTION_STRING, func->LengthInChars());
30593059
utf8::DecodeOptions options = sourceInfo->IsCesu8() ? utf8::doAllowThreeByteSurrogates : utf8::doDefault;
30603060
LPCUTF8 source = func->GetSource(_u("JavascriptFunction::GetDiagValueString"));
3061-
utf8::DecodeInto(stringBuilder->AllocBufferSpace(count), source, source + sourceInfo->GetCbLength(_u("JavascriptFunction::GetDiagValueString")), count, options);
3061+
size_t cbLength = sourceInfo->GetCbLength(_u("JavascriptFunction::GetDiagValueString"));
3062+
size_t cbIndex = utf8::CharacterIndexToByteIndex(source, cbLength, count, options);
3063+
utf8::DecodeUnitsInto(stringBuilder->AllocBufferSpace(count), source, source + cbIndex, options);
30623064
stringBuilder->IncreaseCount(count);
30633065
return TRUE;
30643066
}

lib/Runtime/Library/ScriptFunction.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,12 @@ namespace Js
483483
// Consider: Should we have a JavascriptUtf8Substring class which defers decoding
484484
// until it's needed?
485485

486-
BufferStringBuilder builder(pFuncBody->LengthInChars(), scriptContext);
487-
// TODO: What about surrogate pairs?
486+
charcount_t cch = pFuncBody->LengthInChars();
487+
size_t cbLength = pFuncBody->LengthInBytes();
488+
LPCUTF8 pbStart = pFuncBody->GetSource(_u("ScriptFunction::EnsureSourceString"));
489+
BufferStringBuilder builder(cch, scriptContext);
488490
utf8::DecodeOptions options = pFuncBody->GetUtf8SourceInfo()->IsCesu8() ? utf8::doAllowThreeByteSurrogates : utf8::doDefault;
489-
LPCUTF8 ptr = pFuncBody->GetSource(_u("ScriptFunction::EnsureSourceString"));
490-
size_t cbLength = pFuncBody->GetUtf8SourceInfo()->GetCbLength(_u("ScriptFunction::EnsureSourceString"));
491-
utf8::DecodeInto(builder.DangerousGetWritableBuffer(), ptr, ptr + cbLength, pFuncBody->LengthInChars(), options);
491+
utf8::DecodeUnitsInto(builder.DangerousGetWritableBuffer(), pbStart, pbStart + cbLength, options);
492492
if (pFuncBody->IsLambda() || isActiveScript || this->GetFunctionInfo()->IsClassConstructor()
493493
#ifdef ENABLE_PROJECTION
494494
|| scriptContext->GetConfig()->IsWinRTEnabled()

lib/WasmReader/WasmBinaryReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ WasmBinaryReader::CvtUtf8Str(LPCUTF8 name, uint32 nameLen, charcount_t* dstLengt
10191019
{
10201020
Js::Throw::OutOfMemory();
10211021
}
1022-
utf8::DecodeIntoAndNullTerminate(contents, name, name + nameLen, utf16Len, decodeOptions);
1022+
utf8::DecodeUnitsIntoAndNullTerminate(contents, name, name + nameLen, decodeOptions);
10231023
if (dstLength)
10241024
{
10251025
*dstLength = utf16Len;

test/utf8/bugGH2386.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
function toHexCP(c, cp) {
7+
var hex = "0123456789abcdef";
8+
return String.fromCharCode(hex.charCodeAt((c >> (cp * 4)) & 0xf));
9+
}
10+
11+
function toHex(str) {
12+
var result = "";
13+
for(var i = 0; i < str.length; i++) {
14+
var c = str.charCodeAt(i);
15+
for (var cp = 3; cp >= 0; cp--) {
16+
result += toHexCP(c, cp);
17+
}
18+
}
19+
return "0x" + result;
20+
}
21+
22+
var CHECK = function(h)
23+
{
24+
var hex_str = String.fromCharCode(h);
25+
var pattern = eval("/" + hex_str + "/");
26+
if (toHex(hex_str) != toHex(pattern.source)) {
27+
throw new Error("String encoding has failed? "
28+
+ toHex(hex_str) + " != " + toHex(pattern.source));
29+
}
30+
}
31+
32+
CHECK("0x0000");
33+
CHECK("0x0080");
34+
CHECK("0x0800");
35+
CHECK("0xFF80");
36+
CHECK("0xFFFD");
37+
CHECK("0xFFFFFF");
38+
CHECK("0xFFFFFF80");
39+
CHECK("0xFFFFFF80FF");
40+
41+
function CHECK_EVAL(s)
42+
{
43+
var eval_s = new RegExp( s ).source;
44+
if (s !== eval_s) throw new Error(
45+
"String Encoding is broken ? ->" + s);
46+
}
47+
48+
var CH1 = String.fromCharCode('0xe4b8ad');
49+
var CH2 = String.fromCharCode('0xe69687');
50+
var CH3 = String.fromCharCode('0xe336b2');
51+
var CH4 = String.fromCharCode('0xe336b2aa');
52+
var CHX = String.fromCharCode("0x80808080");
53+
54+
var BUFF = '';
55+
for(var i = 0; i < 16; i++)
56+
{
57+
var str = CH1;
58+
59+
CHECK_EVAL(str + CHX + BUFF)
60+
CHECK_EVAL(str + BUFF + CHX)
61+
CHECK_EVAL(str + BUFF + CHX + '1')
62+
str += BUFF + CH2 + CHX;
63+
BUFF += '1';
64+
65+
CHECK_EVAL(str + '1' + CH3);
66+
CHECK_EVAL(str + '12' + CH3);
67+
CHECK_EVAL(str + '123' + CH3);
68+
69+
CHECK_EVAL(str + '1' + CH4);
70+
CHECK_EVAL(str + '12' + CH4);
71+
CHECK_EVAL(str + '123' + CH4)
72+
}
73+
74+
console.log("PASS");

test/utf8/rlexe.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,17 @@
2020
<baseline />
2121
</default>
2222
</test>
23+
<test>
24+
<default>
25+
<files>bugGH2386.js</files>
26+
<baseline />
27+
</default>
28+
</test>
29+
<test>
30+
<default>
31+
<files>unicode_sequence_serialized.js</files>
32+
<baseline />
33+
<compile-flags>-forceserialized -oopjit-</compile-flags>
34+
</default>
35+
</test>
2336
</regress-exe>

test/utf8/surrogatepair.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,9 @@
77
// For this test case to work, please save this file with UTF-8 encoding
88
var y = "function () { '鄏�莞�遲��屢��箋成鄏賴旭鄑收鄏擒�鄏賴忖 鄏兒江鄏眇成鄑戍鄍�' ;WScript.Echo('hello'); }"
99
var x = function () { '鄏�莞�遲��屢��箋成鄏賴旭鄑收鄏擒�鄏賴忖 鄏兒江鄏眇成鄑戍鄍�' ;WScript.Echo('hello'); }
10-
WScript.Echo(x.toString() === y ? "PASS" : "FAIL");
10+
11+
// 2 bytes
12+
var y2 = "function () { ' kugu' ;WScript.Echo('hello'); }"
13+
var x2 = function () { ' kugu' ;WScript.Echo('hello'); }
14+
15+
WScript.Echo((x.toString() === y && x2.toString() === y2) ? "PASS" : "FAIL");
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(function () {
2+
/()/ ;
3+
})();

0 commit comments

Comments
 (0)