This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: update ChakraCore to chakra-core/ChakraCore@0615a510f6
[1.8>1.9] [MERGE #4607 @boingoing] OS#14763260: Correctly update RegExp.$1 after RegExp.prototype.test matches and used a cached value Merge pull request #4607 from boingoing:FixRegExpTestCache Regression from chakra-core/ChakraCore#3802 - if we hit the cache, we don't update the Regex constructor object with the last match and so retrieving properties about the match from the regex constructor object fails. Fixed by adding an invalidation mechanism to the `JavascriptRegExpConstructor`. If we hit the cache, we'll mark the Regex constructor object last match properties as invalidated and we will then compute them on-demand the first time they're needed. Fixes: https://microsoft.visualstudio.com/web/wi.aspx?id=14763260 Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js"); | ||
|
||
var tests = [ | ||
{ | ||
name: "Verify last match invalidated as expected", | ||
body: function () { | ||
const r1 = /(abc)/; | ||
const r2 = /(def)/; | ||
const s1 = "abc"; | ||
const s2 = " def"; | ||
|
||
r1.test(s1); | ||
|
||
assert.areEqual("abc", RegExp.input, "RegExp.input property calculated correctly"); | ||
assert.areEqual("abc", RegExp['$_'], "RegExp.$_ property calculated correctly"); | ||
assert.areEqual("abc", RegExp.lastMatch, "RegExp.lastMatch property calculated correctly"); | ||
assert.areEqual("abc", RegExp['$&'], "RegExp.$& property calculated correctly"); | ||
assert.areEqual("abc", RegExp.$1, "RegExp.$1 property calculated correctly"); | ||
assert.areEqual(0, RegExp.index, "RegExp.index property calculated correctly"); | ||
|
||
r2.test(s2); | ||
|
||
assert.areEqual(" def", RegExp.input, "RegExp.input property calculated correctly"); | ||
assert.areEqual(" def", RegExp['$_'], "RegExp.$_ property calculated correctly"); | ||
assert.areEqual("def", RegExp.lastMatch, "RegExp.lastMatch property calculated correctly"); | ||
assert.areEqual("def", RegExp['$&'], "RegExp.$& property calculated correctly"); | ||
assert.areEqual("def", RegExp.$1, "RegExp.$1 property calculated correctly"); | ||
assert.areEqual(1, RegExp.index, "RegExp.index property calculated correctly"); | ||
|
||
r1.test(s1); | ||
|
||
assert.areEqual("abc", RegExp.input, "Stale RegExp.input property should be invalidated by second r1.test(s1)"); | ||
assert.areEqual("abc", RegExp['$_'], "Stale RegExp.$_ property should be invalidated by second r1.test(s1)"); | ||
assert.areEqual("abc", RegExp.lastMatch, "Stale RegExp.lastMatch should be invalidated by second r1.test(s1)"); | ||
assert.areEqual("abc", RegExp['$&'], "Stale RegExp.$& property should be invalidated by second r1.test(s1)"); | ||
assert.areEqual("abc", RegExp.$1, "Stale RegExp.$1 should be invalidated by second r1.test(s1)"); | ||
assert.areEqual(0, RegExp.index, "Stale RegExp.index property should be invalidated by second r1.test(s1)"); | ||
} | ||
}, | ||
]; | ||
|
||
testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters