Пример #1
0
        public void Issue_40()
        {
            const string xml = @"
<xml xmlns=""http://www.w3.org/1999/xhtml"">
  <block type=""controls_if"" id=""`Du+(_vc^5di^SX-r)Gy"" x=""-563"" y=""-187"">
    <value name=""IF0"">
      <block type=""logic_compare"" id=""IzaPI5pFR:fkFMJ@)E]9"">
        <field name=""OP"">EQ</field>
        <value name=""A"">
          <block type=""logic_boolean"">
            <field name=""BOOL"">TRUE</field>
          </block>
        </value>
        <value name=""B"">
          <block type=""logic_boolean"">
            <field name=""BOOL"">TRUE</field>
          </block>
        </value>
      </block>
    </value>
    <statement name=""DO0"">
      <block type=""text_print"" id=""vhk7~#CLW_:TTeXy#.34"">
        <value name=""TEXT"">
          <shadow type=""text"" id=""x?1zGi1mkq)$XIq7*t_-"">
            <field name=""TEXT"">it worked</field>
          </shadow>
        </value>
      </block>
    </statement>
  </block>
</xml>
";

            var output = new Parser()
                         .AddStandardBlocks()
                         .AddDebugPrinter()
                         .Parse(xml)
                         .Evaluate();

            Assert.AreEqual("it worked", TestExtensions.GetDebugText().First());
        }
Пример #2
0
        public void Test_Shadow()
        {
            const string xml = @"
<xml>
  <block type=""text_print"">
    <value name=""TEXT"">
      <shadow type=""text"">
        <field name=""TEXT"">abc</field>
      </shadow>
    </value>
  </block>
</xml>";

            new Parser()
            .AddStandardBlocks()
            .AddDebugPrinter()
            .Parse(xml)
            .Evaluate();

            Assert.AreEqual("abc", TestExtensions.GetDebugText().First());
        }
Пример #3
0
        public void Test_Controls_WhileUntil()
        {
            const string xml    = @"
<xml xmlns=""http://www.w3.org/1999/xhtml"">
  <variables>
    <variable type="""">x</variable>
  </variables>
  <block type=""variables_set"">
    <field name=""VAR"" variabletype="""">x</field>
    <value name=""VALUE"">
      <block type=""math_number"">
        <field name=""NUM"">0</field>
      </block>
    </value>
    <next>
      <block type=""controls_whileUntil"">
        <field name=""MODE"">WHILE</field>
        <value name=""BOOL"">
          <block type=""logic_compare"">
            <field name=""OP"">EQ</field>
            <value name=""A"">
              <block type=""variables_get"">
                <field name=""VAR"" variabletype="""">x</field>
              </block>
            </value>
            <value name=""B"">
              <block type=""math_number"">
                <field name=""NUM"">0</field>
              </block>
            </value>
          </block>
        </value>
        <statement name=""DO"">
          <block type=""text_print"">
            <value name=""TEXT"">
              <shadow type=""text"">
                <field name=""TEXT"">abc</field>
              </shadow>
              <block type=""variables_get"">
                <field name=""VAR"" variabletype="""">x</field>
              </block>
            </value>
            <next>
              <block type=""variables_set"">
                <field name=""VAR"" variabletype="""">x</field>
                <value name=""VALUE"">
                  <block type=""math_number"">
                    <field name=""NUM"">1</field>
                  </block>
                </value>
              </block>
            </next>
          </block>
        </statement>
      </block>
    </next>
  </block>
</xml>
";
            var          parser = new Parser()
                                  .AddStandardBlocks()
                                  .AddDebugPrinter()
                                  .Parse(xml)
                                  .Evaluate();

            Assert.AreEqual("0", string.Join(",", TestExtensions.GetDebugText()));
        }