1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00
This commit is contained in:
gnosygnu
2015-07-19 23:16:49 -04:00
parent 794b5a232f
commit 8e041d6e06
834 changed files with 4749 additions and 4461 deletions

View File

@@ -404,7 +404,7 @@ public class Pf_func_ {
case Xol_kwd_grp_.Id_cascadingSources:
return new Pf_func_noop(id);
case Xol_kwd_grp_.Id_bang: return Pf_func_bang._;
default: throw Exc_.new_unhandled(id);
default: throw Err_.new_unhandled(id);
}
}
}

View File

@@ -45,7 +45,7 @@ class Paren_bgn_tkn implements Expr_tkn, Func_tkn {
public int ArgCount() {return 0;}
public int Precedence() {return -1;}
public Func_tkn GetAlt() {return this;}
public boolean Calc(Xop_ctx ctx, Pfunc_expr_shunter shunter, Val_stack val_stack) {throw Exc_.new_unimplemented();}
public boolean Calc(Xop_ctx ctx, Pfunc_expr_shunter shunter, Val_stack val_stack) {throw Err_.new_unimplemented();}
public static Paren_bgn_tkn _ = new Paren_bgn_tkn(); Paren_bgn_tkn() {}
}
class Paren_end_tkn implements Expr_tkn {

View File

@@ -78,7 +78,7 @@ public class Pfunc_expr_shunter {
try {num = Bry_.XtoDecimalByPos(src, numBgn, cur_pos);}
catch (Exception exc) {
// NOTE: PATCH.PHP: 65.5.5 can evaluate to 65.5; EX "{{Geological eras|-600|height=2|border=none}}" eventually does "|10-to={{#ifexpr:{{{1|-4567}}}<-65.5|-65.5|{{{1}}}}}.5" which is 65.5.5
Exc_.Noop(exc);
Err_.Noop(exc);
int dot_count = 0;
for (int i = numBgn; i < cur_pos; i++) {
if (src[i] == Byte_ascii.Dot) {
@@ -88,7 +88,7 @@ public class Pfunc_expr_shunter {
try {
num = Bry_.XtoDecimalByPos(src, numBgn, i);
}
catch (Exception exc_inner) {Exc_.Noop(exc_inner);}
catch (Exception exc_inner) {Err_.Noop(exc_inner);}
break;
}
}

View File

@@ -84,6 +84,6 @@ public class Pfunc_switch extends Pf_func_base {
return tmp.Xto_bry_and_clear_and_trim();
}
}
public static final byte[] Dflt_keyword = Bry_.new_u8("#default"); // NOTE: technically should pull from messages, but would need to cache Dflt_keyword on wiki level; checked all Messages files, and no one overrides it; DATE:2014-05-29
public static final byte[] Dflt_keyword = Bry_.new_a7("#default"); // NOTE: technically should pull from messages, but would need to cache Dflt_keyword on wiki level; checked all Messages files, and no one overrides it; DATE:2014-05-29
private static int Dflt_keyword_len = Dflt_keyword.length;
}

View File

@@ -26,7 +26,7 @@ public class Pfunc_grammar extends Pf_func_base {
Xol_lang lang = ctx.Cur_page().Lang();
boolean pass = false;
try {pass = lang.Grammar().Grammar_eval(bfr, lang, word, argx);}
catch (Exception e) {Exc_.Noop(e);}
catch (Exception e) {Err_.Noop(e);}
if (!pass) Xot_invk_tkn.Print_not_found(bfr, ctx.Wiki().Ns_mgr(), this.Name());
}
}

View File

@@ -35,7 +35,7 @@ public class Pfunc_int_tst {
fxt.Test_parse_en("{{int:january/en}}", "January");
}
@Test public void Lang_specified_by_page() {
fxt.Test_parse_lang("fr", "{{int:Lang}}", "fr"); // NOTE: "Lang" msg is added by Xol_lang; message_mgr.Itm_by_key_or_new(Bry_.new_u8("Lang")).Atrs_set(key_bry, false, false);
fxt.Test_parse_lang("fr", "{{int:Lang}}", "fr"); // NOTE: "Lang" msg is added by Xol_lang; message_mgr.Itm_by_key_or_new(Bry_.new_a7("Lang")).Atrs_set(key_bry, false, false);
}
@Test public void Lang_missing_msg_return_en() { // PURPOSE: if key does not exist in non-english language, use English; EX: la.w:Fasciculus:HannibalFrescoCapitolinec1510.jpg; DATE:2013-09-10
fxt.Init_msg_gfs("en_only_key", "en_only_val", false, false);

View File

@@ -23,31 +23,34 @@ public class Pf_formatnum_fa_tst {
@Before public void init() {
Xoae_app app = Xoa_app_fxt.app_();
Xol_lang lang = new Xol_lang(app.Lang_mgr(), Bry_.new_a7("fa")).Init_by_load_assert();
String gfs = String_.Concat_lines_nl
( "numbers {"
, " digits {"
, " clear;"
, " set('0', '۰');"
, " set('1', '۱');"
, " set('2', '۲');"
, " set('3', '۳');"
, " set('4', '۴');"
, " set('5', '۵');"
, " set('6', '۶');"
, " set('7', '۷');"
, " set('8', '۸');"
, " set('9', '۹');"
, " set('%', '٪');"
, " set('.', '٫');"
, " set(',', '٬');"
, " }"
, "}"
);
app.Gfs_mgr().Run_str_for(lang, gfs);
app.Gfs_mgr().Run_str_for(lang, Persian_numbers_gfs);
Xowe_wiki wiki = Xoa_app_fxt.wiki_(app, "fa.wikipedia.org", lang);
fxt = new Xop_fxt(app, wiki);
}
@Test public void Basic() {
@Test public void Basic() {
fxt.Test_parse_tmpl_str_test("{{formatnum:۱۵۰|R}}" , "{{test}}", "150");
}
@Test public void English() { // PURPOSE: make sure regular numbers are still read; DATE:2015-07-18
fxt.Test_parse_tmpl_str_test("{{formatnum:150|R}}" , "{{test}}", "150");
}
public static final String Persian_numbers_gfs = String_.Concat_lines_nl
( "numbers {"
, " digits {"
, " clear;"
, " set('0', '۰');"
, " set('1', '۱');"
, " set('2', '۲');"
, " set('3', '۳');"
, " set('4', '۴');"
, " set('5', '۵');"
, " set('6', '۶');"
, " set('7', '۷');"
, " set('8', '۸');"
, " set('9', '۹');"
, " set('%', '٪');"
, " set('.', '٫');"
, " set(',', '٬');"
, " }"
, "}"
);
}

View File

@@ -41,7 +41,7 @@ public class Pfunc_rev_props extends Pf_func_base {
bfr.Add_byte(Byte_ascii.Num_0);
break;
case Xol_kwd_grp_.Id_rev_protectionlevel: bfr.Add(rev_data.Protection_level()); break;
default: throw Exc_.new_unhandled(id);
default: throw Err_.new_unhandled(id);
}
}
public Pfunc_rev_props(int id) {this.id = id;}

View File

@@ -33,7 +33,7 @@ public class Pfunc_scrib_lib implements Scrib_lib {
public boolean Procs_exec(int key, Scrib_proc_args args, Scrib_proc_rslt rslt) {
switch (key) {
case Proc_expr: return Expr(args, rslt);
default: throw Exc_.new_unhandled(key);
default: throw Err_.new_unhandled(key);
}
}
private static final int Proc_expr = 0;
@@ -47,6 +47,6 @@ public class Pfunc_scrib_lib implements Scrib_lib {
if (pass)
return rslt.Init_obj(expr_rslt);
else
throw Exc_.new_(expr_rslt);
throw Err_.new_wo_type(expr_rslt);
}
}

View File

@@ -29,7 +29,7 @@ public class Pfunc_tag_tst {
@Test public void Ws_all() {fxt.Test_html_full_str("{{#tag:pre|a| id = b }}" , "<pre id=\"b\">a</pre>");}
@Test public void Ws_quoted() {fxt.Test_html_full_str("{{#tag:pre|a| id = ' b ' }}" , "<pre id=\"_b_\">a</pre>");}
@Test public void Err_bad_key() {fxt.Test_html_full_str("{{#tag:pre|a|id=val|b}}" , "<pre id=\"val\">a</pre>");} // PURPOSE: b was failing b/c id was larger and key_end set to 4 (whereas b was len=1)
// @Test public void Exc() {
// @Test public void Err() {
// fxt.Test_parse_tmpl_str_test("{{#tag:ref|George Robertson announced in January 2003 that he would be stepping down in December.<ref> {{cite news|title =NATO Secretary General to Leave His Post in December After 4 Years |first = Craig | last = Smith | work = The New York Times | date = January 23, 2003| url = http://www.nytimes.com/2003/01/23/world/nato-secretary-general-to-leave-his-post-in-december-after-4-years.html?scp=2&sq=lord+robertson&st=nyt|accessdate = 2009-03-29}}</ref> Jaap de Hoop Scheffer was selected as his successor, but could not assume the office until January 2004 because of his commitment in the Dutch Parliament.<ref> {{cite news|title = Jaap de Hoop Scheffer | work = Newsmakers | issue = 1 | publisher = Thomson Gale | date = January 1, 2005}}</ref> Robertson was asked to extend his term until Scheffer was ready, but declined, so Minuto-Rizzo, the Deputy Secretary General, took over in the interim.<ref name =\"ncsd\" /> |group=N|}}"
// , "{{test}}" , "<pre id=\" b \">a</pre>");}
@Test public void Nested_tmpl() { // PURPOSE: nested template must get re-evaluated; EX:de.wikipedia.org/wiki/Freiburg_im_Breisgau; DATE:2013-12-18;

View File

@@ -27,7 +27,7 @@ public class Pft_func_date_int extends Pf_func_base {
case Date_tid_lcl: date = DateAdp_.Now(); break;
case Date_tid_utc: date = DateAdp_.Now().XtoUtc(); break;
case Date_tid_rev: date = ctx.Cur_page().Revision_data().Modified_on(); break;
default: throw Exc_.new_unhandled(date_tid);
default: throw Err_.new_unhandled(date_tid);
}
switch (id) {
case Xol_kwd_grp_.Id_utc_year:
@@ -81,7 +81,7 @@ public class Pft_func_date_int extends Pf_func_base {
.Add_int_fixed(date.Minute(), 2)
.Add_int_fixed(date.Second(), 2);
break;
default: throw Exc_.new_unhandled(id);
default: throw Err_.new_unhandled(id);
}
}
public static final int Date_tid_utc = 0, Date_tid_lcl = 1, Date_tid_rev = 2;

View File

@@ -26,7 +26,7 @@ public class Pft_func_date_name extends Pf_func_base {
case Pft_func_date_int.Date_tid_lcl: date = DateAdp_.Now(); break;
case Pft_func_date_int.Date_tid_utc: date = DateAdp_.Now().XtoUtc(); break;
case Pft_func_date_int.Date_tid_rev: date = ctx.Cur_page().Revision_data().Modified_on(); break;
default: throw Exc_.new_unhandled(date_tid);
default: throw Err_.new_unhandled(date_tid);
}
byte[] val = ctx.Wiki().Msg_mgr().Val_by_id(base_idx + date.Segment(seg_idx));
bfr.Add(val);

View File

@@ -50,7 +50,7 @@ public class Pft_func_time extends Pf_func_base {
return rv;
}
catch (Exception exc) {
Exc_.Noop(exc);
Err_.Noop(exc);
error_bfr.Add_str_a7("Invalid time");
return null;
}

View File

@@ -189,7 +189,7 @@ class Pxd_itm_unit extends Pxd_itm_base implements Pxd_itm_prototype {
case DateAdp_.SegIdx_day : cur = cur.Add_day (val); break;
case DateAdp_.SegIdx_month : cur = cur.Add_month (val); break;
case DateAdp_.SegIdx_year : cur = cur.Add_year (val); break;
default: throw Exc_.new_unhandled(this.Seg_idx());
default: throw Err_.new_unhandled(this.Seg_idx());
}
bldr.Date_(cur);
}

View File

@@ -39,7 +39,7 @@ public class Pfunc_filepath_tst {
app.Wiki_mgr().Add(commons_wiki);
app.File_mgr().Repo_mgr().Set("src_commons", "mem/xowa/file/commons/src/", commons_wiki.Domain_str());
app.File_mgr().Repo_mgr().Set("trg_commons", "mem/xowa/file/commons/trg/", commons_wiki.Domain_str());
en_wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_u8("src_commons"), Bry_.new_u8("trg_commons"));
en_wiki.File_mgr().Repo_mgr().Add_repo(Bry_.new_a7("src_commons"), Bry_.new_a7("trg_commons"));
Io_mgr.I.CreateDir(Io_url_.new_dir_("mem/xowa/wiki/commons.wikimedia.org/ns/000/page/")); // HACK: create page_dir so Scan_dirs_zip will not identify commons as zipped; FIX: remove; WHEN: after redoing commons.css download logic
}
@Test public void Wiki_is_local() {

View File

@@ -46,7 +46,7 @@ public class Pfunc_urlfunc extends Pf_func_base { // EX: {{lc:A}} -> a
case Tid_local: tmp_bfr.Add(ctx.Wiki().Props().ArticlePath());break;
case Tid_full: tmp_bfr.Add(Bry_relative_url).Add(ctx.Wiki().Props().ServerName()).Add(ctx.Wiki().Props().ArticlePath()); break;
case Tid_canonical: tmp_bfr.Add(ctx.Wiki().Props().Server()).Add(ctx.Wiki().Props().ArticlePath()); break;
default: throw Exc_.new_unhandled(tid);
default: throw Err_.new_unhandled(tid);
}
tmp_bfr.Add(ttl_ary);
trg.Add_bfr_and_clear(tmp_bfr);

View File

@@ -31,7 +31,7 @@ public class Pfunc_wiki_props extends Pf_func_base {
case Xol_kwd_grp_.Id_site_directionmark: bfr.Add(props.DirectionMark()); break;
case Xol_kwd_grp_.Id_site_currentversion: bfr.Add(props.Current_version()); break;
case Xol_kwd_grp_.Id_site_contentlanguage: bfr.Add(ctx.Cur_page().Lang().Key_bry()); break;
default: throw Exc_.new_unhandled(id);
default: throw Err_.new_unhandled(id);
}
}
@Override public Pf_func New(int id, byte[] name) {return new Pfunc_wiki_props(id).Name_(name);}

View File

@@ -35,7 +35,7 @@ public class Pfunc_wiki_stats extends Pf_func_base {
case Xol_kwd_grp_.Id_num_users: v = stats.NumUsers(); break;
case Xol_kwd_grp_.Id_num_users_active: v = stats.NumUsersActive(); break;
case Xol_kwd_grp_.Id_num_admins: v = stats.NumAdmins(); break;
default: throw Exc_.new_unhandled(id);
default: throw Err_.new_unhandled(id);
}
if (raw)
rslt_bfr.Add_int_variable(v);