-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Unable to parse negative number in Norwegian #287
Comments
I can't seem to reproduce this. Because your feature is in Norwegian, Cuucmber uses the So you should be able to run this without any problems: import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Locale;
public class LocaleTest {
public static void main(String[] args) throws ParseException {
Locale locale = Locale.forLanguageTag("no");
NumberFormat format = DecimalFormat.getNumberInstance(locale);
Number parsed = format.parse("-2,11");
System.out.println(parsed);
}
} Which leads me to think that perhaps your editor replaced To debug this, you can put a breakpoint in the cucumber-expressions/java/src/main/java/io/cucumber/cucumberexpressions/NumberParser.java Lines 9 to 22 in 3366223
Btw, using |
No, it's definitely ASCII 45. The entire string is I noticed that when using the debugger to feed a unicode minus sign (U+2212) to |
Mmh. I tested this on |
|
Looks like a variation of https://bugs.openjdk.org/browse/JDK-8298849. For my Native dutch the hypen is used. Do Norwegian keyboards have a dedicated key for the minus sign or is that just the hypen? |
No, it's impossible to type the minus sign using any sane method. Everyone just uses the normal hyphen (ascii 45). |
Oh that is just lovely. This also applies to:
So I'm half minded to override the minus sign to a dash when it is used. |
That will probably work. It looks like it needs to be a hyphen in order to be recognized as a parameter anyway, i.e., replacing the hyphen with a unicode minus in the Gherkin file doesn't work. |
The DecimalFormatSymbols for Norwegian and 59 other languages use the minus-sign (unicode 8722) instead of the hyphen-minus sign (ascii 45). While technically correct, Gherkin is written on regular keyboards and there is no practical way to write a minus-sign. By patching the `DecimalFormatSymbols` with a regular minus sign we solve this problem. Additionally, for the same reason, the non-breaking space (ascii 160) and right single quotation mark (unicode 8217) for thousands separators are also patched with either a period or colon. Fixes: #287
The DecimalFormatSymbols for Norwegian and 59 other languages use the minus-sign (unicode 8722) instead of the hyphen-minus sign (ascii 45). While technically correct, Gherkin is written on regular keyboards and there is no practical way to write a minus-sign. By patching the `DecimalFormatSymbols` with a regular minus sign we solve this problem. Additionally, for the same reason, the non-breaking space (ascii 160) and right single quotation mark (unicode 8217) for thousands separators are also patched with either a period or colon. Fixes: #287
The DecimalFormatSymbols for Norwegian and 59 other languages use the minus-sign (unicode 8722) instead of the hyphen-minus sign (ascii 45). While technically correct, Gherkin is written on regular keyboards and there is no practical way to write a minus-sign. By patching the `DecimalFormatSymbols` with a regular minus sign we solve this problem. Additionally, for the same reason, the non-breaking space (ascii 160) and right single quotation mark (unicode 8217) for thousands separators are also patched with either a period or colon. Fixes: #287
Cheers good point. I presume you also don't use a non-breaking space to separate thousands? |
The DecimalFormatSymbols for Norwegian and 59 other languages use the minus-sign (unicode 8722) instead of the hyphen-minus sign (ascii 45). While technically correct, Gherkin is written on regular keyboards and there is no practical way to write a minus-sign. By patching the `DecimalFormatSymbols` with a regular minus sign we solve this problem. Additionally, for the same reason, the non-breaking space (ascii 160) and right single quotation mark (unicode 8217) for thousands separators are also patched with either a period or colon. Fixes: #287
That's correct, it has the same problem with not being possible to type on a keyboard, so only the most techically minded people will use it in practice. Using a regular space isn't uncommon, though, as is using a period. |
Thanks for the explanation. The fix should be in the latest version of |
Attempting to use a negative number in a step that expects a
{double}
, in a test case written in Norwegian, doesn't work.Minimal example:
👓 What did you see?
Cucumber is unable to parse the number:
✅ What did you expect to see?
The text should be parsed to double value
-2.11
.📦 Which tool/library version are you using?
Cucumber-java 12.15
The text was updated successfully, but these errors were encountered: