mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Wikibase: Fix script error 'libraryUtil.lua:13 bad argument #1 to message.newRawMessage' on sever dozen military pages
This commit is contained in:
37
400_xowa/src/gplx/xowa/langs/msgs/Xol_msg_itm_tst.java
Normal file
37
400_xowa/src/gplx/xowa/langs/msgs/Xol_msg_itm_tst.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
public class Xol_msg_itm_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xol_msg_itm_fxt fxt = new Xol_msg_itm_fxt();
|
||||
@Test public void New_plain() {fxt.Test_new("a" , Bool_.N, Bool_.N);}
|
||||
@Test public void New_fmt() {fxt.Test_new("a~{0}b" , Bool_.Y, Bool_.N);}
|
||||
@Test public void New_tmpl() {fxt.Test_new("a{{b}}c" , Bool_.N, Bool_.Y);}
|
||||
@Test public void New_fmt_tmpl() {fxt.Test_new("a{{b}}c~{0}d" , Bool_.Y, Bool_.Y);}
|
||||
@Test public void New_space() {fxt.Test_val("a b" , "a b");}
|
||||
}
|
||||
class Xol_msg_itm_fxt {
|
||||
public void Clear() {}
|
||||
public void Test_new(String val, boolean has_fmt_arg, boolean has_tmpl_txt) {
|
||||
Xol_msg_itm itm = Xol_msg_itm_.new_(0, "test", val);
|
||||
Tfds.Eq(has_fmt_arg, itm.Has_fmt_arg(), "has_fmt_arg");
|
||||
Tfds.Eq(has_tmpl_txt, itm.Has_tmpl_txt(), "has_tmpl_txt");
|
||||
}
|
||||
public void Test_val(String val, String expd) {
|
||||
Xol_msg_itm itm = Xol_msg_itm_.new_(0, "test", val);
|
||||
Tfds.Eq(expd, String_.new_u8(itm.Val()), "has_fmt_arg");
|
||||
}
|
||||
}
|
||||
68
400_xowa/src/gplx/xowa/langs/msgs/Xol_msg_mgr_tst.java
Normal file
68
400_xowa/src/gplx/xowa/langs/msgs/Xol_msg_mgr_tst.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*; import gplx.core.tests.*; import gplx.xowa.langs.msgs.*;
|
||||
public class Xol_msg_mgr_tst {
|
||||
@Before public void init() {fxt.Clear();} private final Xol_msg_mgr_fxt fxt = new Xol_msg_mgr_fxt();
|
||||
@Test public void Template_msg() {fxt.Test_val_by_key("About {{SITENAME}}", "About Wikipedia");} // PURPOSE.fix: {{Template}} not working inside label tags; EX:de.wikisource.org; DATE:2013-02-10
|
||||
@Test public void Template_mediawiki() { // PURPOSE.fix: {{Template}} not working inside MediaWiki template
|
||||
fxt.Test_mediaWiki_msg("About {{SITENAME}}", "About Wikipedia");
|
||||
}
|
||||
@Test public void Val_html_accesskey_and_title() {
|
||||
fxt.Clear().Test_val_html_accesskey_and_title("test_title" , "a" , " accesskey=\"a\" title=\"test_title [a]\"");
|
||||
fxt.Clear().Test_val_html_accesskey_and_title("test_title" , null , " title=\"test_title\""); // accesskey is missing
|
||||
fxt.Clear().Test_val_html_accesskey_and_title("test_title" , "" , " title=\"test_title\""); // accesskey is ""
|
||||
fxt.Clear().Test_val_html_accesskey_and_title(null , "a" , " title=\"\""); // no title; leave blank
|
||||
}
|
||||
@Test public void Missing() {
|
||||
fxt.Test__get_msg_val("missing", "<missing>"); // check that key is enclosed in <>
|
||||
fxt.Test__get_msg_val("Missing", "<Missing>"); // check that val matches key; used to match 1st case-insensitive variant; EX: "<missing>" b/c "<missing>" was returned above; DATE:2016-08-01
|
||||
}
|
||||
}
|
||||
class Xol_msg_mgr_fxt {
|
||||
public Xol_msg_mgr_fxt Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
mgr = wiki.Msg_mgr();
|
||||
}
|
||||
mgr.Clear();
|
||||
wiki.Lang().Msg_mgr().Clear();
|
||||
return this;
|
||||
} private Xoae_app app; Xowe_wiki wiki; Xow_msg_mgr mgr;
|
||||
public void Test_val_by_key(String val, String expd) {
|
||||
Xol_msg_itm itm = wiki.Lang().Msg_mgr().Itm_by_key_or_new(Bry_.new_a7("test"));
|
||||
itm.Atrs_set(Bry_.new_a7(val), false, true);
|
||||
Tfds.Eq(expd, String_.new_u8(wiki.Msg_mgr().Val_by_key_obj(Bry_.new_a7("test"))), "has_tmpl_txt");
|
||||
}
|
||||
public void Test_mediaWiki_msg(String raw, String expd) {
|
||||
byte[] msg_ttl = Bry_.new_a7("MediaWiki:msg_ttl");
|
||||
wiki.Db_mgr().Save_mgr().Data_create(wiki, Xoa_ttl.Parse(wiki, msg_ttl), Bry_.new_a7(raw));
|
||||
Tfds.Eq(expd, String_.new_u8(wiki.Msg_mgr().Val_by_key_obj(Bry_.new_a7("msg_ttl"))));
|
||||
}
|
||||
public void Test_val_html_accesskey_and_title(String init_title, String init_accesskey, String expd) {
|
||||
if (init_title != null) new_msg_itm_("tooltip-test" , init_title);
|
||||
if (init_accesskey != null) new_msg_itm_("accesskey-test" , init_accesskey);
|
||||
Tfds.Eq(expd, String_.new_a7(wiki.Msg_mgr().Val_html_accesskey_and_title(Bry_.new_a7("test"))));
|
||||
}
|
||||
public void Test__get_msg_val(String key, String expd) {
|
||||
Gftest.Eq__str(expd, Xol_msg_mgr_.Get_msg_val(wiki, wiki.Lang(), Bry_.new_a7(key), Bry_.Ary_empty));
|
||||
}
|
||||
private void new_msg_itm_(String key, String val) {
|
||||
Xol_msg_itm itm = wiki.Lang().Msg_mgr().Itm_by_key_or_new(Bry_.new_a7(key));
|
||||
itm.Atrs_set(Bry_.new_a7(val), false, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
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.langs.msgs; import gplx.*; import gplx.xowa.*; import gplx.xowa.langs.*;
|
||||
import org.junit.*;
|
||||
public class Xow_mainpage_finder_tst {
|
||||
@Before public void init() {fxt.Clear();} private Xow_mainpage_finder_fxt fxt = new Xow_mainpage_finder_fxt();
|
||||
@Test public void Mediawiki() {
|
||||
fxt.Init_mediawiki_page("Mainpage_by_mediawiki");
|
||||
fxt.Test_mainpage("Mainpage_by_mediawiki");
|
||||
}
|
||||
@Test public void Lang() {
|
||||
fxt.Init_lang("Mainpage_by_lang");
|
||||
fxt.Test_mainpage("Mainpage_by_lang");
|
||||
}
|
||||
@Test public void Siteinfo() {
|
||||
fxt.Init_siteinfo("Mainpage_by_siteinfo");
|
||||
fxt.Test_mainpage("Mainpage_by_siteinfo");
|
||||
}
|
||||
@Test public void Lang_and_siteinfo() {
|
||||
fxt.Init_lang("Mainpage_by_lang");
|
||||
fxt.Init_siteinfo("Mainpage_by_siteinfo");
|
||||
fxt.Test_mainpage("Mainpage_by_lang");
|
||||
}
|
||||
@Test public void Mediawiki_and_siteinfo() {
|
||||
fxt.Init_mediawiki_page("Mainpage_by_mediawiki");
|
||||
fxt.Init_siteinfo("Mainpage_by_siteinfo");
|
||||
fxt.Test_mainpage("Mainpage_by_mediawiki");
|
||||
}
|
||||
@Test public void Mediawiki_and_lang_and_siteinfo() {
|
||||
fxt.Init_mediawiki_page("Mainpage_by_mediawiki");
|
||||
fxt.Init_lang("Mainpage_by_lang");
|
||||
fxt.Init_siteinfo("Mainpage_by_siteinfo");
|
||||
fxt.Test_mainpage("Mainpage_by_mediawiki");
|
||||
}
|
||||
@Test public void Mediawiki_tmpl() { // PURPOSE: de.wiktionary.org has "{{ns:project}}:Hauptseite"; DATE:2013-07-07
|
||||
fxt.Init_mediawiki_page("{{ns:project}}:Hauptseite");
|
||||
fxt.Test_mainpage("Wikipedia:Hauptseite");
|
||||
}
|
||||
}
|
||||
class Xow_mainpage_finder_fxt {
|
||||
public void Clear() {
|
||||
fxt.Reset_for_msgs();
|
||||
} private final Xop_fxt fxt = new Xop_fxt();
|
||||
public void Init_siteinfo(String mainpage_val) {
|
||||
fxt.Wiki().Props().Main_page_(Bry_.new_a7(mainpage_val));
|
||||
}
|
||||
public void Init_mediawiki_page(String mainpage_val) {
|
||||
fxt.Init_page_create(String_.new_a7(Ttl_mainpage), mainpage_val);
|
||||
} private static final byte[] Ttl_mainpage = Bry_.new_a7("MediaWiki:Mainpage"); // TEST:
|
||||
public void Init_lang(String mainpage_val) {
|
||||
Xol_msg_itm msg_itm = fxt.Wiki().Lang().Msg_mgr().Itm_by_key_or_new(Xow_mainpage_finder.Msg_mainpage);
|
||||
msg_itm.Atrs_set(Bry_.new_a7(mainpage_val), false, false);
|
||||
}
|
||||
public void Test_mainpage(String expd) {
|
||||
byte[] actl = Xow_mainpage_finder.Find_or(fxt.Wiki(), fxt.Wiki().Props().Main_page());
|
||||
Tfds.Eq(expd, String_.new_a7(actl));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user