z482_vars_parse_tst.java 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 z482_vars_parse_tst {
  15. GfmlTypeCompiler_fxt fx = GfmlTypeCompiler_fxt.new_();
  16. @Test public void Basic() {
  17. fx.tst_Parse(String_.Concat
  18. ( "_var:{"
  19. , " size '20,20';"
  20. , "}"
  21. , "'<~size>';"
  22. )
  23. , fx.nde_().Atru_("20,20")
  24. );
  25. }
  26. @Test public void Many() {
  27. fx.tst_Parse(String_.Concat
  28. ( "_var:{"
  29. , " size '20,20';"
  30. , " pos '30,30';"
  31. , "}"
  32. , "'<~size>' '<~pos>';"
  33. )
  34. , fx.nde_().Atru_("20,20").Atru_("30,30")
  35. );
  36. }
  37. @Test public void Deferred() {
  38. fx.tst_Parse(String_.Concat
  39. ( "_var:{"
  40. , " key0 '<~key1>';"
  41. , "}"
  42. , "_var:{"
  43. , " key1 val1;"
  44. , "}"
  45. , "'<~key0>';"
  46. )
  47. , fx.nde_().Atru_("val1")
  48. );
  49. }
  50. @Test public void Swap() {
  51. fx.tst_Parse(String_.Concat
  52. ( "{"
  53. , " _var:{"
  54. , " size '20,20';"
  55. , " }"
  56. , " '<~size>';"
  57. , " _var:{"
  58. , " size '30,30';"
  59. , " }"
  60. , " '<~size>';"
  61. , "}"
  62. )
  63. , fx.nde_().Subs_
  64. ( fx.nde_().Atru_("20,20")
  65. , fx.nde_().Atru_("30,30")
  66. )
  67. );
  68. }
  69. @Test public void Context() {
  70. fx.tst_Parse(String_.Concat
  71. ( "_var:{"
  72. , " size '20,20' gui;"
  73. , "}"
  74. , "'<~gui.size>' <~size>;"
  75. )
  76. , fx.nde_().Atru_("20,20").Atru_("<~size>")
  77. );
  78. }
  79. }