mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v2.7.2.1
This commit is contained in:
120
110_gfml/tst/gplx/gfml/GfmlDataRdr_tst.java
Normal file
120
110_gfml/tst/gplx/gfml/GfmlDataRdr_tst.java
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class GfmlDataRdr_tst {
|
||||
@Test public void Raw() {
|
||||
raw = "root:{}";
|
||||
rdr = rdr_(raw);
|
||||
|
||||
Tfds.Eq(rdr.NameOfNode(), "root");
|
||||
}
|
||||
@Test public void Atrs() {
|
||||
raw = "root:id=1 name=me isPresent=true dateOf='2006-12-08';";
|
||||
rdr = rdr_(raw);
|
||||
|
||||
Tfds.Eq(rdr.ReadInt("id"), 1);
|
||||
Tfds.Eq(rdr.ReadStr("name"), "me");
|
||||
Tfds.Eq(rdr.ReadBool("isPresent"), true);
|
||||
Tfds.Eq_date(rdr.ReadDate("dateOf"), DateAdp_.parse_gplx("2006-12-08"));
|
||||
}
|
||||
@Test public void Subs() {
|
||||
raw = String_.Concat_any(
|
||||
"root:{",
|
||||
" computers:id=1 {",
|
||||
" item:name=cpu;",
|
||||
" item:name=monitor;",
|
||||
" }",
|
||||
" person:id=2 {",
|
||||
" item:name=hardDrive;",
|
||||
" item:name=networkCard;",
|
||||
" }",
|
||||
"}");
|
||||
rdr = rdr_(raw);
|
||||
|
||||
DataRdr computers = rdr.Subs();
|
||||
int idx = 0;
|
||||
while (computers.MoveNextPeer()) {
|
||||
int expd = idx == 0 ? 1 : 2;
|
||||
Tfds.Eq(computers.ReadInt("id"), expd);
|
||||
idx++;
|
||||
}
|
||||
Tfds.Eq(idx, 2);
|
||||
|
||||
DataRdr items = computers.Subs();
|
||||
idx = 0;
|
||||
while (items.MoveNextPeer()) {
|
||||
String expdStr = idx == 0 ? "hardDrive" : "networkCard";
|
||||
Tfds.Eq(items.ReadStr("name"), expdStr);
|
||||
idx++;
|
||||
}
|
||||
Tfds.Eq(idx, 2);
|
||||
}
|
||||
@Test public void SelectRdr() {
|
||||
raw = String_.Concat_any(
|
||||
"root:{",
|
||||
" person:name=me {}",
|
||||
" computer:brand=noname {}",
|
||||
"}");
|
||||
rdr = rdr_(raw);
|
||||
|
||||
DataRdr person = rdr.Subs_byName_moveFirst("person");
|
||||
Tfds.Eq(person.NameOfNode(), "person");
|
||||
Tfds.Eq(person.ReadStr("name"), "me");
|
||||
DataRdr computer = rdr.Subs_byName_moveFirst("computer");
|
||||
Tfds.Eq(computer.NameOfNode(), "computer");
|
||||
Tfds.Eq(computer.ReadStr("brand"), "noname");
|
||||
}
|
||||
// @Test public void Subs_byKey() {
|
||||
// raw = String_.Concat_any(
|
||||
// "root:",
|
||||
// " person=(name=me)",
|
||||
// ";");
|
||||
// rdr = rdr_(raw);
|
||||
//
|
||||
// DataRdr person = rdr.Subs_byKey("person");
|
||||
// Tfds.Eq(person.NameOfNode, "person");
|
||||
// Tfds.Eq(person.ReadStr("name"), "me");
|
||||
// }
|
||||
// @Test public void Type() {
|
||||
// raw = String_.Concat_any(
|
||||
// "root:{",
|
||||
// " _type:{example{explicit_val; bool_val; int_val; string_val; long_val; date_val; float_val; decimal_val;}}",
|
||||
// " example:val1;",
|
||||
// "}");
|
||||
//
|
||||
// rdr = rdr_(raw);
|
||||
// DataRdr pointRdr = rdr.Subs(); rdr.MoveNextPeer();
|
||||
//
|
||||
// Tfds.Eq(rdr.FieldCount, 8);
|
||||
// Tfds.Eq(rdr.ReadStr("explicit_val"), "val1");
|
||||
// Tfds.Eq(rdr.ReadBool("bool_val"), false);
|
||||
// Tfds.Eq(rdr.ReadInt("int_val"), 0);
|
||||
// Tfds.Eq(rdr.ReadStr("string_val"), null);
|
||||
// Tfds.Eq(rdr.ReadLongOrFail("long_val"), (long)0);
|
||||
// Tfds.Eq(rdr.ReadDate("date_val"), DateAdp_.MinValue);
|
||||
// Tfds.Eq(rdr.ReadFloat("float_val"), (float)0);
|
||||
// Tfds.Eq(rdr.FieldAt(1), "bool_val");
|
||||
// Tfds.Eq(rdr.Read(1), null);
|
||||
// }
|
||||
DataRdr rdr_(String raw) {
|
||||
DataRdr rootRdr = GfmlDataRdr.raw_root_(raw);
|
||||
return rootRdr;
|
||||
}
|
||||
String raw; DataRdr rdr;
|
||||
}
|
||||
79
110_gfml/tst/gplx/gfml/yfxts_GfmlParse_fxt.java
Normal file
79
110_gfml/tst/gplx/gfml/yfxts_GfmlParse_fxt.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlParse_fxt {
|
||||
public GfmlNde_mok nde_() {return GfmlNde_mok.new_();}
|
||||
public GfmlTkn_mok tkn_grp_ary_(String... ary) {return GfmlTkn_mok.new_().Subs_(GfmlTkn_mok.Xto_bry(ary));}
|
||||
public GfmlTkn_mok tkn_grp_(GfmlTkn_mok... ary) {return GfmlTkn_mok.new_().Subs_(ary);}
|
||||
public GfmlTkn_mok tkn_itm_(String r) {return GfmlTkn_mok.new_().Raw_(r);}
|
||||
public void ini_RootLxr_Add(GfmlLxr... ary) {rootLxr.SubLxr_Add(ary);}
|
||||
public void tst_Doc(String raw, GfmlNde_mok... expdAry) {
|
||||
GfmlDoc gdoc = bldr.XtoGfmlDoc(raw);
|
||||
GfmlNde_mok expd = GfmlNde_mok.new_();
|
||||
for (GfmlNde_mok itm : expdAry)
|
||||
expd.Subs_(itm);
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
GfmlTypeResolver_fxt.tst_Nde(tstr, expd, GfmlNde_mok.gfmlNde_(gdoc.RootNde()));
|
||||
tstr.tst_Equal("parse");
|
||||
}
|
||||
public void tst_Tkn(String raw, GfmlTkn_mok... expdAry) {
|
||||
GfmlDoc gdoc = bldr.XtoGfmlDoc(raw);
|
||||
GfmlTkn_mok expd = GfmlTkn_mok.new_();
|
||||
for (GfmlTkn_mok itm : expdAry)
|
||||
expd.Subs_(itm);
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
GfmlTkn_mok.tst(tstr, expd, GfmlTkn_mok.gfmlNde_(gdoc.RootNde()));
|
||||
tstr.tst_Equal("parse");
|
||||
}
|
||||
public static GfmlParse_fxt new_() {
|
||||
GfmlParse_fxt rv = new GfmlParse_fxt();
|
||||
rv.rootLxr = GfmlDocLxrs.Root_lxr();
|
||||
rv.bldr = GfmlBldr_.new_();
|
||||
rv.bldr.Doc().RootLxr_set(rv.rootLxr);
|
||||
return rv;
|
||||
}
|
||||
public void tst_Err(String raw, UsrMsg_mok... expdErrs) {
|
||||
bldr.ThrowErrors_set(false);
|
||||
GfmlDoc actlDoc = bldr.XtoGfmlDoc(raw);
|
||||
List_adp expd = List_adp_.new_(), actl = actlDoc.UsrMsgs();
|
||||
expd.Add_many((Object[])expdErrs);
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
int max = tstr.List_Max(expd, actl);
|
||||
for (int i = 0; i < max; i++) {
|
||||
UsrMsg_mok expdUm = (UsrMsg_mok)tstr.List_FetchAtOrNull(expd, i);
|
||||
UsrMsg actlUm = (UsrMsg)tstr.List_FetchAtOrNull(actl, i);
|
||||
UsrMsg_mok actlUmm = UsrMsg_mok.new_(actlUm);
|
||||
tstr.Eq_str(expdUm.Main(), actlUmm.Main(), "main");
|
||||
for (int j = 0; j < expdUm.Args().Count(); j++) {
|
||||
KeyVal expdKv = (KeyVal)expdUm.Args().Get_at(j);
|
||||
KeyVal actlKv = (KeyVal)actlUmm.Args().Get_by(expdKv.Key());
|
||||
Object actlVal = actlKv == null ? String_.Null_mark : actlKv.Val();
|
||||
tstr.Eq_str(expdKv.Val(), actlVal, expdKv.Key());
|
||||
}
|
||||
for (int j = 0; j < expdUm.Required().Count(); j++) {
|
||||
String expdKv = (String)expdUm.Required().Get_at(j);
|
||||
KeyVal actlKv = (KeyVal)actlUmm.Args().Get_by(expdKv);
|
||||
Object actlVal = actlKv == null ? String_.Null_mark : actlKv.Val();
|
||||
Object actlValV = actlKv == null ? "<<REQD>>" : actlKv.Val();
|
||||
tstr.Eq_str(actlValV, actlVal, expdKv);
|
||||
}
|
||||
}
|
||||
tstr.tst_Equal("errs");
|
||||
}
|
||||
GfmlBldr bldr; GfmlLxr rootLxr;
|
||||
}
|
||||
102
110_gfml/tst/gplx/gfml/yfxts_GfmlTypeCompiler_fxt.java
Normal file
102
110_gfml/tst/gplx/gfml/yfxts_GfmlTypeCompiler_fxt.java
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlTypeCompiler_fxt {
|
||||
public GfmlTyp_mok typ_() {return GfmlTyp_mok.new_();}
|
||||
public GfmlNde_mok nde_() {return GfmlNde_mok.new_();}
|
||||
public GfmlFld_mok fld_() {return GfmlFld_mok.new_();}
|
||||
public GfmlTypRegy Regy() {return typBldr.TypeRegy();}
|
||||
public void ini_Typ(List_adp typs, GfmlTyp_mok typ) {typs.Add(typ);}
|
||||
@gplx.Internal protected void run_InitPragma(GfmlTypRegy regy, GfmlPragma pragma) {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
GfmlType[] typeAry = pragma.MakePragmaTypes(makr);
|
||||
regy.Add_ary(typeAry);
|
||||
}
|
||||
public void tst_Type(GfmlTyp_mok expd, GfmlTyp_mok actl) {
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
tst(tstr, expd, actl);
|
||||
tstr.tst_Equal("typ");
|
||||
}
|
||||
public void tst_Compile(GfmlNde_mok nde, GfmlTyp_mok expd) {
|
||||
GfmlNde gnde = run_Resolve(this.Regy(), "_type/type", nde);
|
||||
Ordered_hash list = Ordered_hash_.new_();
|
||||
GfmlType actlType = GfmlTypeCompiler.Compile(gnde, GfmlType_.Root, this.Regy(), list);
|
||||
GfmlTyp_mok actl = GfmlTyp_mok.type_(actlType);
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
tst(tstr, expd, actl);
|
||||
tstr.tst_Equal("typ");
|
||||
}
|
||||
public void tst_Parse(String raw, GfmlNde_mok... expdAry) {
|
||||
GfmlDoc gdoc = GfmlDoc_.parse_any_eol_(raw);
|
||||
GfmlNde_mok expd = GfmlNde_mok.new_();
|
||||
for (GfmlNde_mok itm : expdAry)
|
||||
expd.Subs_(itm);
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
GfmlTypeResolver_fxt.tst_Nde(tstr, expd, GfmlNde_mok.gfmlNde_(gdoc.RootNde()));
|
||||
tstr.tst_Equal("parse");
|
||||
}
|
||||
public static void tst(TfdsTstr_fxt tstr, GfmlTyp_mok expd, GfmlTyp_mok actl) {
|
||||
if (expd.Name() != null) tstr.Eq_str(expd.Name(), actl.Name(), "name");
|
||||
if (expd.Key() != null) tstr.Eq_str(expd.Key(), actl.Key(), "key");
|
||||
int max = tstr.List_Max(expd.Subs(), actl.Subs());
|
||||
for (int i = 0; i < max; i++) {
|
||||
GfmlFld_mok expdFld = (GfmlFld_mok)tstr.List_FetchAtOrNull(expd.Subs(), i);
|
||||
GfmlFld_mok actlFld = (GfmlFld_mok)tstr.List_FetchAtOrNull(actl.Subs(), i);
|
||||
tstr.SubName_push(Int_.Xto_str(i) + " fld");
|
||||
tst(tstr, expdFld, actlFld);
|
||||
tstr.SubName_pop();
|
||||
}
|
||||
}
|
||||
static void tst(TfdsTstr_fxt tstr, GfmlFld_mok expd, GfmlFld_mok actl) {
|
||||
expd = NullObj(expd); actl = NullObj(actl);
|
||||
if (expd.Name() != null) tstr.Eq_str(expd.Name(), actl.Name(), "name");
|
||||
if (expd.TypeKey() != null) tstr.Eq_str(expd.TypeKey(), actl.TypeKey(), "typekey");
|
||||
if (expd.DefaultTkn() != null) tstr.Eq_str(expd.DefaultTknRaw(), actl.DefaultTknRaw(), "default");
|
||||
}
|
||||
static GfmlFld_mok NullObj(GfmlFld_mok v) {return (v == null) ? GfmlFld_mok.new_().ini_ndk_(String_.Null_mark, "") : v;}
|
||||
public void tst_Resolve(GfmlTyp_mok typ, GfmlNde_mok nde, GfmlNde_mok expd) {
|
||||
typBldr.TypeRegy().Add(typ.XtoGfmlType());
|
||||
tst_Resolve(nde, expd);
|
||||
}
|
||||
public GfmlNde run_Resolve(GfmlTypRegy regy, String typKey, GfmlNde_mok nde) {
|
||||
GfmlNde gfmlNde = nde.XtoGfmlItm(regy);
|
||||
typBldr.OverridePool(regy.FetchOrNull(typKey));
|
||||
tst_ResolveNde(gfmlNde, typKey);
|
||||
return gfmlNde;
|
||||
}
|
||||
public void tst_Resolve(GfmlNde_mok nde, GfmlNde_mok expd) {
|
||||
GfmlNde gfmlNde = nde.XtoGfmlItm(typBldr.TypeRegy());
|
||||
tst_ResolveNde(gfmlNde, GfmlType_.AnyKey);
|
||||
TfdsTstr_fxt tstr = TfdsTstr_fxt.new_();
|
||||
GfmlTypeResolver_fxt.tst_Nde(tstr, expd, GfmlNde_mok.gfmlNde_(gfmlNde));
|
||||
tstr.tst_Equal("test");
|
||||
}
|
||||
void tst_ResolveNde(GfmlNde nde, String ownerKey) {
|
||||
typBldr.NdeBgn(nde, ownerKey);
|
||||
for (int i = 0; i < nde.SubObjs_Count(); i++) {
|
||||
GfmlItm itm = (GfmlItm)nde.SubObjs_GetAt(i);
|
||||
if (itm.ObjType() == GfmlObj_.Type_nde)
|
||||
tst_ResolveNde((GfmlNde)itm, nde.Type().Key());
|
||||
else
|
||||
typBldr.AtrExec(nde, (GfmlAtr)itm);
|
||||
}
|
||||
typBldr.NdeEnd();
|
||||
}
|
||||
GfmlTypeMgr typBldr = GfmlTypeMgr.new_();
|
||||
public static GfmlTypeCompiler_fxt new_() {return new GfmlTypeCompiler_fxt();} GfmlTypeCompiler_fxt() {}
|
||||
}
|
||||
182
110_gfml/tst/gplx/gfml/ymoks_GfmlAtr_GfmlNde_mok.java
Normal file
182
110_gfml/tst/gplx/gfml/ymoks_GfmlAtr_GfmlNde_mok.java
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import gplx.core.strings.*;
|
||||
interface GfmlItm_mok {
|
||||
int ObjType();
|
||||
}
|
||||
class GfmlAtr_mok implements GfmlItm_mok {
|
||||
public int ObjType() {return GfmlObj_.Type_atr;}
|
||||
public String Key() {return key;} public GfmlAtr_mok Key_(String v) {key = v; return this;} private String key;
|
||||
public String Val() {return val;} public GfmlAtr_mok Val_(String v) {val = v; return this;} private String val;
|
||||
public GfmlAtr XtoGfmlItm() {
|
||||
GfmlAtr rv = GfmlAtr.new_(GfmlTkn_.raw_(key), GfmlTkn_.raw_(val), GfmlType_.String);
|
||||
return rv;
|
||||
}
|
||||
public String XtoStrStub() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add_kv("key=", key).Add_kv("val=", val);
|
||||
return sb.XtoStr();
|
||||
}
|
||||
public static final GfmlAtr_mok Null = new GfmlAtr_mok().Key_(String_.Null_mark).Val_(String_.Null_mark);
|
||||
public static GfmlAtr_mok as_(Object obj) {return obj instanceof GfmlAtr_mok ? (GfmlAtr_mok)obj : null;}
|
||||
public static GfmlAtr_mok new_(String key, String val) {
|
||||
GfmlAtr_mok rv = new GfmlAtr_mok();
|
||||
rv.key = key; rv.val = val;
|
||||
return rv;
|
||||
} GfmlAtr_mok() {}
|
||||
}
|
||||
class GfmlNde_mok implements GfmlItm_mok {
|
||||
public int ObjType() {return GfmlObj_.Type_nde;}
|
||||
public String Key() {return key;} public GfmlNde_mok Key_(String v) {key = v; return this;} private String key;
|
||||
public String Hnd() {return hnd;} public GfmlNde_mok Hnd_(String v) {hnd = v; return this;} private String hnd;
|
||||
public String Typ() {return typ;} public GfmlNde_mok Typ_(String v) {typ = v; return this;} private String typ;
|
||||
public int ChainId() {return chainId;} public GfmlNde_mok ChainId_(int v) {chainId = v; return this;} int chainId = -1;
|
||||
public boolean KeyedSubObj() {return keyed;}
|
||||
public GfmlNde_mok KeyedSubObj_() {return KeyedSubObj_(true);}
|
||||
public GfmlNde_mok KeyedSubObj_(boolean v) {keyed = v; return this;} private boolean keyed;
|
||||
public List_adp Subs() {return subs;}
|
||||
public String XtoStrStub() {
|
||||
String_bldr sb = String_bldr_.new_();
|
||||
sb.Add_kv("key=", key).Add_kv("hnd=", hnd).Add_kv("typ=", typ).Add_kv("subs=", Int_.Xto_str(subs.Count()));
|
||||
return sb.XtoStr();
|
||||
}
|
||||
public GfmlNde_mok Subs_(GfmlItm_mok... ary) {
|
||||
for (GfmlItm_mok itm : ary)
|
||||
subs.Add(itm);
|
||||
return this;
|
||||
} List_adp subs = List_adp_.new_();
|
||||
|
||||
public GfmlNde_mok Atrk_(String k, String v) {subs.Add(GfmlAtr_mok.new_(k, v)); return this;}
|
||||
public GfmlNde_mok Atru_(String v) {subs.Add(GfmlAtr_mok.new_(GfmlTkn_.NullVal, v)); return this;}
|
||||
public GfmlNde_mok Atrs_(String... ary) {
|
||||
for (String itm : ary)
|
||||
subs.Add(GfmlAtr_mok.new_(GfmlTkn_.NullVal, itm));
|
||||
return this;
|
||||
}
|
||||
public GfmlNde XtoGfmlItm(GfmlTypRegy regy) {return XtoGfmlNde(regy, this);}
|
||||
static GfmlNde XtoGfmlNde(GfmlTypRegy regy, GfmlNde_mok ownerMok) {
|
||||
String tmpTypeKey = ownerMok.typ == null ? GfmlType_.AnyKey : ownerMok.typ;
|
||||
String tmpHnd = ownerMok.hnd == null ? "" : ownerMok.hnd;
|
||||
GfmlNde rv = GfmlNde.new_(GfmlTkn_.raw_(tmpHnd), regy.FetchOrNull(tmpTypeKey), ownerMok.key != null);
|
||||
rv.ChainId_(ownerMok.chainId);
|
||||
if (ownerMok.keyed) rv.KeyedSubObj_(ownerMok.keyed);
|
||||
if (ownerMok.key != null) rv.KeyTkn_set(GfmlTkn_.val_(ownerMok.key));
|
||||
for (int i = 0; i < ownerMok.subs.Count(); i++) {
|
||||
GfmlItm_mok itm = (GfmlItm_mok)ownerMok.subs.Get_at(i);
|
||||
if (itm.ObjType() == GfmlObj_.Type_nde) {
|
||||
GfmlNde_mok itmMok = (GfmlNde_mok)itm;
|
||||
rv.SubObjs_Add(itmMok.XtoGfmlItm(regy));
|
||||
}
|
||||
else {
|
||||
GfmlAtr_mok atrMok = (GfmlAtr_mok)itm;
|
||||
rv.SubObjs_Add(atrMok.XtoGfmlItm());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static GfmlNde_mok as_(Object obj) {return obj instanceof GfmlNde_mok ? (GfmlNde_mok)obj : null;}
|
||||
public static final GfmlNde_mok Null = new GfmlNde_mok().Hnd_(String_.Null_mark).Typ_(String_.Null_mark);
|
||||
public static final GfmlNde_mok ErrAtr = new GfmlNde_mok().Hnd_("<<ErrAtr>>").Typ_("<<ErrAtr>>");
|
||||
public static GfmlNde_mok new_() {return new GfmlNde_mok();} GfmlNde_mok() {}
|
||||
public static GfmlNde_mok gfmlNde_(GfmlNde nde) {return InitNde(nde);}
|
||||
static GfmlNde_mok InitNde(GfmlNde nde) {
|
||||
GfmlNde_mok rv = new GfmlNde_mok();
|
||||
rv.typ = nde.Type().Key();
|
||||
rv.hnd = nde.Hnd();
|
||||
rv.keyed = nde.KeyedSubObj();
|
||||
rv.chainId = nde.ChainId();
|
||||
if (nde.Key() != null) rv.key = nde.Key();
|
||||
for (int i = 0; i < nde.SubKeys().Count(); i++) {
|
||||
GfmlItm subItm = (GfmlItm)nde.SubKeys().Get_at(i);
|
||||
if (subItm.ObjType() == GfmlObj_.Type_atr) {
|
||||
GfmlAtr subAtr = (GfmlAtr)subItm;
|
||||
GfmlAtr_mok mokAtr = GfmlAtr_mok.new_(subAtr.Key(), subAtr.DatTkn().Val());
|
||||
if (!String_.Len_eq_0(subAtr.Key())) mokAtr.Key_(subAtr.Key());
|
||||
rv.subs.Add(mokAtr);
|
||||
}
|
||||
else {
|
||||
GfmlNde subNde = (GfmlNde)subItm;
|
||||
GfmlNde_mok mokNde = InitNde(subNde);
|
||||
rv.subs.Add(mokNde);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < nde.SubHnds().Count(); i++) {
|
||||
GfmlNde subNde = (GfmlNde)nde.SubHnds().Get_at(i);
|
||||
GfmlNde_mok mokNde = InitNde(subNde);
|
||||
rv.subs.Add(mokNde);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class GfmlTypeResolver_fxt {
|
||||
public GfmlType ini_MakeType(GfmlTyp_mok mok) {
|
||||
type = mok.XtoGfmlType();
|
||||
regy.Add(type);
|
||||
return type;
|
||||
}
|
||||
GfmlType type;
|
||||
public static void tst_Nde(TfdsTstr_fxt tstr, GfmlNde_mok expd, GfmlNde_mok actl) {
|
||||
expd = NullObj(expd); actl = NullObj(actl);
|
||||
if (expd.Typ() != null) tstr.Eq_str(expd.Typ(), actl.Typ(), "typ");
|
||||
if (expd.KeyedSubObj()) tstr.Eq_str(expd.KeyedSubObj(), actl.KeyedSubObj(), "keyed");
|
||||
if (expd.Key() != null) tstr.Eq_str(expd.Key(), actl.Key(), "key");
|
||||
if (expd.Hnd() != null) tstr.Eq_str(expd.Hnd(), actl.Hnd(), "hnd");
|
||||
if (expd.ChainId() != -1) tstr.Eq_str(expd.ChainId(), actl.ChainId(), "chainId");
|
||||
int max = tstr.List_Max(expd.Subs(), actl.Subs());
|
||||
for (int i = 0; i < max; i++) {
|
||||
GfmlItm_mok expdSub = (GfmlItm_mok)tstr.List_FetchAtOrNull(expd.Subs(), i);
|
||||
GfmlItm_mok actlSub = (GfmlItm_mok)tstr.List_FetchAtOrNull(actl.Subs(), i);
|
||||
tstr.SubName_push(Int_.Xto_str(i));
|
||||
if (expdSub == null) {
|
||||
GfmlNde_mok mm = GfmlNde_mok.as_(actlSub);
|
||||
String actlSubStr = mm == null ? "sub:null" : mm.XtoStrStub();
|
||||
tstr.Eq_str("nde:" + "sub:null", actlSubStr, "expdSub null");
|
||||
tstr.Fail();
|
||||
break;
|
||||
}
|
||||
else if (expdSub.ObjType() == GfmlObj_.Type_atr) {
|
||||
GfmlAtr_mok actlAtrMok = GfmlAtr_mok.as_(actlSub);
|
||||
tst_Nde(tstr, (GfmlAtr_mok)expdSub, actlAtrMok);
|
||||
}
|
||||
else {
|
||||
GfmlNde_mok actlMok = GfmlNde_mok.as_(actlSub);
|
||||
if (actlMok == null) {
|
||||
String actlSubStr = actlSub == null ? "sub:null" : "atr:" + ((GfmlAtr_mok)actlSub).XtoStrStub();
|
||||
tstr.Eq_str("nde:" + ((GfmlNde_mok)expdSub).XtoStrStub(), actlSubStr, "actlSub null");
|
||||
tstr.Fail();
|
||||
break;
|
||||
}
|
||||
tst_Nde(tstr, (GfmlNde_mok)expdSub, actlMok);
|
||||
}
|
||||
tstr.SubName_pop();
|
||||
}
|
||||
}
|
||||
static GfmlNde_mok NullObj(GfmlNde_mok v) {return v == null ? GfmlNde_mok.Null : v;}
|
||||
static GfmlAtr_mok NullObj(GfmlAtr_mok v) {return v == null ? GfmlAtr_mok.Null : v;}
|
||||
static void tst_Nde(TfdsTstr_fxt tstr, GfmlAtr_mok expd, GfmlAtr_mok actl) {
|
||||
expd = NullObj(expd); actl = NullObj(actl);
|
||||
if (expd.Key() != null) tstr.Eq_str(expd.Key(), actl.Key(), "key");
|
||||
if (expd.Val() != null) tstr.Eq_str(expd.Val(), actl.Val(), "val");
|
||||
}
|
||||
GfmlTypRegy regy = GfmlTypRegy.new_();
|
||||
public static GfmlTypeResolver_fxt new_() {
|
||||
GfmlTypeResolver_fxt rv = new GfmlTypeResolver_fxt();
|
||||
return rv;
|
||||
} GfmlTypeResolver_fxt() {}
|
||||
}
|
||||
77
110_gfml/tst/gplx/gfml/ymoks_GfmlTkn_mok.java
Normal file
77
110_gfml/tst/gplx/gfml/ymoks_GfmlTkn_mok.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlTkn_mok {
|
||||
public String Raw() {return raw;} public GfmlTkn_mok Raw_(String v) {raw = v; return this;} private String raw;
|
||||
public List_adp Subs() {return list;} List_adp list = List_adp_.new_();
|
||||
public GfmlTkn_mok Subs_(GfmlTkn_mok... ary) {
|
||||
for (GfmlTkn_mok itm : ary)
|
||||
list.Add(itm);
|
||||
return this;
|
||||
}
|
||||
// statics
|
||||
public static GfmlTkn_mok new_() {return new GfmlTkn_mok();} GfmlTkn_mok() {}
|
||||
public static GfmlTkn_mok gfmlNde_(GfmlNde nde) {
|
||||
GfmlTkn_mok rv = new GfmlTkn_mok();
|
||||
InitItm(rv, nde);
|
||||
return rv;
|
||||
}
|
||||
static void InitItm(GfmlTkn_mok rv, GfmlItm owner) {
|
||||
for (int i = 0; i < owner.SubObjs_Count(); i++) {
|
||||
GfmlObj subTkn = (GfmlObj)owner.SubObjs_GetAt(i);
|
||||
GfmlTkn_mok subMok = GfmlTkn_mok.new_();
|
||||
rv.Subs_(subMok);
|
||||
GfmlItm subItm = GfmlItm_.as_(subTkn);
|
||||
if (subItm != null)
|
||||
InitItm(subMok, subItm);
|
||||
else
|
||||
InitTkn(subMok, (GfmlTkn)subTkn);
|
||||
}
|
||||
}
|
||||
static void InitTkn(GfmlTkn_mok mok, GfmlTkn tkn) {
|
||||
if (tkn.SubTkns().length == 0) // leafTkn; no subs; simply set
|
||||
mok.Raw_(tkn.Raw());
|
||||
else { // compTkn; createTkn and iterate
|
||||
for (int i = 0; i < tkn.SubTkns().length; i++) {
|
||||
GfmlTkn subTkn = (GfmlTkn)tkn.SubTkns()[i];
|
||||
GfmlTkn_mok subMok = GfmlTkn_mok.new_();
|
||||
InitTkn(subMok, subTkn);
|
||||
mok.Subs_(subMok);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static GfmlTkn_mok[] Xto_bry(String... ary) {
|
||||
GfmlTkn_mok[] rv = new GfmlTkn_mok[ary.length];
|
||||
for (int i = 0; i < rv.length; i++)
|
||||
rv[i] = GfmlTkn_mok.new_().Raw_(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public static void tst(TfdsTstr_fxt tstr, GfmlTkn_mok expd, GfmlTkn_mok actl) {
|
||||
expd = NullObj(expd); actl = NullObj(actl);
|
||||
if (expd.Raw() != null) tstr.Eq_str(expd.Raw(), actl.Raw(), "raw");
|
||||
int max = tstr.List_Max(expd.Subs(), actl.Subs());
|
||||
for (int i = 0; i < max; i++) {
|
||||
GfmlTkn_mok expdSub = (GfmlTkn_mok)tstr.List_FetchAtOrNull(expd.Subs(), i);
|
||||
GfmlTkn_mok actlSub = (GfmlTkn_mok)tstr.List_FetchAtOrNull(actl.Subs(), i);
|
||||
tstr.SubName_push(Int_.Xto_str(i));
|
||||
tst(tstr, expdSub, actlSub);
|
||||
tstr.SubName_pop();
|
||||
}
|
||||
}
|
||||
static GfmlTkn_mok NullObj(GfmlTkn_mok v) {return v == null ? GfmlTkn_mok.new_().Raw_(String_.Null_mark) : v;}
|
||||
}
|
||||
83
110_gfml/tst/gplx/gfml/ymoks_GfmlTyp_GfmlFld_mok.java
Normal file
83
110_gfml/tst/gplx/gfml/ymoks_GfmlTyp_GfmlFld_mok.java
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlFld_mok {
|
||||
public String Name() {return name;} public GfmlFld_mok Name_(String v) {name = v; return this;} private String name;
|
||||
public String TypeKey() {return typeKey;} public GfmlFld_mok TypeKey_(String v) {typeKey = v; return this;} private String typeKey;
|
||||
public GfmlObj DefaultTkn() {return defaultTkn;}
|
||||
public GfmlFld_mok DefaultTkn_(GfmlObj v) {defaultTkn = v; return this;} GfmlObj defaultTkn = GfmlTkn_.Null;
|
||||
public GfmlFld_mok Default_(String v) {defaultTkn = GfmlTkn_.raw_(v); return this;}
|
||||
public String DefaultTknRaw() {return GfmlFld_mok.XtoRaw(defaultTkn);}
|
||||
public boolean KeyedSubObj() {return keyed;} private boolean keyed = false;
|
||||
public GfmlFld XtoGfmlFld() {
|
||||
GfmlFld rv = GfmlFld.new_(keyed, name, typeKey);
|
||||
rv.DefaultTkn_(defaultTkn);
|
||||
return rv;
|
||||
}
|
||||
public GfmlFld_mok ini_atr_(String name) {this.name = name; this.keyed = true; return this;}
|
||||
public GfmlFld_mok ini_ndk_(String name, String typKey) {this.name = name; this.typeKey = typKey; this.keyed = true; return this;}
|
||||
public static GfmlFld_mok new_() {return new GfmlFld_mok();} GfmlFld_mok() {}
|
||||
public static String XtoRaw(GfmlObj gobj) {
|
||||
if (gobj == null) return String_.Null_mark;
|
||||
GfmlTkn tkn = GfmlTkn_.as_(gobj);
|
||||
if (tkn != null) return tkn.Raw();
|
||||
GfmlNde nde = GfmlNde.as_(gobj);
|
||||
return nde.XtoStr();
|
||||
}
|
||||
}
|
||||
class GfmlTyp_mok {
|
||||
public String Name() {return name;} public GfmlTyp_mok Name_(String v) {name = v; return this;} private String name;
|
||||
public String Key() {return key;} public GfmlTyp_mok Key_(String v) {key = v; return this;} private String key;
|
||||
public List_adp Subs() {return subFlds;} List_adp subFlds = List_adp_.new_();
|
||||
public GfmlTyp_mok Atrs_(String... ary) {
|
||||
for (String itm : ary)
|
||||
subFlds.Add(GfmlFld_mok.new_().ini_atr_(itm));
|
||||
return this;
|
||||
}
|
||||
public GfmlTyp_mok Subs_(GfmlFld_mok... ary) {
|
||||
for (GfmlFld_mok itm : ary)
|
||||
subFlds.Add(itm);
|
||||
return this;
|
||||
}
|
||||
public GfmlType XtoGfmlType() {
|
||||
GfmlType rv = GfmlType_.new_(key, name); // all types in tests are top-level
|
||||
for (int i = 0; i < subFlds.Count(); i++) {
|
||||
GfmlFld_mok fld = (GfmlFld_mok)subFlds.Get_at(i);
|
||||
rv.SubFlds().Add(fld.XtoGfmlFld());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
public static GfmlTyp_mok new_() {return new GfmlTyp_mok();} GfmlTyp_mok() {}
|
||||
public static GfmlTyp_mok simple_(String name, String... flds) {
|
||||
GfmlTyp_mok rv = new GfmlTyp_mok();
|
||||
rv.key = name; rv.name = name;
|
||||
for (String fld : flds)
|
||||
rv.subFlds.Add(GfmlFld_mok.new_().ini_atr_(fld));
|
||||
return rv;
|
||||
}
|
||||
public static GfmlTyp_mok type_(GfmlType typ) {
|
||||
GfmlTyp_mok rv = new GfmlTyp_mok();
|
||||
rv.key = typ.Key(); rv.name = typ.NdeName();
|
||||
for (int i = 0; i < typ.SubFlds().Count(); i++) {
|
||||
GfmlFld fld = (GfmlFld)typ.SubFlds().Get_at(i);
|
||||
GfmlFld_mok mkFld = GfmlFld_mok.new_().ini_ndk_(fld.Name(), fld.TypeKey()).DefaultTkn_(fld.DefaultTkn());
|
||||
rv.subFlds.Add(mkFld);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
36
110_gfml/tst/gplx/gfml/ymoks_UsrMsg_mok.java
Normal file
36
110_gfml/tst/gplx/gfml/ymoks_UsrMsg_mok.java
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class UsrMsg_mok {
|
||||
public String Main() {return main;} public UsrMsg_mok Main_(String v) {main = v; return this;} private String main;
|
||||
public UsrMsg_mok Add_(String k, Object o) {hash.Add(k, KeyVal_.new_(k, o)); return this;}
|
||||
public UsrMsg_mok Require_(String k) {required.Add(k, k); return this;}
|
||||
public Ordered_hash Args() {return hash;} Ordered_hash hash = Ordered_hash_.new_();
|
||||
public Ordered_hash Required() {return required;} Ordered_hash required = Ordered_hash_.new_();
|
||||
public static UsrMsg_mok new_(UsrMsg um) {
|
||||
UsrMsg_mok rv = new UsrMsg_mok();
|
||||
if (um != null) {
|
||||
rv.main = um.Hdr();
|
||||
for (int i = 0; i < um.Args().Count(); i++) {
|
||||
KeyVal kv = (KeyVal)um.Args().Get_at(i);
|
||||
rv.Add_(kv.Key(), kv.Val());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
} UsrMsg_mok() {}
|
||||
}
|
||||
63
110_gfml/tst/gplx/gfml/z011_IntObjHash_tst.java
Normal file
63
110_gfml/tst/gplx/gfml/z011_IntObjHash_tst.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z011_IntObjHash_tst {
|
||||
@Before public void setup() {
|
||||
hash = new IntObjHash_base();
|
||||
} IntObjHash_base hash;
|
||||
@Test public void Empty() {
|
||||
tst_Count(0);
|
||||
tst_Fetch(1, null);
|
||||
}
|
||||
@Test public void Add() {
|
||||
hash.Add(1, "1");
|
||||
tst_Count(1);
|
||||
tst_Fetch(1, "1");
|
||||
tst_Fetch(2, null);
|
||||
}
|
||||
@Test public void Del() {
|
||||
hash.Add(1, "1");
|
||||
|
||||
hash.Del(1);
|
||||
tst_Count(0);
|
||||
tst_Fetch(1, null);
|
||||
}
|
||||
@Test public void Clear() {
|
||||
hash.Add(1, "1");
|
||||
hash.Add(32, "32");
|
||||
tst_Fetch(1, "1");
|
||||
tst_Fetch(32, "32");
|
||||
tst_Count(2);
|
||||
|
||||
hash.Clear();
|
||||
tst_Count(0);
|
||||
tst_Fetch(2, null);
|
||||
tst_Fetch(32, null);
|
||||
}
|
||||
@Test public void Add_bug() { // fails after expanding ary, and fetching at key=n*16
|
||||
hash.Add(1, "1");
|
||||
tst_Count(1);
|
||||
tst_Fetch(1, "1");
|
||||
tst_Fetch(15, null); // works
|
||||
tst_Fetch(17, null); // works
|
||||
tst_Fetch(16, null); // used to fail
|
||||
}
|
||||
void tst_Fetch(int key, Object expd) {Tfds.Eq(expd, hash.Get_by(key));}
|
||||
void tst_Count(int expd) {Tfds.Eq(expd, hash.Count());}
|
||||
}
|
||||
73
110_gfml/tst/gplx/gfml/z012_GfmlTrie_tst.java
Normal file
73
110_gfml/tst/gplx/gfml/z012_GfmlTrie_tst.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.texts.*; /*CharStream*/
|
||||
public class z012_GfmlTrie_tst {
|
||||
@Before public void setup() {
|
||||
trie = GfmlTrie.new_();
|
||||
} GfmlTrie trie;
|
||||
@Test public void Null() {
|
||||
tst_FindMatch_first("", null);
|
||||
tst_FindMatch_first("{", null);
|
||||
}
|
||||
@Test public void OneChar() {
|
||||
trie.Add("{", "val0");
|
||||
tst_FindMatch_first("{", "val0");
|
||||
tst_FindMatch_first(":", null);
|
||||
}
|
||||
@Test public void TwoChar() {
|
||||
trie.Add("/*", "val0");
|
||||
tst_FindMatch_first("/*", "val0");
|
||||
tst_FindMatch_first("//", null);
|
||||
}
|
||||
@Test public void ManySym() {
|
||||
trie.Add(":", "val0");
|
||||
trie.Add("{", "val1");
|
||||
tst_FindMatch_first(":", "val0");
|
||||
tst_FindMatch_first("{", "val1");
|
||||
tst_FindMatch_first("-", null);
|
||||
}
|
||||
@Test public void Overlap_1_2() {
|
||||
trie.Add("[", "val0");
|
||||
trie.Add("[:", "val1");
|
||||
tst_FindMatch_first("[", "val0");
|
||||
tst_FindMatch_first("[:", "val1");
|
||||
tst_FindMatch_first("[-", "val0");
|
||||
tst_FindMatch_first(":", null);
|
||||
}
|
||||
@Test public void Overlap_2_1() {
|
||||
trie.Add("[:", "val0");
|
||||
trie.Add("[", "val1");
|
||||
tst_FindMatch_first("[:", "val0");
|
||||
tst_FindMatch_first("[", "val1");
|
||||
tst_FindMatch_first("[-", "val1");
|
||||
tst_FindMatch_first(":", null);
|
||||
}
|
||||
@Test public void Overlap_1_1() {
|
||||
trie.Add("[", "val0");
|
||||
trie.Add("[", "val1");
|
||||
tst_FindMatch_first("[", "val1"); // return last added
|
||||
tst_FindMatch_first(":", null);
|
||||
}
|
||||
void tst_FindMatch_first(String text, String expd) {
|
||||
CharStream stream = CharStream.pos0_(text);
|
||||
String actl = (String)trie.FindMatch(stream);
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
52
110_gfml/tst/gplx/gfml/z015_GfmlDocPos_tst.java
Normal file
52
110_gfml/tst/gplx/gfml/z015_GfmlDocPos_tst.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z015_GfmlDocPos_tst {
|
||||
GfmlDocPos root = GfmlDocPos_.Root;
|
||||
@Test public void Root() {
|
||||
tst_Path(root, "0");
|
||||
}
|
||||
@Test public void MoveDown() {
|
||||
tst_Path(root.NewDown(0), "0_0");
|
||||
tst_Path(root.NewDown(0).NewDown(0), "0_0_0");
|
||||
tst_Path(root.NewDown(1).NewDown(2), "0_1_2");
|
||||
}
|
||||
@Test public void MoveUp() {
|
||||
tst_Path(root.NewDown(1).NewDown(2).NewUp(), "0_1");
|
||||
}
|
||||
@Test public void CompareTo_same() {
|
||||
GfmlDocPos lhs = root.NewDown(0);
|
||||
GfmlDocPos rhs = root.NewDown(0);
|
||||
tst_CompareTo(lhs, rhs, CompareAble_.Same);
|
||||
}
|
||||
@Test public void CompareTo_diffIndex() {
|
||||
GfmlDocPos lhs = root.NewDown(0);
|
||||
GfmlDocPos rhs = root.NewDown(1);
|
||||
tst_CompareTo(lhs, rhs, CompareAble_.Less);
|
||||
tst_CompareTo(rhs, lhs, CompareAble_.More);
|
||||
}
|
||||
@Test public void CompareTo_diffLevel() {
|
||||
GfmlDocPos lhs = root;
|
||||
GfmlDocPos rhs = root.NewDown(0);
|
||||
tst_CompareTo(lhs, rhs, CompareAble_.Less);
|
||||
tst_CompareTo(rhs, lhs, CompareAble_.More);
|
||||
}
|
||||
void tst_Path(GfmlDocPos pos, String expdPath) {Tfds.Eq(expdPath, pos.Path());}
|
||||
void tst_CompareTo(GfmlDocPos lhs, GfmlDocPos rhs, int expd) {Tfds.Eq(expd, lhs.compareTo(rhs));}
|
||||
}
|
||||
55
110_gfml/tst/gplx/gfml/z016_GfmlScopeList_tst.java
Normal file
55
110_gfml/tst/gplx/gfml/z016_GfmlScopeList_tst.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z016_GfmlScopeList_tst {
|
||||
@Before public void setup() {
|
||||
list = GfmlScopeList.new_("test");
|
||||
} GfmlScopeList list;
|
||||
@Test public void None() {
|
||||
tst_Itm(list, GfmlDocPos_.Root, null);
|
||||
}
|
||||
@Test public void One() {
|
||||
run_Add(list, var_("val1"));
|
||||
tst_Itm(list, GfmlDocPos_.Root, "val1");
|
||||
}
|
||||
@Test public void ByPos() {
|
||||
run_Add(list, var_("val1").DocPos_(docPos_(0, 0)));
|
||||
run_Add(list, var_("val2").DocPos_(docPos_(0, 0, 0)));
|
||||
tst_Itm(list, docPos_(0, 0), "val1");
|
||||
tst_Itm(list, docPos_(0, 0, 0), "val2");
|
||||
tst_Itm(list, docPos_(0, 1), "val1");
|
||||
tst_Itm(list, docPos_(0), null);
|
||||
}
|
||||
GfmlVarItm var_(String val) {return GfmlVarItm.new_("key", GfmlTkn_.raw_(val), GfmlVarCtx_.DefaultKey);}
|
||||
GfmlDocPos docPos_(int... ary) {
|
||||
int last = ary.length - 1;
|
||||
int idx = ary[last];
|
||||
int[] levels = (int[])Array_.Resize(ary, last);
|
||||
return new GfmlDocPos(levels, idx);
|
||||
}
|
||||
void run_Add(GfmlScopeList list, GfmlScopeItm... ary) {
|
||||
for (GfmlScopeItm itm : ary)
|
||||
list.Add(itm);
|
||||
}
|
||||
void tst_Itm(GfmlScopeList list, GfmlDocPos pos, String expd) {
|
||||
GfmlVarItm itm = (GfmlVarItm)list.Get_by(pos);
|
||||
String actl = itm == null ? null : itm.TknVal();
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
53
110_gfml/tst/gplx/gfml/z017_GfmlStringHighlighter_tst.java
Normal file
53
110_gfml/tst/gplx/gfml/z017_GfmlStringHighlighter_tst.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z017_GfmlStringHighlighter_tst {
|
||||
@Test public void Short() {
|
||||
tst_Err(sh_().Raw_("a=").Mark_(1, '=', "key tkn").Mark_(2, '?', "EOS:missing data")
|
||||
, "< >"
|
||||
, " a= "
|
||||
, " =?"
|
||||
, ""
|
||||
, "[1] = key tkn"
|
||||
, "[2] ? EOS:missing data"
|
||||
);
|
||||
}
|
||||
@Test public void Whitespace() {
|
||||
tst_Err(sh_().Raw_("a\t\nb").Mark_(0, ' ', "")
|
||||
, "< tn >"
|
||||
, " a b "
|
||||
, " "
|
||||
);
|
||||
}
|
||||
@Test public void Long() {
|
||||
tst_Err(sh_().Raw_("abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba").Mark_(0, '{', "bgn").Mark_(50, '}', "end")
|
||||
, "< >"
|
||||
, " abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba "
|
||||
, " { } "
|
||||
, ""
|
||||
, "[00] { bgn"
|
||||
, "[50] } end"
|
||||
);
|
||||
}
|
||||
GfmlStringHighlighter sh_() {return GfmlStringHighlighter.new_();}
|
||||
void tst_Err(GfmlStringHighlighter sh, String... expdLines) {
|
||||
String[] actlLines = sh.Gen();
|
||||
Tfds.Eq_ary_str(expdLines, actlLines);
|
||||
}
|
||||
}
|
||||
77
110_gfml/tst/gplx/gfml/z051_GfmlFldPool_keyed_tst.java
Normal file
77
110_gfml/tst/gplx/gfml/z051_GfmlFldPool_keyed_tst.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z051_GfmlFldPool_keyed_tst {
|
||||
@Before public void setup() {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
GfmlType type = makr.MakeSubType("point", "x", "y", "z");
|
||||
fldPool = GfmlFldPool.new_(type);
|
||||
} GfmlFldPool fldPool;
|
||||
@Test public void PopByKey_inOrder() {
|
||||
tst_Keyed_PopByKey(fldPool, "x", "x", "y", "z");
|
||||
}
|
||||
@Test public void PopByKey_outOfOrder() {
|
||||
tst_Keyed_PopByKey(fldPool, "y", "y", "x", "z");
|
||||
}
|
||||
@Test public void PopByKey_unknown() {
|
||||
tst_Keyed_PopByKey(fldPool, "a", GfmlItmKeys.NullKey, "x", "y", "z");
|
||||
}
|
||||
@Test public void PopByKey_alreadyRemoved() {
|
||||
tst_Keyed_PopByKey(fldPool, "x", "x", "y", "z");
|
||||
tst_Keyed_PopByKey(fldPool, "x", GfmlItmKeys.NullKey, "y", "z");
|
||||
}
|
||||
@Test public void PopByKey_depleted() {
|
||||
tst_Keyed_PopByKey(fldPool, "x", "x", "y", "z");
|
||||
tst_Keyed_PopByKey(fldPool, "y", "y", "z");
|
||||
tst_Keyed_PopByKey(fldPool, "z", "z");
|
||||
tst_Keyed_PopByKey(fldPool, "x", GfmlItmKeys.NullKey);
|
||||
}
|
||||
@Test public void PopNext_inOrder() {
|
||||
tst_Keyed_PopNext(fldPool, "x", "y", "z");
|
||||
tst_Keyed_PopNext(fldPool, "y", "z");
|
||||
tst_Keyed_PopNext(fldPool, "z");
|
||||
try {
|
||||
tst_Keyed_PopNext(fldPool, GfmlItmKeys.NullKey);
|
||||
Tfds.Fail("should have failed");
|
||||
}
|
||||
catch (Exception exc) {Exc_.Noop(exc);}
|
||||
}
|
||||
@Test public void PopByKey_PopNext() {
|
||||
tst_Keyed_PopByKey(fldPool, "y", "y", "x", "z");
|
||||
tst_Keyed_PopNext(fldPool, "x", "z");
|
||||
}
|
||||
void tst_Keyed_PopByKey(GfmlFldPool fldPool, String key, String expdFldId, String... expdSubs) {
|
||||
GfmlFld actlFld = fldPool.Keyed_PopByKey(key);
|
||||
Tfds.Eq(expdFldId, actlFld.Name());
|
||||
String[] actlSubs = new String[fldPool.Keyd_Count()];
|
||||
for (int i = 0; i < actlSubs.length; i++) {
|
||||
actlSubs[i] = fldPool.Keyd_FetchAt(i).Name();
|
||||
}
|
||||
Tfds.Eq_ary(expdSubs, actlSubs);
|
||||
}
|
||||
void tst_Keyed_PopNext(GfmlFldPool fldPool, String expdFldId, String... expdSubs) {
|
||||
GfmlFld actlFld = fldPool.Keyed_PopNext();
|
||||
Tfds.Eq(expdFldId, actlFld.Name());
|
||||
String[] actlSubs = new String[fldPool.Keyd_Count()];
|
||||
for (int i = 0; i < actlSubs.length; i++) {
|
||||
actlSubs[i] = fldPool.Keyd_FetchAt(i).Name();
|
||||
}
|
||||
Tfds.Eq_ary(expdSubs, actlSubs);
|
||||
}
|
||||
}
|
||||
71
110_gfml/tst/gplx/gfml/z081_GfmlDataWtr_tst.java
Normal file
71
110_gfml/tst/gplx/gfml/z081_GfmlDataWtr_tst.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z081_GfmlDataWtr_tst {
|
||||
@Before public void setup() {
|
||||
wtr = GfmlDataWtr.new_();
|
||||
wtr.WriteNodeBgn("root");
|
||||
} DataWtr wtr;
|
||||
@Test public void Basic() {
|
||||
tst_XtoStr(wtr, "root:;");
|
||||
}
|
||||
@Test public void Atr_one() {
|
||||
wtr.WriteData("key", "data");;
|
||||
tst_XtoStr(wtr, "root:key='data';");
|
||||
}
|
||||
@Test public void Atr_many() {
|
||||
wtr.WriteData("key1", "data1");
|
||||
wtr.WriteData("key2", "data2");
|
||||
tst_XtoStr(wtr, "root:key1='data1' key2='data2';");
|
||||
}
|
||||
@Test public void Nde_one() {
|
||||
wtr.WriteNodeBgn("sub0");
|
||||
tst_XtoStr(wtr, "root:{sub0:;}");
|
||||
}
|
||||
@Test public void Nde_many() {
|
||||
wtr.WriteNodeBgn("sub0");
|
||||
wtr.WriteNodeEnd();
|
||||
wtr.WriteNodeBgn("sub1");
|
||||
tst_XtoStr(wtr, "root:{sub0:;sub1:;}");
|
||||
}
|
||||
@Test public void Nde_nested() {
|
||||
wtr.WriteNodeBgn("sub0");
|
||||
wtr.WriteNodeBgn("sub1");
|
||||
tst_XtoStr(wtr, "root:{sub0:{sub1:;}}");
|
||||
}
|
||||
@Test public void OneAtrOneNde() {
|
||||
wtr.WriteData("key1", "data1");
|
||||
wtr.WriteNodeBgn("sub0");
|
||||
tst_XtoStr(wtr, "root:key1='data1'{sub0:;}");
|
||||
}
|
||||
@Test public void OneAtrOneNdeOneAtr() {
|
||||
wtr.WriteData("key1", "data1");
|
||||
wtr.WriteNodeBgn("sub0");
|
||||
wtr.WriteData("key2", "data2");
|
||||
tst_XtoStr(wtr, "root:key1='data1'{sub0:key2='data2';}");
|
||||
}
|
||||
@Test public void EscapeQuote() {
|
||||
wtr.WriteData("key", "data's");;
|
||||
tst_XtoStr(wtr, "root:key='data''s';");
|
||||
}
|
||||
void tst_XtoStr(DataWtr wtr, String expd) {
|
||||
String actl = wtr.XtoStr();
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
54
110_gfml/tst/gplx/gfml/z082_GfmlDataWtrOpts_tst.java
Normal file
54
110_gfml/tst/gplx/gfml/z082_GfmlDataWtrOpts_tst.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z082_GfmlDataWtrOpts_tst {
|
||||
@Before public void setup() {
|
||||
wtr = GfmlDataWtr.new_();
|
||||
wtr.WriteNodeBgn("root");
|
||||
} DataWtr wtr;
|
||||
@Test public void KeyedSpr() {
|
||||
wtr.InitWtr(GfmlDataWtrOpts.Key_const, GfmlDataWtrOpts.new_().KeyedSeparator_("\t"));
|
||||
wtr.WriteData("key1", "data1");
|
||||
wtr.WriteData("key2", "data2");
|
||||
tst_XtoStr(wtr, "root:key1='data1'\tkey2='data2';");
|
||||
}
|
||||
@Test public void IndentNamesOn() {
|
||||
wtr.InitWtr(GfmlDataWtrOpts.Key_const, GfmlDataWtrOpts.new_().IndentNodesOn_());
|
||||
wtr.WriteNodeBgn("nde1");
|
||||
wtr.WriteNodeBgn("nde2");
|
||||
wtr.WriteNodeEnd();
|
||||
tst_XtoStr(wtr, String_.Concat_lines_crlf
|
||||
( "root:{"
|
||||
, " nde1:{"
|
||||
, " nde2:;"
|
||||
, " }"
|
||||
, "}"
|
||||
));
|
||||
}
|
||||
@Test public void IgnoreNullNamesOn() {
|
||||
wtr.InitWtr(GfmlDataWtrOpts.Key_const, GfmlDataWtrOpts.new_().IgnoreNullNamesOn_());
|
||||
wtr.WriteNodeBgn("");
|
||||
wtr.WriteData("key1", "data1");
|
||||
tst_XtoStr(wtr, String_.Concat("root:{key1='data1';}"));
|
||||
}
|
||||
void tst_XtoStr(DataWtr wtr, String expd) {
|
||||
String actl = wtr.XtoStr();
|
||||
Tfds.Eq(expd, actl);
|
||||
}
|
||||
}
|
||||
68
110_gfml/tst/gplx/gfml/z091_GfmlLxr_basic_tst.java
Normal file
68
110_gfml/tst/gplx/gfml/z091_GfmlLxr_basic_tst.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.texts.*; /*CharStream*/
|
||||
public class z091_GfmlLxr_basic_tst {
|
||||
@Before public void setup() {
|
||||
rootLxr = GfmlLxr_.general_("gfml.root", GfmlTkn_.cmd_("tkn:text", GfmlBldrCmd_.Null));
|
||||
} GfmlLxr rootLxr;
|
||||
@Test public void Empty() {
|
||||
tst_Fetch("");
|
||||
}
|
||||
@Test public void General() {
|
||||
tst_Fetch("text", "text");
|
||||
}
|
||||
@Test public void Solo() {
|
||||
ini_AddSymbol(",");
|
||||
tst_Fetch(",", ",");
|
||||
tst_Fetch(",data0", ",", "data0");
|
||||
tst_Fetch("data0,", "data0", ",");
|
||||
tst_Fetch("data0,data1", "data0", ",", "data1");
|
||||
}
|
||||
@Test public void Range() {
|
||||
ini_AddRange(" ", "\t");
|
||||
tst_Fetch(" ", " ");
|
||||
tst_Fetch(" a", " ", "a");
|
||||
tst_Fetch("\t ", "\t ");
|
||||
tst_Fetch("\ta ", "\t", "a", " ");
|
||||
}
|
||||
void ini_AddSymbol(String symbol) {
|
||||
GfmlTkn tkn = GfmlTkn_.singleton_("tkn", symbol, symbol, GfmlBldrCmd_.Null);
|
||||
GfmlLxr lxr = GfmlLxr_.solo_(symbol, tkn);
|
||||
rootLxr.SubLxr_Add(lxr);
|
||||
}
|
||||
void ini_AddRange(String... symbols) {
|
||||
GfmlTkn tkn = GfmlTkn_.cmd_("tkn", GfmlBldrCmd_.Null);
|
||||
GfmlLxr lxr = GfmlLxr_.range_("merge", symbols, tkn, false);
|
||||
rootLxr.SubLxr_Add(lxr);
|
||||
}
|
||||
GfmlTkn tst_Fetch(String raw, String... expd) {
|
||||
CharStream stream = CharStream.pos0_(raw);
|
||||
List_adp list = List_adp_.new_();
|
||||
GfmlTkn tkn = null;
|
||||
while (true) {
|
||||
tkn = rootLxr.MakeTkn(stream, 0);
|
||||
if (tkn == GfmlTkn_.EndOfStream) break;
|
||||
list.Add(tkn.Raw());
|
||||
}
|
||||
String[] actl = (String[])list.To_ary(String.class);
|
||||
Tfds.Eq_ary(expd, actl);
|
||||
return tkn;
|
||||
}
|
||||
}
|
||||
50
110_gfml/tst/gplx/gfml/z101_core_ndeInline_tst.java
Normal file
50
110_gfml/tst/gplx/gfml/z101_core_ndeInline_tst.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z101_core_ndeInline_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.NdeInline_lxr());
|
||||
}
|
||||
@Test public void One() {
|
||||
fx.tst_Doc("a;", fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn("a;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(";")
|
||||
));
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Doc("a;b;"
|
||||
, fx.nde_().Atru_("a")
|
||||
, fx.nde_().Atru_("b")
|
||||
);
|
||||
fx.tst_Tkn("a;b;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("b")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
79
110_gfml/tst/gplx/gfml/z102_core_whitespace_tst.java
Normal file
79
110_gfml/tst/gplx/gfml/z102_core_whitespace_tst.java
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z102_core_whitespace_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Whitespace_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Space() {
|
||||
fx.tst_Doc("a b;", fx.nde_().Atru_("a").Atru_("b"));
|
||||
fx.tst_Tkn("a b;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(" ")
|
||||
, fx.tkn_grp_ary_("b")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Tab() {
|
||||
fx.tst_Doc("a\tb;", fx.nde_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
@Test public void NewLine() {
|
||||
fx.tst_Doc(String_.Format("a{0}b;", String_.CrLf), fx.nde_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
@Test public void MergeSameWs() {
|
||||
fx.tst_Doc("a b;", fx.nde_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
@Test public void MergeDiffWs() {
|
||||
fx.tst_Doc("a\t b;", fx.nde_().Atru_("a").Atru_("b"));
|
||||
fx.tst_Tkn("a\t b;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_("\t ")
|
||||
, fx.tkn_grp_ary_("b")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void LeadingWs() {
|
||||
fx.tst_Doc(" a;", fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn(" a;"
|
||||
, fx.tkn_itm_(" ")
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void TrailingWs() {
|
||||
fx.tst_Doc("a ;", fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn("a ;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(" ")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
52
110_gfml/tst/gplx/gfml/z103_core_elmKey_tst.java
Normal file
52
110_gfml/tst/gplx/gfml/z103_core_elmKey_tst.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z103_core_elmKey_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.ElmKey_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("a=b;", fx.nde_().Atrk_("a", "b"));
|
||||
fx.tst_Tkn("a=b;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a", "=", "b")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Ws() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
fx.tst_Tkn("a = b;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a", " ", "=", " ", "b")
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
// @Test public void Err_NotNamed() {
|
||||
// fx.tst_Err("=", GfmlOutCmds.DatTkn_notFound_Err_());
|
||||
// }
|
||||
// @Test public void Err_NotValued() {
|
||||
// fx.tst_Err("a=;", GfmlOutCmds.elmKey_notValued_Err());
|
||||
// }
|
||||
}
|
||||
51
110_gfml/tst/gplx/gfml/z111_core_comment0_tst.java
Normal file
51
110_gfml/tst/gplx/gfml/z111_core_comment0_tst.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z111_core_comment0_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Whitespace_lxr() // add whitespace to make sure it has no effect
|
||||
, GfmlDocLxrs.Comment0_lxr() // bgn=// end=\n
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("//a" + String_.Lf);
|
||||
fx.tst_Tkn("//a" + String_.Lf
|
||||
, fx.tkn_grp_ary_("//", "a", String_.Lf)
|
||||
);
|
||||
}
|
||||
@Test public void Data() {
|
||||
fx.tst_Doc("a;//b" + String_.Lf, fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn("a;//b" + String_.Lf
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(";"))
|
||||
, fx.tkn_grp_ary_("//", "b", String_.Lf)
|
||||
);
|
||||
}
|
||||
// @Test public void DanglingBgn() {
|
||||
// try {
|
||||
// fx.tst_Err("//", GfmlOutCmds.Frame_danglingBgn_Err_());
|
||||
// Tfds.Fail_expdError();
|
||||
// }
|
||||
// catch (Exception exc) {Exc_.Noop(exc);}
|
||||
// }
|
||||
}
|
||||
69
110_gfml/tst/gplx/gfml/z112_core_comment1_tst.java
Normal file
69
110_gfml/tst/gplx/gfml/z112_core_comment1_tst.java
Normal file
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z112_core_comment1_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Comment1_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("/*a*/");
|
||||
fx.tst_Tkn("/*a*/"
|
||||
, fx.tkn_grp_ary_("/*", "a", "*/")
|
||||
);
|
||||
}
|
||||
@Test public void Data() {
|
||||
fx.tst_Doc("a;/*b*/", fx.nde_().Atru_("a"));
|
||||
fx.tst_Tkn("a;/*b*/"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_itm_(";"))
|
||||
, fx.tkn_grp_ary_("/*", "b", "*/")
|
||||
);
|
||||
}
|
||||
@Test public void IgnoreWs() {
|
||||
fx.tst_Tkn("/* b c */"
|
||||
, fx.tkn_grp_ary_("/*", " b c ", "*/")
|
||||
);
|
||||
}
|
||||
@Test public void EscapeBgn() {
|
||||
fx.tst_Tkn("/* /*/* */"
|
||||
, fx.tkn_grp_ary_("/*", " ", "/*/*", " ", "*/")
|
||||
);
|
||||
}
|
||||
@Test public void EscapeEnd() {
|
||||
fx.tst_Tkn("/* */*/ */"
|
||||
, fx.tkn_grp_ary_("/*", " ", "*/*/", " ", "*/")
|
||||
);
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fx.tst_Tkn("/* b0 /* c */ b1 */"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("/*")
|
||||
, fx.tkn_itm_(" b0 ")
|
||||
, fx.tkn_grp_ary_("/*", " c ", "*/")
|
||||
, fx.tkn_itm_(" b1 ")
|
||||
, fx.tkn_itm_("*/")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
41
110_gfml/tst/gplx/gfml/z120_quotes_eval0_tst.java
Normal file
41
110_gfml/tst/gplx/gfml/z120_quotes_eval0_tst.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z120_quotes_eval0_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Eval0_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("<~t>;", fx.nde_().Atru_("\t"));
|
||||
fx.tst_Tkn("<~t>;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("<~", "t", ">"))
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void DoublingIsNotEscaping() {
|
||||
fx.tst_Doc("<~t>>>;", fx.nde_().Atru_("\t").Atru_(">>")); // >> does not resolve to >
|
||||
}
|
||||
}
|
||||
52
110_gfml/tst/gplx/gfml/z121_quotes_quotes0_tst.java
Normal file
52
110_gfml/tst/gplx/gfml/z121_quotes_quotes0_tst.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z121_quotes_quotes0_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Quote0_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("'abc';", fx.nde_().Atru_("abc"));
|
||||
fx.tst_Tkn("'abc';"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("'", "abc", "'"))
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Escape() {
|
||||
fx.tst_Doc("'a''b';", fx.nde_().Atru_("a'b"));
|
||||
fx.tst_Tkn("'a''b';"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("'", "a", "''", "b", "'"))
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void ManyAtrs_LastQuoted() { // bugfix
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
fx.tst_Doc("a 'b';", fx.nde_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
}
|
||||
64
110_gfml/tst/gplx/gfml/z122_quotes_quote0_eval0_tst.java
Normal file
64
110_gfml/tst/gplx/gfml/z122_quotes_quote0_eval0_tst.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z122_quotes_quote0_eval0_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Quote0_Eval0_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("'a<~t>b';", fx.nde_().Atru_("a\tb"));
|
||||
fx.tst_Tkn("'a<~t>b';"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_itm_("'")
|
||||
, fx.tkn_itm_("a")
|
||||
, fx.tkn_grp_ary_("<~", "t", ">")
|
||||
, fx.tkn_itm_("b")
|
||||
, fx.tkn_itm_("'")
|
||||
))
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void QuoteInside() {
|
||||
fx.tst_Doc("'a<~'t'>b';", fx.nde_().Atru_("a\tb"));
|
||||
fx.tst_Tkn("'a<~'t'>b';"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_itm_("'")
|
||||
, fx.tkn_itm_("a")
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("<~")
|
||||
, fx.tkn_grp_ary_("'", "t", "'")
|
||||
, fx.tkn_itm_(">")
|
||||
)
|
||||
, fx.tkn_itm_("b")
|
||||
, fx.tkn_itm_("'")
|
||||
))
|
||||
, fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
40
110_gfml/tst/gplx/gfml/z123_quotes_quoteBlock_tst.java
Normal file
40
110_gfml/tst/gplx/gfml/z123_quotes_quoteBlock_tst.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z123_quotes_quoteBlock_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.QuoteBlock_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("|'abc'|;", fx.nde_().Atru_("abc"));
|
||||
}
|
||||
@Test public void Escape_bgn() {
|
||||
fx.tst_Doc("|'a|'|'b'|;", fx.nde_().Atru_("a|'b"));
|
||||
}
|
||||
@Test public void Escape_end() {
|
||||
fx.tst_Doc("|'a'|'|b'|;", fx.nde_().Atru_("a'|b"));
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fx.tst_Doc("|'a|'-'|b'|;", fx.nde_().Atru_("a-b"));
|
||||
}
|
||||
}
|
||||
61
110_gfml/tst/gplx/gfml/z124_quotes_quoteFold_tst.java
Normal file
61
110_gfml/tst/gplx/gfml/z124_quotes_quoteFold_tst.java
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z124_quotes_quoteFold_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.QuoteFold_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Quote() {
|
||||
fx.tst_Doc("^'a b'^;", fx.nde_().Atru_("a b"));
|
||||
}
|
||||
@Test public void Tab() {
|
||||
fx.tst_Doc("^'a\tb'^;", fx.nde_().Atru_("ab"));
|
||||
fx.tst_Tkn("^'a\tb'^;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("^'", "a", "\t", "b", "'^"))
|
||||
, fx.tkn_itm_(";"))
|
||||
);
|
||||
}
|
||||
@Test public void NewLine() {
|
||||
fx.tst_Doc(String_.Concat("^'a", String_.CrLf, "b'^;"), fx.nde_().Atru_("ab"));
|
||||
}
|
||||
@Test public void Eval() {
|
||||
fx.tst_Doc("^'a<~t>b'^;", fx.nde_().Atru_("a\tb"));
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fx.tst_Doc("^'a^'-'^b'^;", fx.nde_().Atru_("a-b"));
|
||||
}
|
||||
@Test public void EscapeBgn() {
|
||||
fx.tst_Doc("^'a^'^'b'^;", fx.nde_().Atru_("a^'b"));
|
||||
}
|
||||
@Test public void EscapeEnd() {
|
||||
fx.tst_Doc("^'a'^'^b'^;", fx.nde_().Atru_("a'^b"));
|
||||
}
|
||||
@Test public void Comment0() {
|
||||
fx.tst_Doc(String_.Concat("^'a//comment", String_.CrLf, "b'^;"), fx.nde_().Atru_("ab"));
|
||||
}
|
||||
@Test public void Comment1() {
|
||||
fx.tst_Doc("^'a/*comment*/b'^;", fx.nde_().Atru_("ab"));
|
||||
}
|
||||
}
|
||||
65
110_gfml/tst/gplx/gfml/z151_ndeSubs_basic_tst.java
Normal file
65
110_gfml/tst/gplx/gfml/z151_ndeSubs_basic_tst.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z151_ndeSubs_basic_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("{}", fx.nde_());
|
||||
fx.tst_Tkn("{}"
|
||||
, fx.tkn_grp_ary_("{", "}")
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Doc("{}{}", fx.nde_(), fx.nde_());
|
||||
}
|
||||
@Test public void Nested() {
|
||||
fx.tst_Doc("{{}}"
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_())
|
||||
);
|
||||
}
|
||||
@Test public void NestedMany() {
|
||||
fx.tst_Doc("{{}{}}"
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_()
|
||||
, fx.nde_()
|
||||
));
|
||||
}
|
||||
@Test public void Complex() {
|
||||
fx.tst_Doc(String_.Concat
|
||||
( "{"
|
||||
, "{"
|
||||
, "{}"
|
||||
, "}"
|
||||
, "{}"
|
||||
, "}"
|
||||
)
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Subs_
|
||||
( fx.nde_())
|
||||
, fx.nde_()
|
||||
));
|
||||
}
|
||||
}
|
||||
68
110_gfml/tst/gplx/gfml/z152_ndeSubs_data_tst.java
Normal file
68
110_gfml/tst/gplx/gfml/z152_ndeSubs_data_tst.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z152_ndeSubs_data_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Whitespace_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void ToInline() {
|
||||
fx.tst_Doc("{a;}"
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Atru_("a"))
|
||||
);
|
||||
}
|
||||
@Test public void ToInline_many() {
|
||||
fx.tst_Doc("{a b;}"
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Atru_("a").Atru_("b"))
|
||||
);
|
||||
}
|
||||
@Test public void ToBody() {
|
||||
fx.tst_Doc("{a{}}"
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Atru_("a"))
|
||||
);
|
||||
}
|
||||
@Test public void ToBody_many() {
|
||||
fx.tst_Doc("{a b{}}"
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Atru_("a").Atru_("b"))
|
||||
);
|
||||
}
|
||||
@Test public void ToBody_manyNest() {
|
||||
fx.tst_Doc("a{b;}"
|
||||
, fx.nde_().Atru_("a").Subs_
|
||||
( fx.nde_().Atru_("b"))
|
||||
);
|
||||
}
|
||||
@Test public void ToBody_many2() {
|
||||
fx.tst_Doc("a{b{c;}}"
|
||||
, fx.nde_().Atru_("a").Subs_
|
||||
( fx.nde_().Atru_("b").Subs_
|
||||
( fx.nde_().Atru_("c"))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
46
110_gfml/tst/gplx/gfml/z161_ndeHdrs_inline_tst.java
Normal file
46
110_gfml/tst/gplx/gfml/z161_ndeHdrs_inline_tst.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z161_ndeHdrs_inline_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeHeader_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.Whitespace_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("a:;", fx.nde_().Hnd_("a"));
|
||||
fx.tst_Tkn("a:;"
|
||||
, fx.tkn_grp_ary_("a", ":", ";")
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Doc("a:;b:;"
|
||||
, fx.nde_().Hnd_("a")
|
||||
, fx.nde_().Hnd_("b")
|
||||
);
|
||||
}
|
||||
@Test public void Ws() {
|
||||
fx.tst_Tkn("a : ;"
|
||||
, fx.tkn_grp_ary_("a", " ", ":", " ", ";")
|
||||
);
|
||||
}
|
||||
}
|
||||
33
110_gfml/tst/gplx/gfml/z162_ndeHdrs_err_tst.java
Normal file
33
110_gfml/tst/gplx/gfml/z162_ndeHdrs_err_tst.java
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z162_ndeHdrs_err_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeHeader_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void NotNamed() {
|
||||
fx.tst_Err(":", UsrMsg_mok.new_(GfmlUsrMsgs.fail_DatTkn_notFound()));
|
||||
}
|
||||
@Test public void Dangling() {
|
||||
fx.tst_Err("a{", UsrMsg_mok.new_(GfmlUsrMsgs.fail_Frame_danglingBgn()));
|
||||
}
|
||||
}
|
||||
52
110_gfml/tst/gplx/gfml/z163_ndeHdrs_body_tst.java
Normal file
52
110_gfml/tst/gplx/gfml/z163_ndeHdrs_body_tst.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z163_ndeHdrs_body_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeHeader_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("a:{}", fx.nde_().Hnd_("a"));
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Doc("a:{}b:{}"
|
||||
, fx.nde_().Hnd_("a")
|
||||
, fx.nde_().Hnd_("b")
|
||||
);
|
||||
}
|
||||
@Test public void Nested() {
|
||||
fx.tst_Doc("a:{b:{}}"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().Hnd_("b"))
|
||||
);
|
||||
}
|
||||
@Test public void NestedMany() {
|
||||
fx.tst_Doc("a:{b:{}c:{}}"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().Hnd_("b")
|
||||
, fx.nde_().Hnd_("c")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
53
110_gfml/tst/gplx/gfml/z164_hdeHdrs_data_tst.java
Normal file
53
110_gfml/tst/gplx/gfml/z164_hdeHdrs_data_tst.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z164_hdeHdrs_data_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.Whitespace_lxr()
|
||||
, GfmlDocLxrs.NdeHeader_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Bas1() {
|
||||
fx.tst_Tkn("a:b;"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("a")
|
||||
, fx.tkn_itm_(":")
|
||||
, fx.tkn_grp_ary_("b")
|
||||
, fx.tkn_itm_(";")
|
||||
));
|
||||
}
|
||||
@Test public void Basic3() {
|
||||
fx.tst_Tkn("a:b{c;}"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("a")
|
||||
, fx.tkn_itm_(":")
|
||||
, fx.tkn_grp_ary_("b")
|
||||
, fx.tkn_itm_("{")
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("c")
|
||||
, fx.tkn_itm_(";"))
|
||||
, fx.tkn_itm_("}")
|
||||
));
|
||||
}
|
||||
}
|
||||
65
110_gfml/tst/gplx/gfml/z181_ndeDots_basic_tst.java
Normal file
65
110_gfml/tst/gplx/gfml/z181_ndeDots_basic_tst.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z181_ndeDots_basic_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeDot_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void One() {
|
||||
fx.tst_Doc("{a.b;c;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1)
|
||||
)
|
||||
, fx.nde_().Atru_("c").ChainId_(0)
|
||||
));
|
||||
fx.tst_Tkn("{a.b;c;}"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("{")
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("a")
|
||||
, fx.tkn_itm_(".")
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("b")
|
||||
, fx.tkn_itm_(";"))
|
||||
)
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("c")
|
||||
, fx.tkn_itm_(";"))
|
||||
, fx.tkn_itm_("}")
|
||||
));
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Doc("{a.b.c.d;e;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("c").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("d").ChainId_(1)
|
||||
)))
|
||||
, fx.nde_().ChainId_(0).Atru_("e")
|
||||
));
|
||||
}
|
||||
}
|
||||
73
110_gfml/tst/gplx/gfml/z182_ndeDots_subs_tst.java
Normal file
73
110_gfml/tst/gplx/gfml/z182_ndeDots_subs_tst.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z182_ndeDots_subs_tst {
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeDot_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
);
|
||||
} GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("{a.b{}z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1)
|
||||
)
|
||||
, fx.nde_().Atru_("z").ChainId_(0)
|
||||
));
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.NdeHeader_lxr());
|
||||
fx.tst_Doc("{a.b.c{d:e;}z;}" // shorthand of {a{b{c{d:e;}}}}
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("c").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("d").ChainId_(0).Atru_("e")
|
||||
)
|
||||
)
|
||||
)
|
||||
, fx.nde_().ChainId_(0).Atru_("z")
|
||||
));
|
||||
}
|
||||
@Test public void Chain() {
|
||||
fx.tst_Doc("{a.b.c;z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("c").ChainId_(1))
|
||||
)
|
||||
, fx.nde_().ChainId_(0).Atru_("z")
|
||||
));
|
||||
}
|
||||
@Test public void NdeHdr() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.NdeHeader_lxr());
|
||||
fx.tst_Doc("{a:b.c;z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").Atru_("b").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("c").ChainId_(1)//.Subs_
|
||||
// ( fx.nde_().Hnd_("c"))
|
||||
)
|
||||
, fx.nde_().Atru_("z").ChainId_(0)
|
||||
));
|
||||
}
|
||||
}
|
||||
140
110_gfml/tst/gplx/gfml/z183_ndeDots_parens_tst.java
Normal file
140
110_gfml/tst/gplx/gfml/z183_ndeDots_parens_tst.java
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z183_ndeDots_parens_tst {
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeDot_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
, GfmlDocLxrs.NdeHdrBgn_lxr()
|
||||
, GfmlDocLxrs.NdeHdrEnd_lxr()
|
||||
);
|
||||
} GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("{a.b(c);z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c")
|
||||
)
|
||||
, fx.nde_().ChainId_(0).Atru_("z")
|
||||
));
|
||||
}
|
||||
@Test public void Basic_tkn() {
|
||||
//A_('1');
|
||||
fx.tst_Tkn("a(c);"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("a"), fx.tkn_itm_("(")
|
||||
, fx.tkn_grp_(fx.tkn_itm_("c"))
|
||||
, fx.tkn_itm_(")"), fx.tkn_itm_(";")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Basic2_tkn() {
|
||||
fx.tst_Tkn("a.b(c);"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("a"), fx.tkn_itm_(".")
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_itm_("b"), fx.tkn_itm_("("), fx.tkn_grp_ary_("c"), fx.tkn_itm_(")"), fx.tkn_itm_(";")
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
fx.tst_Doc("{a.b(c d e);z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c").Atru_("d").Atru_("e")
|
||||
)
|
||||
, fx.nde_().ChainId_(0).Atru_("z")
|
||||
));
|
||||
}
|
||||
// @Test public void Many2() {
|
||||
// fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
// fx.tst_Doc("{a.b(c){d();}}"
|
||||
// , fx.nde_().ChainId_(0).Subs_
|
||||
// ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
// ( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c").Subs_
|
||||
// ( fx.nde_().Hnd_("d")
|
||||
// )
|
||||
// )
|
||||
// ));
|
||||
// }
|
||||
@Test public void Chain() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
fx.tst_Doc("{a.b(c).d(e);z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).Atru_("c").Subs_
|
||||
( fx.nde_().Hnd_("d").ChainId_(1).Atru_("e")
|
||||
)
|
||||
)
|
||||
, fx.nde_().ChainId_(0).Atru_("z")
|
||||
));
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fx.tst_Doc("{a.b(c.d);z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).KeyedSubObj_(false).Subs_
|
||||
( fx.nde_().Hnd_("c").ChainId_(2).KeyedSubObj_(true).Subs_
|
||||
( fx.nde_().Hnd_("d").ChainId_(2).KeyedSubObj_(false)
|
||||
)
|
||||
)
|
||||
)
|
||||
, fx.nde_().Atru_("z")
|
||||
));
|
||||
}
|
||||
@Test public void Nest_longer() {
|
||||
fx.tst_Doc("{a.b.c(d.e.f);z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").KeyedSubObj_(false).ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("c").KeyedSubObj_(false).ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("d").KeyedSubObj_(true).ChainId_(2).Subs_
|
||||
( fx.nde_().Hnd_("e").KeyedSubObj_(false).ChainId_(2).Subs_
|
||||
( fx.nde_().Hnd_("f").KeyedSubObj_(false).ChainId_(2)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
, fx.nde_().Atru_("z")
|
||||
));
|
||||
}
|
||||
@Test public void Nest_deeper() {
|
||||
fx.tst_Doc("{a.b(c.d(e.f));z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").KeyedSubObj_(false).ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("c").KeyedSubObj_(true).ChainId_(2).Subs_
|
||||
( fx.nde_().Hnd_("d").KeyedSubObj_(false).ChainId_(2).Subs_
|
||||
( fx.nde_().Hnd_("e").KeyedSubObj_(true).ChainId_(3).Subs_
|
||||
( fx.nde_().Hnd_("f").KeyedSubObj_(false).ChainId_(3)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
, fx.nde_().Atru_("z")
|
||||
));
|
||||
}
|
||||
}
|
||||
47
110_gfml/tst/gplx/gfml/z184_ndeDots_atrSpr_tst.java
Normal file
47
110_gfml/tst/gplx/gfml/z184_ndeDots_atrSpr_tst.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z184_ndeDots_atrSpr_tst {
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeDot_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
, GfmlDocLxrs.NdeHdrBgn_lxr()
|
||||
, GfmlDocLxrs.NdeHdrEnd_lxr()
|
||||
, GfmlDocLxrs.AtrSpr_lxr()
|
||||
);
|
||||
} GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Test public void NestMult() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.AtrSpr_lxr());
|
||||
fx.tst_Doc("{a.b(c.d,e.f);z;}"
|
||||
, fx.nde_().ChainId_(0).Subs_
|
||||
( fx.nde_().Hnd_("a").ChainId_(1).Subs_
|
||||
( fx.nde_().Hnd_("b").ChainId_(1).KeyedSubObj_(false).Subs_
|
||||
( fx.nde_().Hnd_("c").ChainId_(2).KeyedSubObj_(true).Subs_
|
||||
( fx.nde_().Hnd_("d").ChainId_(2).KeyedSubObj_(false))
|
||||
, fx.nde_().Hnd_("e").ChainId_(3).KeyedSubObj_(true).Subs_
|
||||
( fx.nde_().Hnd_("f").ChainId_(3).KeyedSubObj_(false))
|
||||
)
|
||||
)
|
||||
, fx.nde_().ChainId_(0).Atru_("z")
|
||||
));
|
||||
}
|
||||
}
|
||||
120
110_gfml/tst/gplx/gfml/z191_ndeProps_basic_tst.java
Normal file
120
110_gfml/tst/gplx/gfml/z191_ndeProps_basic_tst.java
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z191_ndeProps_basic_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdePropBgn_lxr()
|
||||
, GfmlDocLxrs.NdePropEnd_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
, GfmlDocLxrs.NdeHeader_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Doc("a:[b]{}"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("b"))
|
||||
);
|
||||
}
|
||||
@Test public void Basic_empty() {
|
||||
fx.tst_Tkn("[];"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("[", "]")
|
||||
, fx.tkn_itm_(";")
|
||||
));
|
||||
}
|
||||
@Test public void Hdr() {
|
||||
fx.tst_Tkn("a[];"
|
||||
, fx.tkn_grp_
|
||||
( fx.tkn_grp_ary_("a")
|
||||
, fx.tkn_grp_ary_("[", "]")
|
||||
, fx.tkn_itm_(";")
|
||||
));
|
||||
}
|
||||
@Test public void WithInnerNde() {
|
||||
fx.tst_Doc("a:[b]{c;}"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("b")
|
||||
, fx.nde_().Atru_("c")
|
||||
));
|
||||
}
|
||||
@Test public void DoesNotUsurpDatTknForName() {
|
||||
fx.tst_Doc("a:b[c]{}"
|
||||
, fx.nde_().Hnd_("a").Atru_("b").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("c")
|
||||
));
|
||||
}
|
||||
@Test public void NoHeader_body() {
|
||||
fx.tst_Doc("a[b]{}"
|
||||
, fx.nde_().Atru_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("b")
|
||||
));
|
||||
}
|
||||
@Test public void NoHeader_inline() {
|
||||
fx.tst_Doc("a[b];"
|
||||
, fx.nde_().Atru_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("b")
|
||||
));
|
||||
}
|
||||
@Test public void Nesting() {
|
||||
fx.tst_Doc("a:[b:;]{}"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Subs_
|
||||
( fx.nde_().Hnd_("b"))
|
||||
));
|
||||
}
|
||||
@Test public void Nesting2() {
|
||||
fx.tst_Doc("a:[b{}]{}"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("b")
|
||||
));
|
||||
}
|
||||
@Test public void CanBeKeyed_header() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.ElmKey_lxr());
|
||||
fx.tst_Doc("a:b=[c];"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Key_("b").Atru_("c")
|
||||
));
|
||||
}
|
||||
@Test public void CanBeKeyed2_inline() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.Whitespace_lxr()
|
||||
, GfmlDocLxrs.ElmKey_lxr()
|
||||
);
|
||||
fx.tst_Doc("a b=[c];"
|
||||
, fx.nde_().Atru_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Key_("b").Atru_("c")
|
||||
));
|
||||
}
|
||||
@Test public void Sole() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
fx.tst_Doc("[a b]"
|
||||
, fx.nde_().KeyedSubObj_().Atru_("a").Atru_("b"));
|
||||
}
|
||||
@Test public void Nest1() {
|
||||
fx.ini_RootLxr_Add(GfmlDocLxrs.Whitespace_lxr());
|
||||
fx.tst_Doc("[a [b]]"
|
||||
, fx.nde_().Atru_("a").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("b")
|
||||
));
|
||||
}
|
||||
}
|
||||
39
110_gfml/tst/gplx/gfml/z192_ndeProps_dots_tst.java
Normal file
39
110_gfml/tst/gplx/gfml/z192_ndeProps_dots_tst.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z192_ndeProps_dots_tst {
|
||||
GfmlParse_fxt fx = GfmlParse_fxt.new_();
|
||||
@Before public void setup() {
|
||||
fx.ini_RootLxr_Add
|
||||
( GfmlDocLxrs.NdeDot_lxr()
|
||||
, GfmlDocLxrs.NdeInline_lxr()
|
||||
, GfmlDocLxrs.NdeBodyBgn_lxr()
|
||||
, GfmlDocLxrs.NdeBodyEnd_lxr()
|
||||
, GfmlDocLxrs.NdePropBgn_lxr()
|
||||
, GfmlDocLxrs.NdePropEnd_lxr()
|
||||
);
|
||||
}
|
||||
@Test public void Stress() {
|
||||
fx.tst_Doc("a.b[c];"
|
||||
, fx.nde_().Hnd_("a").Subs_
|
||||
( fx.nde_().Hnd_("b").Subs_
|
||||
( fx.nde_().KeyedSubObj_().Atru_("c"))
|
||||
));
|
||||
}
|
||||
}
|
||||
66
110_gfml/tst/gplx/gfml/z400_GfmlTypeMakr_tst.java
Normal file
66
110_gfml/tst/gplx/gfml/z400_GfmlTypeMakr_tst.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z400_GfmlTypeMakr_tst {
|
||||
@Before public void setup() {
|
||||
makr = GfmlTypeMakr.new_();
|
||||
} GfmlTypeMakr makr; GfmlType type; GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void MakeSubType() {
|
||||
type = makr.MakeSubType("point", "x", "y");
|
||||
fx.tst_Type
|
||||
( fx.typ_().Key_("point").Subs_
|
||||
( fx.fld_().ini_atr_("x").TypeKey_(GfmlType_.StringKey)
|
||||
, fx.fld_().ini_atr_("y").TypeKey_(GfmlType_.StringKey)
|
||||
)
|
||||
, GfmlTyp_mok.type_(type)
|
||||
);
|
||||
tst_XtoAry(makr, "point");
|
||||
}
|
||||
@Test public void MakeSubTypeAsOwner() {
|
||||
type = makr.MakeSubTypeAsOwner("item");
|
||||
fx.tst_Type
|
||||
( fx.typ_().Key_("item")
|
||||
, GfmlTyp_mok.type_(type)
|
||||
);
|
||||
tst_Owner(makr, "item");
|
||||
tst_XtoAry(makr, "item");
|
||||
}
|
||||
@Test public void MakeSubTypeAsOwner_MakeSubType() {
|
||||
type = makr.MakeSubTypeAsOwner("item");
|
||||
makr.MakeSubType("pos", "x", "y");
|
||||
fx.tst_Type
|
||||
( fx.typ_().Key_("item").Subs_
|
||||
( fx.fld_().Name_("pos").TypeKey_("item/pos"))
|
||||
, GfmlTyp_mok.type_(type)
|
||||
);
|
||||
tst_Owner(makr, "item");
|
||||
tst_XtoAry(makr, "item", "item/pos");
|
||||
}
|
||||
void tst_Owner(GfmlTypeMakr typeMakr, String expdKey) {
|
||||
Tfds.Eq(expdKey, typeMakr.Owner().Key());
|
||||
}
|
||||
void tst_XtoAry(GfmlTypeMakr typeMakr, String... expdAry) {
|
||||
GfmlType[] actlTypeAry = typeMakr.Xto_bry();
|
||||
String[] actlAry = new String[actlTypeAry.length];
|
||||
for (int i = 0; i < actlAry.length; i++) {
|
||||
actlAry[i] = actlTypeAry[i].Key();
|
||||
}
|
||||
Tfds.Eq_ary(expdAry, actlAry);
|
||||
}
|
||||
}
|
||||
65
110_gfml/tst/gplx/gfml/z401_types_compile_basic_tst.java
Normal file
65
110_gfml/tst/gplx/gfml/z401_types_compile_basic_tst.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z401_types_compile_basic_tst {
|
||||
@Before public void setup() {
|
||||
fx.run_InitPragma(fx.Regy(), GfmlPragmaType.new_());
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("point", "gfml.point").Subs_
|
||||
( fx.nde_().Atru_("x")
|
||||
, fx.nde_().Atru_("y")
|
||||
)
|
||||
, fx.typ_().Name_("point").Key_("gfml.point").Atrs_("x", "y")
|
||||
);
|
||||
}
|
||||
@Test public void Nest() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("item", "gfml.item").Subs_
|
||||
( fx.nde_().Atru_("pos").Atrk_("type", "gfml.item.point")
|
||||
)
|
||||
, fx.typ_().Name_("item").Key_("gfml.item").Subs_
|
||||
( fx.fld_().Name_("pos").TypeKey_("gfml.item.point")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void NestMany() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("item", "gfml.item").Subs_
|
||||
( fx.nde_().Atru_("pos").Atrk_("type", "gfml.item.point")
|
||||
, fx.nde_().Atru_("size").Atrk_("type", "gfml.item.size")
|
||||
)
|
||||
, fx.typ_().Name_("item").Key_("gfml.item").Subs_
|
||||
( fx.fld_().Name_("pos").TypeKey_("gfml.item.point")
|
||||
, fx.fld_().Name_("size").TypeKey_("gfml.item.size")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Recurse() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("widget", "gfml.widget").Subs_
|
||||
( fx.nde_().Atru_("widget").Atrk_("type", "gfml.widget")
|
||||
)
|
||||
, fx.typ_().Name_("widget").Key_("gfml.widget").Subs_
|
||||
( fx.fld_().Name_("widget").TypeKey_("gfml.widget")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
63
110_gfml/tst/gplx/gfml/z402_types_compile_implicit_tst.java
Normal file
63
110_gfml/tst/gplx/gfml/z402_types_compile_implicit_tst.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z402_types_compile_implicit_tst {
|
||||
@Before public void setup() {
|
||||
fx.run_InitPragma(fx.Regy(), GfmlPragmaType.new_());
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Fld_typeKey_leaf() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("point", "gfml.point").Subs_
|
||||
( fx.nde_().Atru_("x").Atrk_("type", "gfml.int") // explicit
|
||||
, fx.nde_().Atru_("y") // implicit: GfmlType_.String
|
||||
)
|
||||
, fx.typ_().Name_("point").Key_("gfml.point").Subs_
|
||||
( fx.fld_().Name_("x").TypeKey_("gfml.int")
|
||||
, fx.fld_().Name_("y").TypeKey_("gfml.String")
|
||||
));
|
||||
}
|
||||
@Test public void Fld_typeKey_nest() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("rect", "gfml.rect").Subs_
|
||||
( fx.nde_().Atru_("pos").Atrk_("type", "gfml.point").Subs_ // explicit
|
||||
( fx.nde_().Atru_("x")
|
||||
, fx.nde_().Atru_("y")
|
||||
)
|
||||
, fx.nde_().Atru_("size").Subs_ // implicit: gfml.rect.size; (needs to have subs)
|
||||
( fx.nde_().Atru_("w")
|
||||
, fx.nde_().Atru_("h")
|
||||
)
|
||||
)
|
||||
, fx.typ_().Name_("rect").Key_("gfml.rect").Subs_
|
||||
( fx.fld_().Name_("pos").TypeKey_("gfml.point")
|
||||
, fx.fld_().Name_("size").TypeKey_("gfml.rect/size")
|
||||
));
|
||||
}
|
||||
@Test public void Typ_key() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("point", "gfml.point") // explicit: gfml.point
|
||||
, fx.typ_().Name_("point").Key_("gfml.point")
|
||||
);
|
||||
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("point") // implicit: point
|
||||
, fx.typ_().Name_("point").Key_("point")
|
||||
);
|
||||
}
|
||||
}
|
||||
64
110_gfml/tst/gplx/gfml/z403_types_compile_default_tst.java
Normal file
64
110_gfml/tst/gplx/gfml/z403_types_compile_default_tst.java
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z403_types_compile_default_tst {
|
||||
@Before public void setup() {
|
||||
fx.run_InitPragma(fx.Regy(), GfmlPragmaType.new_());
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("point", "gfml.point").Subs_
|
||||
( fx.nde_().Atru_("x").Atrk_("default", "10")
|
||||
, fx.nde_().Atru_("y")
|
||||
)
|
||||
, fx.typ_().Name_("point").Key_("gfml.point").Subs_
|
||||
( fx.fld_().Name_("x").Default_("10")
|
||||
, fx.fld_().Name_("y").Default_(GfmlTkn_.NullRaw)
|
||||
));
|
||||
}
|
||||
@Test public void Nde() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("rect", "gfml.rect").Subs_
|
||||
( fx.nde_().Atru_("point").Subs_
|
||||
( fx.nde_().Key_("default").Atrk_("x", "1").Atrk_("y", "2") // NOTE: naming b/c unnamed attribs are not returned in SubKeys
|
||||
))
|
||||
, fx.typ_().Name_("rect").Key_("gfml.rect").Subs_
|
||||
( fx.fld_().Name_("point").DefaultTkn_
|
||||
( ndek_("point", atr_("x", "1"), atr_("y", "2")))
|
||||
));
|
||||
}
|
||||
@Test public void Nde_unnamed() {
|
||||
fx.tst_Compile
|
||||
( fx.nde_().Atrs_("rect", "gfml.rect").Subs_
|
||||
( fx.nde_().Atru_("point").Subs_
|
||||
( fx.nde_().Key_("").Atru_("1").Atru_("2")
|
||||
))
|
||||
, fx.typ_().Name_("rect").Key_("gfml.rect").Subs_
|
||||
( fx.fld_().Name_("point").DefaultTkn_
|
||||
( ndek_("point", atr_("", "1"), atr_("", "2")))
|
||||
));
|
||||
}
|
||||
static GfmlAtr atr_(String key, String val) {return GfmlAtr.string_(GfmlTkn_.raw_(key), GfmlTkn_.raw_(val));}
|
||||
static GfmlNde ndek_(String key, GfmlItm... subs) {
|
||||
GfmlNde rv = GfmlNde.new_(GfmlTkn_.raw_(key), GfmlType_.Null, true);
|
||||
for (GfmlItm sub : subs)
|
||||
rv.SubObjs_Add(sub);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
66
110_gfml/tst/gplx/gfml/z411_types_apply_atrs_basic_tst.java
Normal file
66
110_gfml/tst/gplx/gfml/z411_types_apply_atrs_basic_tst.java
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z411_types_apply_atrs_basic_tst {
|
||||
@Before public void setup() {
|
||||
pointType = fx.typ_().Key_("point").Atrs_("x", "y", "z");
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_(); GfmlTyp_mok pointType;
|
||||
@Test public void Unnamed_one() {
|
||||
fx.tst_Resolve
|
||||
( pointType
|
||||
, fx.nde_().Hnd_("point").Atru_("10")
|
||||
, fx.nde_().Typ_("point").Atrk_("x", "10")
|
||||
);
|
||||
}
|
||||
@Test public void Unnamed_three() {
|
||||
fx.tst_Resolve
|
||||
( pointType
|
||||
, fx.nde_().Hnd_("point").Atrs_("10", "20", "30")
|
||||
, fx.nde_().Typ_("point").Atrk_("x", "10").Atrk_("y", "20").Atrk_("z", "30")
|
||||
);
|
||||
}
|
||||
@Test public void Keys_partial1() {
|
||||
fx.tst_Resolve
|
||||
( pointType
|
||||
, fx.nde_().Hnd_("point").Atrk_("x", "10").Atrs_("20", "30")
|
||||
, fx.nde_().Typ_("point").Atrk_("x", "10").Atrk_("y", "20").Atrk_("z", "30")
|
||||
);
|
||||
}
|
||||
@Test public void Keys_partial2() {
|
||||
fx.tst_Resolve
|
||||
( pointType
|
||||
, fx.nde_().Hnd_("point").Atrk_("x", "10").Atrk_("y", "20").Atru_("30")
|
||||
, fx.nde_().Typ_("point").Atrk_("x", "10").Atrk_("y", "20").Atrk_("z", "30")
|
||||
);
|
||||
}
|
||||
@Test public void OutOfOrder_z_1() {
|
||||
fx.tst_Resolve
|
||||
( pointType
|
||||
, fx.nde_().Hnd_("point").Atrk_("z", "30").Atrs_("10", "20")
|
||||
, fx.nde_().Typ_("point").Atrk_("z", "30").Atrk_("x", "10").Atrk_("y", "20")
|
||||
);
|
||||
}
|
||||
@Test public void OutOfOrder_z_2() {
|
||||
fx.tst_Resolve
|
||||
( pointType
|
||||
, fx.nde_().Hnd_("point").Atru_("10").Atrk_("z", "30").Atru_("20")
|
||||
, fx.nde_().Typ_("point").Atrk_("x", "10").Atrk_("z", "30").Atrk_("y", "20")
|
||||
);
|
||||
}
|
||||
}
|
||||
52
110_gfml/tst/gplx/gfml/z421_types_apply_ndes_basic_tst.java
Normal file
52
110_gfml/tst/gplx/gfml/z421_types_apply_ndes_basic_tst.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z421_types_apply_ndes_basic_tst {
|
||||
@Before public void setup() {
|
||||
fx.Regy().Add(
|
||||
fx.typ_().Key_("pos").Subs_
|
||||
( GfmlFld_mok.new_().ini_atr_("x")
|
||||
, GfmlFld_mok.new_().ini_atr_("y")
|
||||
).XtoGfmlType());
|
||||
fx.Regy().Add(
|
||||
fx.typ_().Key_("rect").Subs_
|
||||
( GfmlFld_mok.new_().ini_ndk_("pos", "pos")
|
||||
).XtoGfmlType());
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void NamedNde_but_UnnamedAtr() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Key_("pos").Atrs_("1")
|
||||
)
|
||||
, fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Typ_("pos").Atrk_("x", "1")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void UnnamedNde() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Key_(GfmlTkn_.NullRaw).Atrs_("1")
|
||||
)
|
||||
, fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Typ_("pos").Atrk_("x", "1")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
74
110_gfml/tst/gplx/gfml/z422_types_apply_ndes_multi_tst.java
Normal file
74
110_gfml/tst/gplx/gfml/z422_types_apply_ndes_multi_tst.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z422_types_apply_ndes_multi_tst {
|
||||
@Before public void setup() {
|
||||
fx.Regy().Add
|
||||
( fx.typ_().Key_("pos").Subs_
|
||||
( GfmlFld_mok.new_().ini_atr_("x")
|
||||
, GfmlFld_mok.new_().ini_atr_("y")
|
||||
).XtoGfmlType());
|
||||
fx.Regy().Add
|
||||
( fx.typ_().Key_("size").Subs_
|
||||
( GfmlFld_mok.new_().ini_atr_("w")
|
||||
, GfmlFld_mok.new_().ini_atr_("h")
|
||||
).XtoGfmlType());
|
||||
fx.Regy().Add
|
||||
( fx.typ_().Key_("rect").Subs_
|
||||
( GfmlFld_mok.new_().ini_ndk_("pos", "pos")
|
||||
, GfmlFld_mok.new_().ini_ndk_("size", "size")
|
||||
).XtoGfmlType());
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Unnamed() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Key_(GfmlTkn_.NullRaw).Atrs_("1")
|
||||
, fx.nde_().Key_(GfmlTkn_.NullRaw).Atrs_("3")
|
||||
)
|
||||
, fx.nde_().Typ_("rect").Subs_
|
||||
( fx.nde_().Typ_("pos").Atrk_("x", "1")
|
||||
, fx.nde_().Typ_("size").Atrk_("w", "3")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Partial() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Key_("pos").Atrs_("1")
|
||||
, fx.nde_().Key_(GfmlTkn_.NullRaw).Atrs_("3")
|
||||
)
|
||||
, fx.nde_().Typ_("rect").Subs_
|
||||
( fx.nde_().Typ_("pos").Atrk_("x", "1")
|
||||
, fx.nde_().Typ_("size").Atrk_("w", "3")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void OutOfOrder() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Key_("size").Atrs_("3")
|
||||
, fx.nde_().Key_(GfmlTkn_.NullRaw).Atrs_("1")
|
||||
)
|
||||
, fx.nde_().Typ_("rect").Subs_
|
||||
( fx.nde_().Typ_("size").Atrk_("w", "3")
|
||||
, fx.nde_().Typ_("pos").Atrk_("x", "1")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
49
110_gfml/tst/gplx/gfml/z423_types_apply_ndes_misc_tst.java
Normal file
49
110_gfml/tst/gplx/gfml/z423_types_apply_ndes_misc_tst.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z423_types_apply_ndes_misc_tst {
|
||||
@Before public void setup() {
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Recurse() {
|
||||
fx.Regy().Add(
|
||||
fx.typ_().Key_("item").Subs_
|
||||
( GfmlFld_mok.new_().ini_atr_("key")
|
||||
, GfmlFld_mok.new_().ini_ndk_("item", "item")
|
||||
).XtoGfmlType());
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("item").Atru_("1").Subs_
|
||||
( fx.nde_().Hnd_("item").Atru_("2"))
|
||||
, fx.nde_().Hnd_("item").Atrk_("key", "1").Subs_
|
||||
( fx.nde_().Hnd_("item").Atrk_("key", "2")
|
||||
));
|
||||
}
|
||||
@Test public void OwnerTypePrecedesTopLevel() {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
GfmlType topLevelSize = makr.MakeSubType("size", "width", "height");
|
||||
GfmlType rect = makr.MakeSubTypeAsOwner("rect");
|
||||
GfmlType rectSize = makr.MakeSubType("size", "w", "h");
|
||||
fx.Regy().Add(topLevelSize).Add(rect).Add(rectSize);
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Hnd_("size").Atru_("1").Atru_("2"))
|
||||
, fx.nde_().Hnd_("rect").Subs_
|
||||
( fx.nde_().Typ_("rect/size").Atrk_("w", "1").Atrk_("h", "2")
|
||||
));
|
||||
}
|
||||
}
|
||||
67
110_gfml/tst/gplx/gfml/z424_types_apply_ndes_nest_tst.java
Normal file
67
110_gfml/tst/gplx/gfml/z424_types_apply_ndes_nest_tst.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z424_types_apply_ndes_nest_tst {
|
||||
@Before public void setup() {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
makr.MakeRootType("gfml.item", "item");
|
||||
makr.MakeSubType("pos", "x", "y");
|
||||
fx.Regy().Add_ary(makr.Xto_bry());
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void InvokeByHnd() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("gfml.item").Subs_
|
||||
( fx.nde_().Hnd_("pos").Atrs_("10", "20"))
|
||||
, fx.nde_().Typ_("gfml.item").Subs_
|
||||
( fx.nde_().Typ_("gfml.item/pos").Atrk_("x", "10").Atrk_("y", "20")
|
||||
));
|
||||
}
|
||||
@Test public void InvokeByTyp() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("gfml.item").Subs_
|
||||
( fx.nde_().Hnd_("gfml.item/pos").Atrs_("10", "20"))
|
||||
, fx.nde_().Typ_("gfml.item").Subs_
|
||||
( fx.nde_().Typ_("gfml.item/pos").Atrk_("x", "10").Atrk_("y", "20")
|
||||
));
|
||||
}
|
||||
@Test public void NoInvokeByName() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("gfml.item").Subs_
|
||||
( fx.nde_().Hnd_("gfml.item").Atrs_("10", "20")) // item is not in .SubFlds, but is in regy
|
||||
, fx.nde_().Typ_("gfml.item").Subs_
|
||||
( fx.nde_().Typ_("gfml.item").Atrs_("10", "20")
|
||||
));
|
||||
}
|
||||
@Test public void Name_subLevel() {
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
makr.MakeRootType("font", "size");
|
||||
makr.MakeSubType("color", "name");
|
||||
fx.Regy().Add_ary(makr.Xto_bry());
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("color").Atru_("blue")
|
||||
, fx.nde_().Typ_(GfmlType_.AnyKey).Atru_("blue")// confirm that subFlds in other types are not selectable by name; i.e.: must be font/color, not just color
|
||||
);
|
||||
}
|
||||
@Test public void Unresolved() {
|
||||
fx.tst_Resolve
|
||||
( fx.nde_().Hnd_("").Atrs_("10", "20")
|
||||
, fx.nde_().Typ_(GfmlType_.AnyKey).Atrs_("10", "20")
|
||||
);
|
||||
}
|
||||
}
|
||||
53
110_gfml/tst/gplx/gfml/z441_types_parse_basic_tst.java
Normal file
53
110_gfml/tst/gplx/gfml/z441_types_parse_basic_tst.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z441_types_parse_basic_tst {
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Null() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "point:1;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_(GfmlType_.AnyKey).Atru_("1")
|
||||
);
|
||||
}
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "point {"
|
||||
, "x;"
|
||||
, "}"
|
||||
, "}"
|
||||
, "point:1;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "1")
|
||||
);
|
||||
}
|
||||
@Test public void MultipleAtrs() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "point {"
|
||||
, "x; y;"
|
||||
, "}"
|
||||
, "}"
|
||||
, "point:1 2;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "1").Atrk_("y", "2")
|
||||
);
|
||||
}
|
||||
}
|
||||
101
110_gfml/tst/gplx/gfml/z442_types_parse_default_tst.java
Normal file
101
110_gfml/tst/gplx/gfml/z442_types_parse_default_tst.java
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z442_types_parse_default_tst {
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "point {x;}"
|
||||
, "}"
|
||||
, "1;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "1")
|
||||
);
|
||||
}
|
||||
@Test public void Pinned() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "point {x;}"
|
||||
, "}"
|
||||
, "1;" // uses point, but should pin
|
||||
, "2;" // uses pin
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "1")
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "2")
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "point {x;}" // point is always pinned
|
||||
, "size {w;}" // size is defined, but can only be invoked by hnd
|
||||
, "}"
|
||||
, "1;"
|
||||
, "2;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "1")
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "2")
|
||||
);
|
||||
}
|
||||
@Test public void Nested() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "item {"
|
||||
, "point {x; y;}"
|
||||
, "}"
|
||||
, "}"
|
||||
, "{1 2;}"
|
||||
)
|
||||
, fx.nde_().Hnd_("item").Typ_("item").Subs_
|
||||
( fx.nde_().Hnd_("point").Typ_("item/point").Atrk_("x", "1").Atrk_("y", "2")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void NestedWithAtr() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "item {"
|
||||
, "name;"
|
||||
, "point {x; y;}"
|
||||
, "}"
|
||||
, "}"
|
||||
, "1 {1 2;}"
|
||||
// , "1 {point:{1 2}}" // breaks b/c point is not resolved as item/point
|
||||
)
|
||||
, fx.nde_().Hnd_("item").Typ_("item").Atrk_("name", "1").Subs_
|
||||
( fx.nde_().Hnd_("point").Typ_("item/point").Atrk_("x", "1").Atrk_("y", "2")
|
||||
)
|
||||
);
|
||||
}
|
||||
//@Test
|
||||
public void WithDefault() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "point {"
|
||||
, "x 1;"
|
||||
, "y;"
|
||||
, "}"
|
||||
, "}"
|
||||
, "2;"
|
||||
)
|
||||
, fx.nde_().Hnd_("point").Typ_("point").Atrk_("x", "1").Atrk_("y", "2")
|
||||
);
|
||||
}
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
}
|
||||
50
110_gfml/tst/gplx/gfml/z443_types_parse_keyd_tst.java
Normal file
50
110_gfml/tst/gplx/gfml/z443_types_parse_keyd_tst.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z443_types_parse_keyd_tst {
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "[10 12];"
|
||||
)
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Atru_("10").Atru_("12")
|
||||
)
|
||||
);
|
||||
}
|
||||
// @Test // FIX: IGNORE
|
||||
public void KeydDefault() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, " rect {"
|
||||
, " point [1 2];"
|
||||
, " }"
|
||||
, "}"
|
||||
, "rect:;"
|
||||
, "rect:;"
|
||||
)
|
||||
, fx.nde_().Typ_("rect").Subs_
|
||||
( fx.nde_().Hnd_("point").Atru_("1").Atru_("2")
|
||||
)
|
||||
, fx.nde_().Typ_("rect").Subs_
|
||||
( fx.nde_().Hnd_("point").Atru_("1").Atru_("2")
|
||||
)
|
||||
);
|
||||
}
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
}
|
||||
41
110_gfml/tst/gplx/gfml/z450_fx_GfmlDefaultItem_fxt.java
Normal file
41
110_gfml/tst/gplx/gfml/z450_fx_GfmlDefaultItem_fxt.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
class GfmlDefaultItem_fxt {
|
||||
@gplx.Internal protected GfmlDefaultItem make_(String typeKey, String key, GfmlTkn val) {return GfmlDefaultItem.new_(typeKey, key, val);}
|
||||
@gplx.Internal protected GfmlDefaultItem make_(String typeKey, String key, String val) {return GfmlDefaultItem.new_(typeKey, key, GfmlTkn_.raw_(val));}
|
||||
@gplx.Internal protected void tst_Item(GfmlDefaultItem actl, GfmlDefaultItem expd) {
|
||||
Tfds.Eq(expd.TypeKey(), actl.TypeKey());
|
||||
Tfds.Eq(expd.Key(), actl.Key());
|
||||
Tfds.Eq(GfmlFld_mok.XtoRaw(expd.Val()), GfmlFld_mok.XtoRaw(actl.Val()));
|
||||
Tfds.Eq(Val_to_str_or_null(expd.ValPrev()), Val_to_str_or_null(actl.ValPrev()));
|
||||
}
|
||||
@gplx.Internal protected void tst_List(List_adp list, GfmlDefaultItem... expdAry) {
|
||||
for (int i = 0; i < expdAry.length; i++) {
|
||||
GfmlDefaultItem actl = (GfmlDefaultItem)list.Get_at(i);
|
||||
GfmlDefaultItem expd = expdAry[i];
|
||||
tst_Item(actl, expd);
|
||||
}
|
||||
Tfds.Eq(expdAry.length, list.Count());
|
||||
}
|
||||
String Val_to_str_or_null(GfmlObj gobj) {
|
||||
GfmlTkn tkn = GfmlTkn_.as_(gobj);
|
||||
return tkn == null ? null : tkn.Val();
|
||||
}
|
||||
public static GfmlDefaultItem_fxt new_() {return new GfmlDefaultItem_fxt();} GfmlDefaultItem_fxt() {}
|
||||
}
|
||||
46
110_gfml/tst/gplx/gfml/z451_dflts_compile_tst.java
Normal file
46
110_gfml/tst/gplx/gfml/z451_dflts_compile_tst.java
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z451_dflts_compile_tst {
|
||||
@Before public void setup() {
|
||||
regy = fx_typ.Regy();
|
||||
pragma = GfmlPragmaDefault.new_();
|
||||
fx_typ.run_InitPragma(regy, pragma);
|
||||
} GfmlTypRegy regy; GfmlPragmaDefault pragma; GfmlDefaultItem_fxt fx = GfmlDefaultItem_fxt.new_(); GfmlTypeCompiler_fxt fx_typ = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
GfmlNde gnde = fx_typ.run_Resolve(regy, "_default/type/atr"
|
||||
, fx_typ.nde_().Atru_("x").Atru_("10")
|
||||
);
|
||||
GfmlDefaultItem actl = pragma.CompileItem(gnde, "point");
|
||||
fx.tst_Item(actl, fx.make_("point", "x", "10"));
|
||||
}
|
||||
@Test public void Many() {
|
||||
GfmlNde gnde = fx_typ.run_Resolve(regy, "_default/type"
|
||||
, fx_typ.nde_().Atru_("point").Subs_
|
||||
( fx_typ.nde_().Atrs_("x", "10")
|
||||
, fx_typ.nde_().Atrs_("y", "20")
|
||||
));
|
||||
List_adp list = List_adp_.new_();
|
||||
pragma.CompileSubNde(gnde, list);
|
||||
fx.tst_List(list
|
||||
, fx.make_("point", "x", "10")
|
||||
, fx.make_("point", "y", "20")
|
||||
);
|
||||
}
|
||||
}
|
||||
96
110_gfml/tst/gplx/gfml/z452_dflts_exec_tst.java
Normal file
96
110_gfml/tst/gplx/gfml/z452_dflts_exec_tst.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z452_dflts_exec_tst {
|
||||
@Before public void setup() {
|
||||
type = make_("gfml.point", "point", "x");
|
||||
} GfmlDefaultItem item; GfmlType type; GfmlDefaultItem_fxt fx_item = GfmlDefaultItem_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
tst_SubFldDefault(type, "x", null);
|
||||
|
||||
item = fx_item.make_("gfml.point", "x", "10");
|
||||
item.Exec_bgn(type);
|
||||
tst_SubFldDefault(type, "x", "10");
|
||||
|
||||
item.Exec_end(type);
|
||||
tst_SubFldDefault(type, "x", null);
|
||||
}
|
||||
@Test public void Overwrite() {
|
||||
ini_SubFldDefault_add(type, "x", "0");
|
||||
tst_SubFldDefault(type, "x", "0");
|
||||
|
||||
item = fx_item.make_("gfml.point", "x", "10");
|
||||
item.Exec_bgn(type);
|
||||
tst_SubFldDefault(type, "x", "10");
|
||||
|
||||
item.Exec_end(type);
|
||||
tst_SubFldDefault(type, "x", "0");
|
||||
}
|
||||
@Test public void CreateDefault() {
|
||||
tst_SubFldExists(type, "y", false);
|
||||
|
||||
item = fx_item.make_("gfml.point", "y", "10");
|
||||
item.Exec_bgn(type);
|
||||
|
||||
tst_SubFldDefault(type, "y", "10");
|
||||
|
||||
item.Exec_end(type);
|
||||
tst_SubFldExists(type, "y", false);
|
||||
}
|
||||
@Test public void DefaultTkn() {
|
||||
Object[] ary = ini_eval_("0");
|
||||
GfmlTkn varTkn = (GfmlTkn)ary[0];
|
||||
GfmlVarItm varItem = (GfmlVarItm)ary[1];
|
||||
item = fx_item.make_("gfml.point", "x", varTkn);
|
||||
varItem.Tkn_set(GfmlTkn_.raw_("10"));
|
||||
item.Exec_bgn(type);
|
||||
|
||||
tst_SubFldDefault(type, "x", "10");
|
||||
}
|
||||
Object[] ini_eval_(String text) {
|
||||
GfmlVarCtx evalContext = GfmlVarCtx.new_("testContext");
|
||||
GfmlTkn valTkn = GfmlTkn_.raw_(text);
|
||||
GfmlVarItm varItem = GfmlVarItm.new_("varKey", valTkn, "testContext");
|
||||
evalContext.Add_if_dupe_use_nth(varItem);
|
||||
GfmlVarTkn rv = new GfmlVarTkn("eval", GfmlTknAry_.ary_(valTkn), evalContext, "varKey");
|
||||
return new Object[] {rv, varItem};
|
||||
}
|
||||
void ini_SubFldDefault_add(GfmlType type, String subFldKey, String defaultVal) {
|
||||
GfmlFld subFld = type.SubFlds().Get_by(subFldKey);
|
||||
GfmlTkn defaultTkn = GfmlTkn_.raw_(defaultVal);;
|
||||
subFld.DefaultTkn_(defaultTkn);
|
||||
}
|
||||
void tst_SubFldDefault(GfmlType type, String subFldKey, String expdDefaultVal) {
|
||||
GfmlFld subFld = type.SubFlds().Get_by(subFldKey);
|
||||
GfmlTkn defaultTkn = GfmlTkn_.as_(subFld.DefaultTkn());
|
||||
String actlDefaultVal = defaultTkn == null || defaultTkn == GfmlTkn_.Null ? null : defaultTkn.Val();
|
||||
Tfds.Eq(expdDefaultVal, actlDefaultVal);
|
||||
}
|
||||
void tst_SubFldExists(GfmlType type, String subFldKey, boolean expd) {
|
||||
GfmlFld subFld = type.SubFlds().Get_by(subFldKey);
|
||||
Tfds.Eq(expd, subFld != null);
|
||||
}
|
||||
GfmlType make_(String key, String name, String... atrs) {
|
||||
GfmlTypeMakr typeMakr = GfmlTypeMakr.new_();
|
||||
GfmlType rv = typeMakr.MakeRootType(key, name);
|
||||
for (String atr : atrs)
|
||||
typeMakr.AddSubFld(GfmlFld.new_(true, atr, GfmlType_.StringKey));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
49
110_gfml/tst/gplx/gfml/z455_dflts_scope_tst.java
Normal file
49
110_gfml/tst/gplx/gfml/z455_dflts_scope_tst.java
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z455_dflts_scope_tst {
|
||||
@Before public void setup() {
|
||||
regy = GfmlTypRegy.new_();
|
||||
GfmlTypeMakr makr = GfmlTypeMakr.new_();
|
||||
rootPos = GfmlDocPos_.Root.NewDown(0);
|
||||
GfmlType type = makr.MakeRootType("point", "point", "x", "y").DocPos_(rootPos);
|
||||
regy.Add(type);
|
||||
} GfmlDocPos rootPos, currPos; GfmlTypRegy regy;
|
||||
@Test public void Basic() {
|
||||
currPos = rootPos.NewDown(0);
|
||||
tst_FetchOrNullByPos(regy, "point", rootPos, "point", "x", "y");
|
||||
tst_FetchOrNullByPos(regy, "point", currPos, "point", "x", "y");
|
||||
|
||||
List_adp list = List_adp_.new_();
|
||||
list.Add(GfmlDefaultItem.new_("point", "z", GfmlTkn_.raw_("0")));
|
||||
GfmlDefaultPragma_bgnCmd.ExecList(regy, currPos, list);
|
||||
|
||||
tst_FetchOrNullByPos(regy, "point", rootPos, "point", "x", "y");
|
||||
tst_FetchOrNullByPos(regy, "point", currPos, "point", "x", "y", "z");
|
||||
}
|
||||
GfmlType tst_FetchOrNullByPos(GfmlTypRegy regy, String key, GfmlDocPos docPos, String expdTypeKey, String... expdSubs) {
|
||||
GfmlType actl = regy.FetchOrNull(key, docPos);
|
||||
Tfds.Eq(expdTypeKey, actl.Key());
|
||||
String[] actlSubs = new String[actl.SubFlds().Count()];
|
||||
for (int i = 0; i < actlSubs.length; i++)
|
||||
actlSubs[i] = actl.SubFlds().Get_at(i).Name();
|
||||
Tfds.Eq_ary(expdSubs, actlSubs);
|
||||
return actl;
|
||||
}
|
||||
}
|
||||
35
110_gfml/tst/gplx/gfml/z456_dflts_parse_tst.java
Normal file
35
110_gfml/tst/gplx/gfml/z456_dflts_parse_tst.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z456_dflts_parse_tst {
|
||||
@Test public void Fix_DefaultChangesPinnedType() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_type:{"
|
||||
, "item {"
|
||||
, "name;"
|
||||
, "}"
|
||||
, "}"
|
||||
, "_default:{item {name 10;}}"
|
||||
, ";"
|
||||
)
|
||||
, fx.nde_().Typ_("item").Atrk_("name", "10")
|
||||
);
|
||||
}
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
}
|
||||
35
110_gfml/tst/gplx/gfml/z481_vars_compile_tst.java
Normal file
35
110_gfml/tst/gplx/gfml/z481_vars_compile_tst.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z481_vars_compile_tst {
|
||||
@Before public void setup() {
|
||||
regy = fx.Regy();
|
||||
pragma = GfmlPragmaVar.new_();
|
||||
fx.run_InitPragma(regy, pragma);
|
||||
} GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_(); GfmlTypRegy regy; GfmlPragmaVar pragma;
|
||||
@Test public void Text1() {
|
||||
GfmlNde gnde = fx.run_Resolve(regy, "_var/text"
|
||||
, fx.nde_().Atru_("key_test").Atru_("val_test").Atru_("context_test"));
|
||||
|
||||
GfmlVarItm itm = pragma.CompileItmNde(gnde);
|
||||
Tfds.Eq_rev(itm.Key(), "key_test");
|
||||
Tfds.Eq_rev(itm.TknVal(), "val_test");
|
||||
Tfds.Eq_rev(itm.CtxKey(), "context_test");
|
||||
}
|
||||
}
|
||||
85
110_gfml/tst/gplx/gfml/z482_vars_parse_tst.java
Normal file
85
110_gfml/tst/gplx/gfml/z482_vars_parse_tst.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z482_vars_parse_tst {
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void Basic() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_var:{"
|
||||
, " size '20,20';"
|
||||
, "}"
|
||||
, "'<~size>';"
|
||||
)
|
||||
, fx.nde_().Atru_("20,20")
|
||||
);
|
||||
}
|
||||
@Test public void Many() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_var:{"
|
||||
, " size '20,20';"
|
||||
, " pos '30,30';"
|
||||
, "}"
|
||||
, "'<~size>' '<~pos>';"
|
||||
)
|
||||
, fx.nde_().Atru_("20,20").Atru_("30,30")
|
||||
);
|
||||
}
|
||||
@Test public void Deferred() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_var:{"
|
||||
, " key0 '<~key1>';"
|
||||
, "}"
|
||||
, "_var:{"
|
||||
, " key1 val1;"
|
||||
, "}"
|
||||
, "'<~key0>';"
|
||||
)
|
||||
, fx.nde_().Atru_("val1")
|
||||
);
|
||||
}
|
||||
@Test public void Swap() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "{"
|
||||
, " _var:{"
|
||||
, " size '20,20';"
|
||||
, " }"
|
||||
, " '<~size>';"
|
||||
, " _var:{"
|
||||
, " size '30,30';"
|
||||
, " }"
|
||||
, " '<~size>';"
|
||||
, "}"
|
||||
)
|
||||
, fx.nde_().Subs_
|
||||
( fx.nde_().Atru_("20,20")
|
||||
, fx.nde_().Atru_("30,30")
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Context() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_var:{"
|
||||
, " size '20,20' gui;"
|
||||
, "}"
|
||||
, "'<~gui.size>' <~size>;"
|
||||
)
|
||||
, fx.nde_().Atru_("20,20").Atru_("<~size>")
|
||||
);
|
||||
}
|
||||
}
|
||||
88
110_gfml/tst/gplx/gfml/z501_lxr_parse_tst.java
Normal file
88
110_gfml/tst/gplx/gfml/z501_lxr_parse_tst.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z501_lxr_parse_tst {
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
@Test public void SymCreate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_lxr_sym:key='gfml.elm_key_1' raw='<-' cmd='gfml.elm_key';"
|
||||
, "a<-1;"
|
||||
)
|
||||
, fx.nde_().Atrk_("a", "1")
|
||||
);
|
||||
}
|
||||
@Test public void SymUpdate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_lxr_sym:key='gfml.elm_key_0' raw='<-';"
|
||||
, "a<-1 b=1;"
|
||||
)
|
||||
, fx.nde_().Atrk_("a", "1").Atru_("b=1")
|
||||
);
|
||||
}
|
||||
@Test public void SwapCreate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_lxr_sym:key='gfml.swap_0' raw='/?/?' val='/?';"
|
||||
, "/?/?;"
|
||||
)
|
||||
, fx.nde_().Atru_("/?")
|
||||
);
|
||||
}
|
||||
@Test public void FrameCreate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_lxr_frame:key='gfml.comment_2' type='comment' bgn='/-' end='-/';"
|
||||
, "a=/-ignore-/b;"
|
||||
)
|
||||
, fx.nde_().Atrk_("a", "b")
|
||||
);
|
||||
}
|
||||
@Test public void FrameUpdate() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_lxr_frame:key='gfml.comment_0' bgn='--' end='!';"
|
||||
, "a=--ignore!"
|
||||
, "b;"
|
||||
)
|
||||
, fx.nde_().Atrk_("a", "b")
|
||||
);
|
||||
}
|
||||
//@Test
|
||||
public void FrameCreateNest() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "_lxr_frame:key='gfml.comment_2' type='comment' bgn='/-' end='-/' {"
|
||||
, "sym:key='gfml.comment_2_escape_bgn' raw='/-/-' val='/-' cmd='gfml.elm_data';"
|
||||
, "sym:key='gfml.comment_2_escape_end' raw='-/-/' val='-/' cmd='gfml.elm_data';"
|
||||
, "}"
|
||||
, "a=/-/-/-ignore-/b;"
|
||||
)
|
||||
, fx.nde_().Atrk_("a", "b")
|
||||
);
|
||||
// todo:
|
||||
// cmd should be waitingTkns add, not data (makes invisible
|
||||
// should resolve type on sym to lxr_sym (since _lxr_sym is not invoked) or create _lxr_frame/sym type
|
||||
// how to change inner lxrs (lookup by key?)
|
||||
}
|
||||
|
||||
// @Test public void FrameUpdateEval() {
|
||||
// raw = String_.Concat
|
||||
// ( "_lxr_frame:key='gfml.eval_0' bgn='~<' end='>';" // how to handle '<~' where <~ (block quote)
|
||||
// , "a=~[t];"
|
||||
// );
|
||||
// gdoc = GfmlDoc_.parse_any_eol_(raw);
|
||||
// fx_nde.tst_SubKeys(gdoc, 0, atr_("a", "\t"));
|
||||
// }
|
||||
}
|
||||
130
110_gfml/tst/gplx/gfml/z601_edit_atr_tst.java
Normal file
130
110_gfml/tst/gplx/gfml/z601_edit_atr_tst.java
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z601_edit_atr_tst {
|
||||
GfmlUpdateFx fx = GfmlUpdateFx.new_();
|
||||
@Test public void Basic() {
|
||||
fx .Raw_("a=1;").Update_(fx.atr_().NdeIdxs_(0).Atr_("a", "2"))
|
||||
.tst_("a=2;");
|
||||
}
|
||||
@Test public void WhiteSpaceComment() {
|
||||
fx .Raw_("a = /*comment*/1;").Update_(fx.atr_().NdeIdxs_(0).Atr_("a", "2"))
|
||||
.tst_("a = /*comment*/2;");
|
||||
}
|
||||
@Test public void Quoted() {
|
||||
fx .Raw_("a='1';").Update_(fx.atr_().NdeIdxs_(0).Atr_("a", "2"))
|
||||
.tst_("a='2';");
|
||||
}
|
||||
@Test public void EmbeddedQuote() {
|
||||
fx .Raw_("a=1;").Update_(fx.atr_().NdeIdxs_(0).Atr_("a", "1'2"))
|
||||
.tst_("a='1''2';");
|
||||
}
|
||||
@Test public void ReuseQuote() {
|
||||
fx .Raw_("a=|'1'|;").Update_(fx.atr_().NdeIdxs_(0).Atr_("a", "2"))
|
||||
.tst_("a=|'2'|;");
|
||||
}
|
||||
@Test public void ReuseQuoteWithEmbeddedQuote() {
|
||||
fx .Raw_("a=|'1'2'|;").Update_(fx.atr_().NdeIdxs_(0).Atr_("a", "2'3"))
|
||||
.tst_("a=|'2'3'|;");
|
||||
}
|
||||
// @Test public void AtrIdx() {
|
||||
// fx .Raw_("1;").Update_(fx.atr_().NdeIdxs_(0).AtrIdx_(0, "2"))
|
||||
// .tst_("2;");
|
||||
// }
|
||||
// @Test public void AtrIdx_parens() {
|
||||
// fx .Raw_("A_('1');").Update_(fx.atr_().NdeIdxs_(0).AtrIdx_(0, "2"))
|
||||
// .tst_("A_('2');");
|
||||
// }
|
||||
@Test public void AddNew() {
|
||||
fx .Raw_("a:;").Update_(fx.atr_().NdeIdxs_(0).Atr_("b", "1"))
|
||||
.tst_("a:b='1';");
|
||||
}
|
||||
@Test public void AddExisting() {
|
||||
fx .Raw_("a='1';").Update_(fx.atr_().NdeIdxs_(0).Atr_("b", "2"))
|
||||
.tst_("a='1' b='2';");
|
||||
}
|
||||
@Test public void Add_many() {
|
||||
fx .Raw_("a='1';").Update_(fx.atr_().NdeIdxs_(0).Atr_("b", "2")).Update_(fx.atr_().NdeIdxs_(0).Atr_("c", "3"))
|
||||
.tst_("a='1' b='2' c='3';");
|
||||
}
|
||||
@Test public void AddNode() {
|
||||
fx .Raw_("a(){}").Update_(fx.nde_().NdeIdxs_(0).Nest_("b"))
|
||||
.tst_("a(){b(){}}");
|
||||
}
|
||||
@Test public void AddNodeMany() {
|
||||
fx .Raw_("a(){}").Update_(fx.nde_().NdeIdxs_(0).Nest_("b")).Update_(fx.nde_().NdeIdxs_(0).Nest_("c"))
|
||||
.tst_("a(){b(){}c(){}}");
|
||||
}
|
||||
@Test public void EditNode() {
|
||||
fx .Raw_("a(){b(){}}").Update_(fx.nde_().NdeIdxs_(0).Nest_("b"))
|
||||
.tst_("a(){b(){}}");
|
||||
}
|
||||
}
|
||||
interface GfmlUpdateCmd {
|
||||
void Exec(GfmlDoc gdoc);
|
||||
}
|
||||
class GfmlUpdateCmd_atr implements GfmlUpdateCmd {
|
||||
public GfmlUpdateCmd_atr NdeIdxs_(int... v) {ndeIdxs = v; return this;} int[] ndeIdxs;
|
||||
public GfmlUpdateCmd_atr Atr_(String key, String val) {atrKey = key; atrVal = val; return this;} String atrKey, atrVal;
|
||||
// public GfmlUpdateCmd_atr AtrIdx_(int idx, String val) {atrIdx = idx; atrVal = val; return this;} int atrIdx = -1;
|
||||
public void Exec(GfmlDoc gdoc) {
|
||||
GfmlNde nde = GetNde(ndeIdxs, gdoc.RootNde());
|
||||
nde.UpdateAtr(atrKey, atrVal);
|
||||
// GfmlAtr atr = atrIdx != -1 ? GfmlAtr.as_(nde.SubKeys().Get_at(atrIdx)) : GfmlAtr.as_(nde.SubKeys().Get_by(atrKey));
|
||||
// atr.UpdateAtr(atrKey, atrVal);
|
||||
atrKey = ""; atrVal = "";//atrIdx = -1;
|
||||
}
|
||||
public static GfmlNde GetNde(int[] ndeIdxs, GfmlNde owner) {
|
||||
GfmlNde nde = owner;
|
||||
for (int i = 0; i < ndeIdxs.length; i++) {
|
||||
int ndeIdx = ndeIdxs[i];
|
||||
nde = (GfmlNde)owner.SubHnds().Get_at(ndeIdx);
|
||||
}
|
||||
return nde;
|
||||
}
|
||||
public static GfmlUpdateCmd_atr new_() {return new GfmlUpdateCmd_atr();} GfmlUpdateCmd_atr() {}
|
||||
}
|
||||
class GfmlUpdateCmd_nde implements GfmlUpdateCmd {
|
||||
public GfmlUpdateCmd_nde NdeIdxs_(int... v) {ndeIdxs = v; return this;} int[] ndeIdxs;
|
||||
public GfmlUpdateCmd_nde Nest_(String hnd) {ndeHnd = hnd; return this;} String ndeHnd;
|
||||
public void Exec(GfmlDoc gdoc) {
|
||||
GfmlNde nde = GfmlUpdateCmd_atr.GetNde(ndeIdxs, gdoc.RootNde());
|
||||
nde.UpdateNde(ndeHnd);
|
||||
ndeHnd = "";
|
||||
}
|
||||
public static GfmlUpdateCmd_nde new_() {return new GfmlUpdateCmd_nde();} GfmlUpdateCmd_nde() {}
|
||||
}
|
||||
class GfmlUpdateFx {
|
||||
public GfmlUpdateCmd_atr atr_() {return GfmlUpdateCmd_atr.new_();}
|
||||
public GfmlUpdateCmd_nde nde_() {return GfmlUpdateCmd_nde.new_();}
|
||||
public String Raw() {return raw;} public GfmlUpdateFx Raw_(String v) {raw = v; return this;} private String raw;
|
||||
public GfmlUpdateFx Update_(GfmlUpdateCmd cmd) {cmds.Add(cmd); return this;} List_adp cmds = List_adp_.new_();
|
||||
public GfmlUpdateFx tst_(String expd) {
|
||||
GfmlDoc actlDoc = GfmlDataNde.new_any_eol_(raw).Doc();
|
||||
for (int i = 0; i < cmds.Count(); i++) {
|
||||
GfmlUpdateCmd cmd = (GfmlUpdateCmd)cmds.Get_at(i);
|
||||
cmd.Exec(actlDoc);
|
||||
}
|
||||
String actl = actlDoc.RootNde().XtoStr();
|
||||
Tfds.Eq(expd, actl);
|
||||
cmds.Clear();
|
||||
return this;
|
||||
}
|
||||
public static GfmlUpdateFx new_() {return new GfmlUpdateFx();} GfmlUpdateFx() {}
|
||||
}
|
||||
24
110_gfml/tst/gplx/gfml/z602_edit_nde_tst.java
Normal file
24
110_gfml/tst/gplx/gfml/z602_edit_nde_tst.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z602_edit_nde_tst {
|
||||
GfmlUpdateFx fx = GfmlUpdateFx.new_();
|
||||
@Test public void Basic() {
|
||||
}
|
||||
}
|
||||
81
110_gfml/tst/gplx/gfml/z801_useCase_DataRdr_tst.java
Normal file
81
110_gfml/tst/gplx/gfml/z801_useCase_DataRdr_tst.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
import gplx.stores.*;
|
||||
public class z801_useCase_DataRdr_tst {
|
||||
String raw;
|
||||
@Test public void Subs_byName() {
|
||||
raw = String_.Concat
|
||||
( "_type:{"
|
||||
, " item {"
|
||||
, " point {"
|
||||
, " x;"
|
||||
, " y;"
|
||||
, " }"
|
||||
, " }"
|
||||
, "}"
|
||||
, "item:{"
|
||||
, " 1 2;"
|
||||
, "}"
|
||||
);
|
||||
rdr = GfmlDataRdr.raw_root_(raw);
|
||||
|
||||
subRdr = rdr.Subs_byName_moveFirst("point");
|
||||
fx_rdr.tst_Atrs(subRdr, kv_("x", "1"), kv_("y", "2"));
|
||||
}
|
||||
// @Test
|
||||
public void Subs_byName3() {
|
||||
raw = String_.Concat
|
||||
( "_type:{"
|
||||
, " item {"
|
||||
, " key"
|
||||
, " point {"
|
||||
, " x;"
|
||||
, " y;"
|
||||
, " }"
|
||||
, " }"
|
||||
, "}"
|
||||
, "abc point=(1 2);"
|
||||
);
|
||||
rdr = GfmlDataRdr.raw_root_(raw);
|
||||
|
||||
subRdr = rdr.Subs_byName_moveFirst("point");
|
||||
fx_rdr.tst_Atrs(subRdr, kv_("x", "1"), kv_("y", "2"));
|
||||
}
|
||||
KeyVal kv_(String key, Object val) {return KeyVal_.new_(key, val);}
|
||||
DataRdr_Fxt fx_rdr = DataRdr_Fxt._;
|
||||
DataRdr rdr, subRdr;
|
||||
}
|
||||
class DataRdr_Fxt {
|
||||
@gplx.Internal protected DataRdr run_Subs_at(DataRdr rdr, int i) {
|
||||
DataRdr rv = rdr.Subs();
|
||||
int count = -1;
|
||||
while (count++ < i) {
|
||||
rv.MoveNextPeer();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@gplx.Internal protected void tst_Atrs(DataRdr rdr, KeyVal... expdAry) {
|
||||
KeyVal[] actlAry = new KeyVal[rdr.FieldCount()];
|
||||
for (int i = 0; i < actlAry.length; i++)
|
||||
actlAry[i] = rdr.KeyValAt(i);
|
||||
Tfds.Eq_ary_str(expdAry, actlAry);
|
||||
}
|
||||
public static final DataRdr_Fxt _ = new DataRdr_Fxt(); DataRdr_Fxt() {}
|
||||
}
|
||||
87
110_gfml/tst/gplx/gfml/z803_useCase_KbdKeyboard_tst.java
Normal file
87
110_gfml/tst/gplx/gfml/z803_useCase_KbdKeyboard_tst.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z803_useCase_KbdKeyboard_tst {
|
||||
String raw; GfmlDoc gdoc;
|
||||
@Test public void Quote() { // smokeTest; make sure DefaultLxr supports both quoting mechanisms
|
||||
fx.tst_Parse(String_.Concat
|
||||
( "gfui-keyboard-ui:{"
|
||||
, " keyQuote {"
|
||||
, " \"'\" 'key.quote';"
|
||||
, " '\"' 'key.quote+key.shift' shift;"
|
||||
, " }"
|
||||
, "}"
|
||||
)
|
||||
, fx.nde_().Hnd_("gfui-keyboard-ui").Subs_
|
||||
( fx.nde_().Atru_("keyQuote").Subs_
|
||||
( fx.nde_().Atrs_("'", "key.quote")
|
||||
, fx.nde_().Atrs_("\"", "key.quote+key.shift", "shift")
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Key_LtrA() {
|
||||
fx.tst_Parse(String_.Concat
|
||||
( TypeHeader
|
||||
, "keys:{"
|
||||
, " keyA {"
|
||||
, " a 'key.a';"
|
||||
, " A 'key.a+key.shift' shift;"
|
||||
, " }"
|
||||
, "}"
|
||||
)
|
||||
, fx.nde_().Hnd_("keys").Subs_
|
||||
( fx.nde_().Hnd_("key").Typ_("keys/key").Atrk_("size", "48,45").Atrk_("relAnchor", "{previous},rightOf").Atrk_("id", "keyA").Subs_
|
||||
( fx.nde_().Hnd_("sendKeyCode").Typ_("sendKeyCode").Atrk_("modifier", "normal").Atrk_("displayText", "a").Atrk_("keyCode", "key.a")
|
||||
, fx.nde_().Hnd_("sendKeyCode").Typ_("sendKeyCode").Atrk_("displayText", "A").Atrk_("keyCode", "key.a+key.shift").Atrk_("modifier", "shift")
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@Test public void Load_Smoke() {
|
||||
Io_url url = Tfds.RscDir.GenSubFil_nest("110_gfml", "cfgs_archive", "gfui-keyboard-ui.cfg.gfml");
|
||||
raw = Io_mgr.I.LoadFilStr(url);
|
||||
gdoc = GfmlDoc_.parse_any_eol_(raw);
|
||||
// Tfds.Write(gdoc.RootNde().XtoStr());
|
||||
}
|
||||
String TypeHeader = String_.Concat
|
||||
( "_type:{"
|
||||
, " keys {"
|
||||
, " key {"
|
||||
, " id;"
|
||||
, " size default='48,45';"
|
||||
, " relAnchor default='{previous},rightOf';"
|
||||
, " sendKeyCode type=sendKeyCode;"
|
||||
, " }"
|
||||
, " }"
|
||||
, " sendKeyCode {"
|
||||
, " displayText;"
|
||||
, " keyCode;"
|
||||
, " modifier default=normal;"
|
||||
, " }"
|
||||
, " changeModifier {"
|
||||
, " displayText;"
|
||||
, " modifier default=normal;"
|
||||
, " newModifierId;"
|
||||
, " isSticky;"
|
||||
, " }"
|
||||
, "}"
|
||||
);
|
||||
GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
|
||||
}
|
||||
50
110_gfml/tst/gplx/gfml/z811_useCase_GfmlIoSql_tst.java
Normal file
50
110_gfml/tst/gplx/gfml/z811_useCase_GfmlIoSql_tst.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*;
|
||||
public class z811_useCase_GfmlIoSql_tst {
|
||||
@Test public void Basic() {
|
||||
tst_Doc("fld1=val1", nde_("fld").Atrs_add_("word", "fld1").Atrs_add_("op", "=").Atrs_add_("word", "val1"));
|
||||
tst_Doc("fld1 = val1", nde_("fld").Atrs_add_("word", "fld1").Atrs_add_("op", "=").Atrs_add_("word", "val1"));
|
||||
tst_Doc("fld1='val1'", nde_("fld").Atrs_add_("word", "fld1").Atrs_add_("op", "=").Atrs_add_("word", "val1"));
|
||||
tst_Doc("fld1='val 1'", nde_("fld").Atrs_add_("word", "fld1").Atrs_add_("op", "=").Atrs_add_("word", "val 1"));
|
||||
}
|
||||
@Test public void Basic2() {
|
||||
tst_Doc("1=1 OR 2=2", nde_("fld").Atrs_add_("word", "1").Atrs_add_("op", "=").Atrs_add_("word", "1")
|
||||
.Atrs_add_("word", "OR")
|
||||
.Atrs_add_("word", "2").Atrs_add_("op", "=").Atrs_add_("word", "2")
|
||||
);
|
||||
tst_Doc("(1=1)", nde_("fld").Atrs_add_("op", "(").Atrs_add_("word", "1").Atrs_add_("op", "=").Atrs_add_("word", "1")
|
||||
.Atrs_add_("op", ")")
|
||||
);
|
||||
}
|
||||
void tst_Doc(String raw, GfmlNdeWrapper expd) {
|
||||
GfmlDoc doc = SqlDoc.XtoDoc(raw);
|
||||
GfmlNde actl = (GfmlNde)doc.RootNde();
|
||||
Tfds.Eq_ary_str(XtoStr(expd.Nde()), XtoStr(actl));
|
||||
}
|
||||
String[] XtoStr(GfmlNde nde) {
|
||||
List_adp list = List_adp_.new_();
|
||||
for (int i = 0; i < nde.SubObjs_Count(); i++) {
|
||||
GfmlAtr atr = (GfmlAtr)nde.SubObjs_GetAt(i);
|
||||
list.Add(atr.Key() + "=" + atr.DatTkn().Raw());
|
||||
}
|
||||
return list.To_str_ary();
|
||||
}
|
||||
GfmlNdeWrapper nde_(String name) {return GfmlNdeWrapper.new_().Name_(name);}
|
||||
}
|
||||
117
110_gfml/tst/gplx/gfml/z901_perf_tst.java
Normal file
117
110_gfml/tst/gplx/gfml/z901_perf_tst.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.gfml; import gplx.*;
|
||||
import org.junit.*; import gplx.core.strings.*;
|
||||
public class z901_perf_tst {
|
||||
TimerWatch tmr = TimerWatch.new_();
|
||||
@Test public void EmptyTestSoJunitWillNotFail() {}
|
||||
// @Test
|
||||
public void Long() {
|
||||
// String longText = String_.Repeat("a", 30 * 1000 * 1000);
|
||||
String longText = Io_mgr.I.LoadFilStr(Io_url_.new_any_("C:\\core_weekly.temp.gfio"));
|
||||
// String_bldr sbXml = String_bldr_.new_();
|
||||
// sbXml.Add("<");
|
||||
// sbXml.Add(longText);
|
||||
// sbXml.Add("/>");
|
||||
// tmr.Bgn();
|
||||
// gplx.xmls.XmlDoc_.parse_(sbXml.XtoStr());
|
||||
// tmr.End_and_print("xml"); // 400
|
||||
|
||||
String_bldr sbGfml = String_bldr_.new_();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
sbGfml.Add(longText);
|
||||
// sbGfml.Add(longText);
|
||||
// sbGfml.Add(longText);
|
||||
// sbGfml.Add(longText);
|
||||
}
|
||||
// tmr.Bgn();
|
||||
// gplx.texts.CharStream.pos0_(sbGfml.XtoStr());
|
||||
// tmr.End_and_print("char"); // 1700
|
||||
|
||||
tmr.Bgn();
|
||||
GfmlDoc_.parse_any_eol_(sbGfml.XtoStr());
|
||||
tmr.End_and_print("gfml"); // 1700
|
||||
}
|
||||
//@Test
|
||||
public void Prop() {
|
||||
int max = 100 * 1000 * 1000;
|
||||
PerfFieldVsProc c = new PerfFieldVsProc();
|
||||
int v = 0;
|
||||
tmr.Bgn();
|
||||
for (int i = 0; i < max; i++)
|
||||
v = member;
|
||||
tmr.End_and_print("member");
|
||||
tmr.Bgn();
|
||||
for (int i = 0; i < max; i++)
|
||||
v = c.Val_field;
|
||||
tmr.End_and_print("field");
|
||||
tmr.Bgn();
|
||||
for (int i = 0; i < max; i++)
|
||||
v = c.Val_proc();
|
||||
tmr.End_and_print("proc");
|
||||
Tfds.Write(v);
|
||||
}
|
||||
// @Test
|
||||
// public void ClassComp() {
|
||||
// int max = 100 * 1000 * 1000;
|
||||
// ClassType ct = new ClassType3();
|
||||
// long v = 0;
|
||||
// // 2625 CS, 718 JAVA
|
||||
// tmr.Bgn();
|
||||
// for (int i = 0; i < max; i++) {
|
||||
// if (ct.Type() == ClassType_.Type_1) v += 1;
|
||||
// else if (ct.Type() == ClassType_.Type_2) v += 2;
|
||||
// else if (ct.Type() == ClassType_.Type_3) v += 3;
|
||||
// }
|
||||
// tmr.End_and_print("var");
|
||||
// v = 0;
|
||||
// // 12437 CS, 578 JAVA
|
||||
// tmr.Bgn();
|
||||
// for (int i = 0; i < max; i++) {
|
||||
// Class<?> type = ct.getClass();
|
||||
// if (type == typeof(ClassType1)) v += 1;
|
||||
// else if (type == typeof(ClassType2)) v += 2;
|
||||
// else if (type == typeof(ClassType3)) v += 3;
|
||||
// }
|
||||
// tmr.End_and_print("type");
|
||||
// }
|
||||
interface ClassType {int Type();}
|
||||
class ClassType_ {public static final int Type_1 = 1, Type_2 = 2, Type_3 = 3;}
|
||||
class ClassType1 implements ClassType {public int Type() {return ClassType_.Type_1;}}
|
||||
class ClassType2 implements ClassType {public int Type() {return ClassType_.Type_2;}}
|
||||
class ClassType3 implements ClassType {public int Type() {return ClassType_.Type_3;}}
|
||||
int member = 1;
|
||||
}
|
||||
class PerfFieldVsProc {
|
||||
public int Val_field = 1;
|
||||
public int Val_proc() {return 1;}
|
||||
}
|
||||
class TimerWatch {
|
||||
public void Bgn() {bgnTime = Env_.TickCount();} long bgnTime;
|
||||
public void End() {duration = Env_.TickCount() - bgnTime;} long duration;
|
||||
public void End_and_print(String text) {
|
||||
this.End();
|
||||
Tfds.Write(XtoStr_ms() + " " + text);
|
||||
}
|
||||
public String XtoStr_ms() {return Long_.Xto_str(duration);}
|
||||
public static TimerWatch new_() {
|
||||
TimerWatch rv = new TimerWatch();
|
||||
rv.Bgn();
|
||||
return rv;
|
||||
} TimerWatch() {}
|
||||
}
|
||||
Reference in New Issue
Block a user