You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The present issue concerns the "option" argument. One of the possible option is "ignorePunctuation" that can be true/false.
It seems that the documented behavior of this option (see link above) is not respected when we use it inside a karate scenario.
For example, running these scenarios with the latest release of karate.jar (1.3.1):
Scenario: success and behaves as expected
* def value1 = "abc";
* def value2 = "abc";
And match value1.localeCompare(value2, "en", { ignorePunctuation: true }) == 0
Scenario: success but do not behaves as expected
* def value1 = "abc";
* def value2 = "a,bc";
And match value1.localeCompare(value2, "en", { ignorePunctuation: true }) == 1
(both scenarios are passing)
We can see that introducing punctuation changes the result of the function but should not.
Trying with other locales or other punctuation signs does not have an effect.
because the JS engine is Graal and it does have some quirks. for this use-case I recommend using the JDK locale helpers via Java interop. I am tagging this issue as help wanted
Hello,
When comparing 2 strings for sorting purposes, we use the function localeCompare.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
This function takes 3 arguments:
The present issue concerns the "option" argument. One of the possible option is "ignorePunctuation" that can be true/false.
It seems that the documented behavior of this option (see link above) is not respected when we use it inside a karate scenario.
For example, running these scenarios with the latest release of karate.jar (1.3.1):
(both scenarios are passing)
We can see that introducing punctuation changes the result of the function but should not.
Trying with other locales or other punctuation signs does not have an effect.
I tried the function on nodejs v16.18.1:
and the results are as expected.
Why is the javascript called by karate behaves differently than the one we use outside?
Thanks
The text was updated successfully, but these errors were encountered: