z182_ndeDots_subs_tst.java 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. XOWA: the XOWA Offline Wiki Application
  3. Copyright (C) 2012-2017 gnosygnu@gmail.com
  4. XOWA is licensed under the terms of the General Public License (GPL) Version 3,
  5. or alternatively under the terms of the Apache License Version 2.0.
  6. You may use XOWA according to either of these licenses as is most appropriate
  7. for your project on a case-by-case basis.
  8. The terms of each license can be found in the source code repository:
  9. GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
  10. Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
  11. */
  12. package gplx.gfml; import gplx.*;
  13. import org.junit.*;
  14. public class z182_ndeDots_subs_tst {
  15. @Before public void setup() {
  16. fx.ini_RootLxr_Add
  17. ( GfmlDocLxrs.NdeDot_lxr()
  18. , GfmlDocLxrs.NdeInline_lxr()
  19. , GfmlDocLxrs.NdeBodyBgn_lxr()
  20. , GfmlDocLxrs.NdeBodyEnd_lxr()
  21. );
  22. } GfmlParse_fxt fx = GfmlParse_fxt.new_();
  23. @Test public void Basic() {
  24. fx.tst_Doc("{a.b{}z;}"
  25. , fx.nde_().ChainId_(0).Subs_
  26. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  27. ( fx.nde_().Hnd_("b").ChainId_(1)
  28. )
  29. , fx.nde_().Atru_("z").ChainId_(0)
  30. ));
  31. }
  32. @Test public void Nest() {
  33. fx.ini_RootLxr_Add(GfmlDocLxrs.NdeHeader_lxr());
  34. fx.tst_Doc("{a.b.c{d:e;}z;}" // shorthand of {a{b{c{d:e;}}}}
  35. , fx.nde_().ChainId_(0).Subs_
  36. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  37. ( fx.nde_().Hnd_("b").ChainId_(1).Subs_
  38. ( fx.nde_().Hnd_("c").ChainId_(1).Subs_
  39. ( fx.nde_().Hnd_("d").ChainId_(0).Atru_("e")
  40. )
  41. )
  42. )
  43. , fx.nde_().ChainId_(0).Atru_("z")
  44. ));
  45. }
  46. @Test public void Chain() {
  47. fx.tst_Doc("{a.b.c;z;}"
  48. , fx.nde_().ChainId_(0).Subs_
  49. ( fx.nde_().Hnd_("a").ChainId_(1).Subs_
  50. ( fx.nde_().Hnd_("b").ChainId_(1).Subs_
  51. ( fx.nde_().Hnd_("c").ChainId_(1))
  52. )
  53. , fx.nde_().ChainId_(0).Atru_("z")
  54. ));
  55. }
  56. @Test public void NdeHdr() {
  57. fx.ini_RootLxr_Add(GfmlDocLxrs.NdeHeader_lxr());
  58. fx.tst_Doc("{a:b.c;z;}"
  59. , fx.nde_().ChainId_(0).Subs_
  60. ( fx.nde_().Hnd_("a").Atru_("b").ChainId_(1).Subs_
  61. ( fx.nde_().Hnd_("c").ChainId_(1)//.Subs_
  62. // ( fx.nde_().Hnd_("c"))
  63. )
  64. , fx.nde_().Atru_("z").ChainId_(0)
  65. ));
  66. }
  67. }