-
Notifications
You must be signed in to change notification settings - Fork 30.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util.isDeepStrictEqual regex comparison #28766
Comments
Not saying the existing behavior is right or wrong, but it does behave as documented. The |
Yes, I saw that and yes it behaves as described. And yes, I guess it is a question of "is this behaviour correct for strictly comparing regexes"? They are similar, but you would get a different result from using them. |
This is an interesting edge case. It would be good to know how other assertion libraries work. In some cases it'll likely be good to distinguish the regular expression based on |
These days many are deferring to the Node isDeepStrictEqual spec, so this is becoming the measuring stick. In my own previous library I compared |
How about to add an option parameter for this function? e.g. assert.deepStrictEqual(a, b, { supportRegexp: true }); |
At worst, document the edge case and say that the developer must perform this check if necessary?
|
Compare the `lastIndex` property of regular expressions next to the flags and source property. Fixes: nodejs#28766 Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
Compare the `lastIndex` property of regular expressions next to the flags and source property. Fixes: nodejs#28766 Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de>
Compare the `lastIndex` property of regular expressions next to the flags and source property. Fixes: #28766 Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> PR-URL: #41020 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Compare the `lastIndex` property of regular expressions next to the flags and source property. Fixes: nodejs#28766 Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> PR-URL: nodejs#41020 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
v10.14.1
Mac OS Darwin Kernel Version 18.6.0
My expectation would have been
false
. I see thatareSimilarRegExps
does not perform a check onlastIndex
, andkeyCheck
performs a comparison of enumerable keys, andlastIndex
is not enumerable. This may be considered correct, but it feels wrong to me.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
Thankyou for your time and consideration.
The text was updated successfully, but these errors were encountered: