1
0
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:
gnosygnu
2018-07-01 07:55:55 -04:00
parent 10c39e4c76
commit 372cd3958d
908 changed files with 70356 additions and 14 deletions

View 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.dbs.bulks; import gplx.*; import gplx.dbs.*;
import org.junit.*; import gplx.core.tests.*; import gplx.dbs.metas.*;
public class Db_tbl_copy_tst {
private final Db_tbl_copy_fxt fxt = new Db_tbl_copy_fxt();
@Test public void Basic() {
fxt.Test__bld_sql(fxt.Make_tbl("tbl_1", Dbmeta_fld_itm.new_int("fld_1"), Dbmeta_fld_itm.new_int("fld_2")),
String_.Concat_lines_nl_skip_last
( "INSERT INTO trg"
, "(fld_1, fld_2)"
, "SELECT"
, " fld_1, fld_2"
, "FROM <src_db>src"
));
}
}
class Db_tbl_copy_fxt {
private final Db_tbl_copy mgr = new Db_tbl_copy();
public Dbmeta_tbl_itm Make_tbl(String name, Dbmeta_fld_itm... flds) {return Dbmeta_tbl_itm.New(name, flds);}
public void Test__bld_sql(Dbmeta_tbl_itm tbl, String expd) {
Gftest.Eq__ary__lines(expd, mgr.Bld_sql(tbl, "src", "trg"), "sql");
}
}

View File

@@ -0,0 +1,53 @@
/*
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.dbs.metas.updates; import gplx.*; import gplx.dbs.*; import gplx.dbs.metas.*;
import org.junit.*; import gplx.dbs.*;
public class Schema_update_mgr_tst {
@Before public void init() {fxt.Clear();} private Schema_update_mgr_fxt fxt = new Schema_update_mgr_fxt();
@Test public void Create() {
fxt.Test_exec_y(new Schema_update_cmd__mock());
}
@Test public void Delete() {
fxt.Init_itm(Dbmeta_itm_tid.Tid_table, Schema_update_cmd__mock.Tbl_name);
fxt.Test_exec_n(new Schema_update_cmd__mock());
}
}
class Schema_update_mgr_fxt {
private Schema_update_mgr update_mgr; private Schema_db_mgr db_mgr;
public void Clear() {
update_mgr = new Schema_update_mgr();
db_mgr = new Schema_db_mgr();
}
public void Init_itm(int tid, String name) {
db_mgr.Tbl_mgr().Add(Dbmeta_tbl_itm.New(name));
}
public void Test_exec_y(Schema_update_cmd cmd) {Test_exec(cmd, Bool_.Y);}
public void Test_exec_n(Schema_update_cmd cmd) {Test_exec(cmd, Bool_.N);}
private void Test_exec(Schema_update_cmd cmd, boolean expd) {
update_mgr.Add(cmd);
update_mgr.Update(db_mgr, Db_conn_.Noop);
Tfds.Eq(expd, cmd.Exec_is_done());
}
}
class Schema_update_cmd__mock implements Schema_update_cmd {
public String Name() {return "xowa.user.cfg_regy.create";}
public boolean Exec_is_done() {return exec_is_done;} private boolean exec_is_done;
public void Exec(Schema_db_mgr mgr, Db_conn conn) {
if (mgr.Tbl_mgr().Has(Tbl_name)) return;
exec_is_done = true;
}
public static final String Tbl_name = "tbl_mock";
}

View File

@@ -0,0 +1,61 @@
/*
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.dbs.percentiles; import gplx.*; import gplx.dbs.*;
import org.junit.*;
public class Percentile_rng_tst {
private final Percentile_rng_fxt fxt = new Percentile_rng_fxt();
@Before public void init() {fxt.Clear();}
@Test public void Found__000() {
fxt.Test__rng(999994, 1000001);
fxt.Exec__update( 0).Test__rng(999966, 999994);
fxt.Exec__update( 0).Test__rng(999854, 999966);
}
@Test public void Found__025() {
fxt.Test__rng(999994, 1000001);
fxt.Exec__update( 25).Test__rng(999973, 999994);
fxt.Exec__update( 25).Test__rng(999931, 999973);
fxt.Exec__update( 25).Test__rng(999889, 999931);
fxt.Exec__update( 25).Test__rng(999847, 999889);
}
@Test public void Calc_score_unit() {
fxt.Test__calc_score_unit(50, 16000000, 1000000, 4); // to fill 50 -> 16 pages per point -> read every 4 points to get 64 pages
fxt.Test__calc_score_unit(50, 1000, 1000000, 50000); // to fill 50 -> 1000 points per page -> read every 50k points to get 50 pages
fxt.Test__calc_score_unit(50, 25, 1000000, 1000000); // range bounds check; to fill 50, always read full amount
}
}
class Percentile_rng_fxt {
private final Percentile_rng rng = new Percentile_rng();
public void Clear() {
this.Exec__init_for_wiki(16000000, 1000000);
this.Exec__init_for_search(100, 0);
}
public Percentile_rng_fxt Exec__init_for_wiki (int pages_max, int score_max) {
rng.Init(pages_max, score_max); return this;
}
public Percentile_rng_fxt Exec__init_for_search(int request_count, int score_len_adj) {
rng.Select_init(request_count, Percentile_rng.Score_null, Percentile_rng.Score_null, score_len_adj); return this;
}
public Percentile_rng_fxt Exec__update(int rdr_found) {
rng.Update(rdr_found); return this;
}
public void Test__rng(int expd_bgn, int expd_end) {
Tfds.Eq(expd_end, rng.Score_end(), "rng_end");
Tfds.Eq(expd_bgn, rng.Score_bgn(), "rng_bgn");
}
public void Test__calc_score_unit(int request_count, long pages_max, int score_max, int expd) {
Tfds.Eq(expd, Percentile_rng.Calc_score_unit(request_count, pages_max, score_max));
}
}