mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
ParserFunctions: Fail if e0
or pi0
[#819]
This commit is contained in:
parent
b1c52aa2b2
commit
7d357540c7
@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
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.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
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.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.exprs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import gplx.core.btries.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*;
|
||||
@ -113,6 +113,7 @@ public class Pfunc_expr_shunter {
|
||||
if (cur_prc.Func_is_const()) { // func is "pi" or "e"; DATE:2014-03-01
|
||||
if (mode_expr) { // number expected; just call Calc (which will place value on stack)
|
||||
cur_prc.Calc(ctx, this, val_stack);
|
||||
mode_expr = false; // 2020-11-25|ISSUE#:819|Set mode_expr to false which forces next term to be operator not number. EX: `pi0` -> fails
|
||||
break;
|
||||
}
|
||||
else // operator expected; fail b/c pi / e is not an operator;
|
||||
@ -121,6 +122,9 @@ public class Pfunc_expr_shunter {
|
||||
if (mode_expr) { // NOTE: all the GetAlts have higher precedence; "break;" need to skip evaluation below else will fail for --1
|
||||
Func_tkn alt_prc = cur_prc.GetAlt();
|
||||
prc_stack.Push(alt_prc);
|
||||
if (alt_prc == Func_tkn_e_const.Instance) {
|
||||
mode_expr = false; // 2020-11-25|ISSUE#:819|Set mode_expr to false which forces next term to be operator not number. EX: `e0` -> fails
|
||||
}
|
||||
break;
|
||||
}
|
||||
prv_prc = prc_stack.Get_at_last();
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
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.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
|
||||
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.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
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
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.xtns.pfuncs.exprs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.pfuncs.*;
|
||||
import org.junit.*;
|
||||
public class Pfunc_expr_tst {
|
||||
@ -115,4 +115,10 @@ public class Pfunc_expr_tst {
|
||||
@Test public void Num_precision() {// PURPOSE: number should be set to precision of 14; PAGE:de.wikipedia.org/wiki/Nationalpark_Mu_Ko_Ang_Thong ISSUE#:683 DATE:2020-03-24
|
||||
fxt.Test__parse__tmpl_to_html("{{#expr:15.064329981401556}}", "15.064329981402"); // fails if 15.06432998140155
|
||||
}
|
||||
@Test public void Const_e_suffix_should_fail() { // 2020-11-25|ISSUE#:819|Do not interpret 'e0' as 'e'; EX: e0 x> 2.71828
|
||||
fxt.Test_parse_page_tmpl_str("{{#expr:e0}}", "<strong class=\"error\">Expression error: Unexpected number</strong>");
|
||||
}
|
||||
@Test public void Const_pi_suffix_should_fail() { // 2020-11-25|ISSUE#:819|Do not interpret 'pi0' as 'pi'; EX: e0 x> 3.141529
|
||||
fxt.Test_parse_page_tmpl_str("{{#expr:pi0}}", "<strong class=\"error\">Expression error: Unexpected number</strong>");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user