Exemplo n.º 1
0
        public void CodeSample2()
        {
            var symbols = new SymbolsTable();
              var tokenizer = DefaultLexer.Create();
              var executor = new StatementRunner();
              var sut = new Interpreter(symbols, tokenizer, executor);
              var core = new WebCore();

              var sb = new StringBuilder();
              core.OnPrint += (_, value) =>
              {
            var list = value as IEnumerable;
            if (list == null)
              sb.Append(value.ToString());
            else
            {
              foreach (var item in list)
            sb.AppendLine(item.ToString());
            }
              };

              sut.Run(Resources.Sample2, core);

              var expected = Resources.Expected2.Replace("\\n", "\n");
              var result = sb.ToString();
              Assert.AreEqual(expected, result);

              //A.CallTo(() => core.OpenPage("https://www.google.com/search?q=something+to+search&cad=cbv&sei=drQPVuWtDoS7acCjptgG")).MustHaveHappened();
              //A.CallTo(() => core.Print(A<string>.Ignored)).MustHaveHappened();
              //A.CallTo(() => core.Find(A<string>.Ignored, "//div[class='srg']/div[class='g pb']")).MustHaveHappened();
              //A.CallTo(() => core.Find(A<string>.Ignored, "div[class='st']"));
              //A.CallTo(() => core.Print(A<object>.Ignored)).MustHaveHappened();
        }
Exemplo n.º 2
0
Arquivo: frmMain.cs Projeto: zuun/wSQL
        private void runScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (autosaveOnRunToolStripMenuItem.Checked)
            saveActiveFile();

             var console = tabContainer.GetActiveOutputConsole();
             console.TextOutput = "";
             Application.DoEvents();

             try
             {
            var interpretor = new Interpreter(new SymbolsTable(), DefaultLexer.Create(), new StatementRunner());
            var webCore = new WebCore();
            webCore.OnPrint += WebCore_OnPrint;
            var script = tabContainer.GetActiveEditor().Text;
            interpretor.Run(script, webCore);
            //Task.Factory.StartNew(() => interpretor.Run(script, webCore));
            //interpretor.Run(tabContainer.GetActiveEditor().Text, webCore);
             }
             catch (Exception ex)
             {
            console.TextOutput += ex.Message;
             }
        }