Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Fix the RegExp restoration tests #316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ghostd
Copy link

@ghostd ghostd commented Aug 13, 2018

I chose to copy the results before the assertions. Another fix would be to disable this code by setting the NODE_DISABLE_COLORS variable. But IMHO that'd still be flaky.

@ghostd ghostd mentioned this pull request Aug 13, 2018
@ghostd ghostd mentioned this pull request Sep 14, 2018
@luiz
Copy link

luiz commented Feb 27, 2019

Hi, @ghostd! Thanks for this PR. I've tested it here and it fixes a test that was failing, but still fails another.

Normally, RegExp.lastMatch should be cached and restored
 > ERROR: expected value foo but the actual value is xterm-256

I found that a similar fix has to be applied at tests/disableregexprestore.js.

--- a/tests/disableregexprestore.js
+++ b/tests/disableregexprestore.js
@@ -26,8 +26,10 @@ new IntlPolyfill.NumberFormat('en-US', {
     currency: 'GBP',
     minimumFractionDigits: 2,
 });
-assertEqual(RegExp.input, 'a foo test', 'Normally, RegExp.input should be cached and restored');
-assertEqual(RegExp.lastMatch, 'foo', 'Normally, RegExp.lastMatch should be cached and restored');
+var actualInput = RegExp.input;
+var actualLastMatch = RegExp.lastMatch;
+assertEqual(actualInput, 'a foo test', 'Normally, RegExp.input should be cached and restored');
+assertEqual(actualLastMatch, 'foo', 'Normally, RegExp.lastMatch should be cached and restored');
 
 // Issues #231
 /function[\s\S]+(})/.exec('function defineProperty\\(\\) \\{\n    \\[native code\\]\n\\}');
@@ -36,8 +38,10 @@ new IntlPolyfill.NumberFormat('en-US', {
     currency: 'GBP',
     minimumFractionDigits: 2,
 });
-assertEqual(RegExp.input, 'function defineProperty\\(\\) \\{\n    \\[native code\\]\n\\}', 'Normally, RegExp.input should be cached and restored');
-assertEqual(RegExp.lastMatch, 'function defineProperty\\(\\) \\{\n    \\[native code\\]\n\\}', 'Normally, RegExp.lastMatch should be cached and restored');
+actualInput = RegExp.input;
+actualLastMatch = RegExp.lastMatch;
+assertEqual(actualInput, 'function defineProperty\\(\\) \\{\n    \\[native code\\]\n\\}', 'Normally, RegExp.input should be cached and restored');
+assertEqual(actualLastMatch, 'function defineProperty\\(\\) \\{\n    \\[native code\\]\n\\}', 'Normally, RegExp.lastMatch should be cached and restored');
 
 IntlPolyfill.__disableRegExpRestore();
 /foo/.exec('a foo test');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants