Пример #1
0
        public void TestGenFunctionFolding()
        {
            var translator = new Mq4Translator();
            Assert.IsTrue(translator.Parse(ScriptUtils.ComplexFunctionWrongFolding));
            var code = translator.GenerateCode();

            Assert.IsFalse(string.IsNullOrEmpty(code));
        }
Пример #2
0
        public void TestGenComplexIfs()
        {
            var translator = new Mq4Translator();
            Assert.IsTrue(translator.Parse(ScriptUtils.ComplexIfsCode));
            var code = translator.GenerateCode();

            Assert.IsFalse(string.IsNullOrEmpty(code));
        }
Пример #3
0
        public void TestMethod1()
        {
            var translator = new Mq4Translator();
            translator.Parse(ScriptUtils.ComplexCode);
            var code = translator.GenerateCode();

            Assert.IsFalse(string.IsNullOrEmpty(code));
        }
Пример #4
0
        public void TestArrayCodeGen()
        {
            var translator = new Mq4Translator();
            const string fileText = ScriptUtils.SimpleArray;
            var resultParse = translator.Parse(fileText);
            Assert.IsTrue(resultParse);
            var code = translator.GenerateCode();

            Assert.IsFalse(string.IsNullOrEmpty(code));
            var formattedCode = code.BeautifyCsFileSource();
            var fileErrors = code.CsFileErrors().Select(err =>
                                                        string.Format("{0}: {1}", err.Region, err.Message)).ToArray();

            Assert.IsFalse(string.IsNullOrEmpty(code));
            Assert.IsTrue(fileErrors.Length == 0);
        }
Пример #5
0
 void UpdateSource(string text)
 {
     try
     {
         var translator = new Mq4Translator();
         translator.Parse(text);
         var code = translator.GenerateCode();
         var formattedCode = code.BeautifyCsFileSource();
         var errors = code.CsFileErrors().Select(err => err.ErrorPrettyPrinter());
         UiService.InvokeMainThread(() =>
         {
             WriteError(string.Join(Environment.NewLine, errors));
             OutputEditor.TextEditor.Text = formattedCode;
         });
     }
     catch (Exception ex)
     {
         UiService.InvokeMainThread(() =>
         {
             var message = ex.Message;
             WriteError(message);
         });
     }
 }
Пример #6
0
        public static string GetFileResultScript(string fileToTest)
        {
            IncludePaths.BlackListIncludeFile("stdlib.mqh");
            IncludePaths.AddDirectoryInclude(@"C:\ProgramData\MetaTrader ECN - FXOpen\experts\include\");
            var translator = new Mq4Translator();
            var fileText = fileToTest.CodeFromExtras(Encoding.Default);
            var resultParse = translator.Parse(fileText);
            Assert.IsTrue(resultParse);
            var code = translator.GenerateCode();

            Assert.IsFalse(string.IsNullOrEmpty(code));
            var formattedCode = code.BeautifyCsFileSource();
            var fileErrors = code.CsFileErrors().Select(err =>
                                                        string.Format("Error ({0}:{1}): {2} ", err.Region.BeginLine,
                                                                      err.Region.BeginColumn, err.Message))
                .ToList();

            Assert.IsFalse(string.IsNullOrEmpty(code));
            Assert.IsTrue(fileErrors.Count == 0);
            return formattedCode;
        }
Пример #7
0
        public static void TestFileParsing(string fileToTest)
        {
            IncludePaths.BlackListIncludeFile("stdlib.mqh");
            IncludePaths.AddDirectoryInclude(@"C:\ProgramData\MetaTrader ECN - FXOpen\experts\include\");
            var translator = new Mq4Translator();
            var fileText = fileToTest.CodeFromExtras(Encoding.Default);
            var resultParse = translator.Parse(fileText, false);
            Assert.IsTrue(resultParse);
            var code = translator.GenerateCode();

            Assert.IsFalse(string.IsNullOrEmpty(code));
        }