mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Scribunto: Allow int for find
parameter [#802]
This commit is contained in:
parent
59d8a42b22
commit
c801e3a20b
@ -1,6 +1,6 @@
|
||||
/*
|
||||
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,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,12 +13,33 @@ 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.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.objects.strings.unicodes.*;
|
||||
import gplx.core.intls.*; import gplx.langs.regxs.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.xtns.scribunto.procs.*;
|
||||
import gplx.xowa.xtns.scribunto.libs.patterns.*;
|
||||
package gplx.xowa.xtns.scribunto.libs;
|
||||
|
||||
import gplx.Bool_;
|
||||
import gplx.Err_;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.Io_url;
|
||||
import gplx.Keyval;
|
||||
import gplx.Keyval_;
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.String_;
|
||||
import gplx.langs.regxs.Regx_adp;
|
||||
import gplx.langs.regxs.Regx_adp_;
|
||||
import gplx.langs.regxs.Regx_group;
|
||||
import gplx.langs.regxs.Regx_match;
|
||||
import gplx.objects.strings.unicodes.Ustring;
|
||||
import gplx.objects.strings.unicodes.Ustring_;
|
||||
import gplx.xowa.Xoa_page_;
|
||||
import gplx.xowa.xtns.scribunto.Scrib_core;
|
||||
import gplx.xowa.xtns.scribunto.Scrib_kv_utl_;
|
||||
import gplx.xowa.xtns.scribunto.Scrib_lib;
|
||||
import gplx.xowa.xtns.scribunto.Scrib_lua_mod;
|
||||
import gplx.xowa.xtns.scribunto.libs.patterns.Scrib_pattern_matcher;
|
||||
import gplx.xowa.xtns.scribunto.procs.Scrib_proc_args;
|
||||
import gplx.xowa.xtns.scribunto.procs.Scrib_proc_mgr;
|
||||
import gplx.xowa.xtns.scribunto.procs.Scrib_proc_rslt;
|
||||
|
||||
public class Scrib_lib_ustring implements Scrib_lib {
|
||||
public Scrib_lib_ustring(Scrib_core core) {this.core = core;} private Scrib_core core;
|
||||
public String Key() {return "mw.ustring";}
|
||||
@ -113,7 +134,8 @@ public class Scrib_lib_ustring implements Scrib_lib {
|
||||
public boolean Match(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
// get args
|
||||
String text_str = args.Xstr_str_or_null(0); // Module can pass raw ints; PAGE:en.w:Budget_of_the_European_Union; DATE:2015-01-22
|
||||
String find_str = args.Cast_str_or_null(1);
|
||||
// 2019-20-01|ISSUE#:802|passing integer should return NULL, not throw error
|
||||
String find_str = args.Xstr_str_or_null(1);
|
||||
int bgn_as_codes_base1 = args.Cast_int_or(2, 1);
|
||||
|
||||
// validate / adjust
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
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,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@ -13,8 +13,16 @@ 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.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import org.junit.*; import gplx.xowa.xtns.scribunto.engines.mocks.*;
|
||||
package gplx.xowa.xtns.scribunto.libs;
|
||||
|
||||
import gplx.Keyval_;
|
||||
import gplx.String_;
|
||||
import gplx.xowa.xtns.scribunto.Scrib_kv_utl_;
|
||||
import gplx.xowa.xtns.scribunto.Scrib_lib;
|
||||
import gplx.xowa.xtns.scribunto.engines.mocks.Mock_scrib_fxt;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Scrib_lib_ustring__match__tst {
|
||||
private final Mock_scrib_fxt fxt = new Mock_scrib_fxt(); private Scrib_lib lib;
|
||||
@Before public void init() {
|
||||
@ -50,7 +58,9 @@ public class Scrib_lib_ustring__match__tst {
|
||||
@Test public void Unicode_alpha() {// ISSUE#:502; DATE:2019-07-01
|
||||
Exec_match("ä" , "%a", 1, "ä");
|
||||
}
|
||||
|
||||
@Test public void Number() {// 2019-20-01|ISSUE#:802|passing integer should return NULL, not throw error
|
||||
Exec_match_obj("A" , 0, 0, String_.Null_mark);
|
||||
}
|
||||
|
||||
// @Test public void Match_viwiktionary() {
|
||||
// fxt.Init_cbk(Scrib_core.Key_mw_interface, fxt.Core().Lib_ustring(), Scrib_lib_ustring.Invk_match);
|
||||
@ -60,4 +70,7 @@ public class Scrib_lib_ustring__match__tst {
|
||||
private void Exec_match(Object text, String regx, int bgn, String expd) {
|
||||
fxt.Test__proc__kvps__flat(lib, Scrib_lib_ustring.Invk_match, Scrib_kv_utl_.base1_many_(text, regx, bgn), expd);
|
||||
}
|
||||
private void Exec_match_obj(Object text, Object regx, int bgn, String expd) {
|
||||
fxt.Test__proc__kvps__flat(lib, Scrib_lib_ustring.Invk_match, Scrib_kv_utl_.base1_many_(text, regx, bgn), expd);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user