mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Parser: Require coefficient for scientific notation [#795]
This commit is contained in:
parent
d3896bf547
commit
5f2e9c7514
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
XOWA: the XOWA Offline Wiki Application
|
XOWA: the XOWA Offline Wiki Application
|
||||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||||
|
|
||||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||||
or alternatively under the terms of the Apache License Version 2.0.
|
or alternatively under the terms of the Apache License Version 2.0.
|
||||||
@ -13,7 +13,14 @@ The terms of each license can be found in the source code repository:
|
|||||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
package gplx.core.primitives;
|
||||||
|
|
||||||
|
import gplx.Byte_ascii;
|
||||||
|
import gplx.Decimal_adp;
|
||||||
|
import gplx.Decimal_adp_;
|
||||||
|
import gplx.Int_;
|
||||||
|
import gplx.Math_;
|
||||||
|
|
||||||
public class Gfo_number_parser {
|
public class Gfo_number_parser {
|
||||||
public int Rv_as_int() {return (int)num_val;} private long num_val = 0;
|
public int Rv_as_int() {return (int)num_val;} private long num_val = 0;
|
||||||
public long Rv_as_long() {return num_val;}
|
public long Rv_as_long() {return num_val;}
|
||||||
@ -112,6 +119,7 @@ public class Gfo_number_parser {
|
|||||||
has_exp = true;
|
has_exp = true;
|
||||||
has_neg = false;
|
has_neg = false;
|
||||||
has_plus = false; // allow +1E+2
|
has_plus = false; // allow +1E+2
|
||||||
|
has_num = false; // 2020-09-07|ISSUE#:795|scientific notation requires coefficient; set has_num to false which will fail below if no coefficient
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Byte_ascii.Ltr_A:
|
case Byte_ascii.Ltr_A:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
XOWA: the XOWA Offline Wiki Application
|
XOWA: the XOWA Offline Wiki Application
|
||||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||||
|
|
||||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||||
or alternatively under the terms of the Apache License Version 2.0.
|
or alternatively under the terms of the Apache License Version 2.0.
|
||||||
@ -13,8 +13,15 @@ The terms of each license can be found in the source code repository:
|
|||||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||||
*/
|
*/
|
||||||
package gplx.core.primitives; import gplx.*; import gplx.core.*;
|
package gplx.core.primitives;
|
||||||
import org.junit.*;
|
|
||||||
|
import gplx.Bry_;
|
||||||
|
import gplx.Decimal_adp;
|
||||||
|
import gplx.Decimal_adp_;
|
||||||
|
import gplx.Tfds;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class Gfo_number_parser_tst {
|
public class Gfo_number_parser_tst {
|
||||||
@Before public void init() {fxt.Clear();} private final Gfo_number_parser_fxt fxt = new Gfo_number_parser_fxt();
|
@Before public void init() {fxt.Clear();} private final Gfo_number_parser_fxt fxt = new Gfo_number_parser_fxt();
|
||||||
@Test public void Integer() {
|
@Test public void Integer() {
|
||||||
@ -42,6 +49,7 @@ public class Gfo_number_parser_tst {
|
|||||||
fxt.Test_dec("1.234E-2", Decimal_adp_.parse(".01234"));
|
fxt.Test_dec("1.234E-2", Decimal_adp_.parse(".01234"));
|
||||||
fxt.Test_dec("123.4E-2", Decimal_adp_.parse("1.234"));
|
fxt.Test_dec("123.4E-2", Decimal_adp_.parse("1.234"));
|
||||||
fxt.Test_dec("+6.0E-3", Decimal_adp_.parse(".006"));
|
fxt.Test_dec("+6.0E-3", Decimal_adp_.parse(".006"));
|
||||||
|
fxt.Test_err("e24", true); // 2020-09-07|ISSUE#:795|scientific notation requires coefficient
|
||||||
}
|
}
|
||||||
@Test public void Err() {
|
@Test public void Err() {
|
||||||
fxt.Test_err("+", true);
|
fxt.Test_err("+", true);
|
||||||
|
Loading…
Reference in New Issue
Block a user