Example #1
0
        public void DoesNotThrow()
        {
            var testCode = $"{GlobalCode()}\r\n" +
                           $"<ROUTINE GO ({argSpec})\r\n" +
                           $"\t{body}\r\n" +
                           "\t<QUIT>>";

            ZlrHelperRunResult result;

            try
            {
                result = ZlrHelper.Run(testCode, null, compileOnly: true, wantDebugInfo: wantDebugInfo);
            }
            catch (Exception ex)
            {
                Assert.Fail("Expected no exception, but caught {0}", ex);

                // can't get here, but the compiler doesn't know that...
                // ReSharper knows, but we still can't remove the return

                // ReSharper disable once HeuristicUnreachableCode
                return;
            }

            CheckWarnings(result);
        }
Example #2
0
        public void DoesNotCompile()
        {
            var testCode = $"{GlobalCode()}\r\n" +
                           $"<ROUTINE GO ({argSpec})\r\n" +
                           $"\t{body}\r\n" +
                           "\t<QUIT>>";

            var result = ZlrHelper.Run(testCode, null, compileOnly: true, wantDebugInfo: wantDebugInfo);

            Assert.AreEqual(ZlrTestStatus.CompilationFailed, result.Status);

            CheckWarnings(result);
        }
Example #3
0
        public void Compiles()
        {
            var testCode =
                $"{GlobalCode()}\r\n" +
                "<GLOBAL DUMMY?VAR <>>\r\n" +
                "<ROUTINE GO ()\r\n" +
                $"\t<SETG DUMMY?VAR {Expression()}>\r\n" +
                "\t<QUIT>>";

            var result = ZlrHelper.Run(testCode, null, compileOnly: true, wantDebugInfo: wantDebugInfo);

            Assert.IsTrue(result.Status > ZlrTestStatus.CompilationFailed,
                          "Failed to compile");

            CheckWarnings(result);
        }
Example #4
0
        public void DoesNotCompile([CanBeNull] Predicate <ZlrHelperRunResult> resultFilter = null,
                                   [CanBeNull] string message = null)
        {
            var testCode =
                $"{GlobalCode()}\r\n" +
                "<GLOBAL DUMMY?VAR <>>\r\n" +
                "<ROUTINE GO ()\r\n" +
                $"\t<SETG DUMMY?VAR {Expression()}>\r\n" +
                "\t<QUIT>>";

            var result = ZlrHelper.Run(testCode, null, compileOnly: true, wantDebugInfo: wantDebugInfo);

            Assert.AreEqual(ZlrTestStatus.CompilationFailed, result.Status);

            CheckWarnings(result);

            if (resultFilter != null)
            {
                Assert.IsTrue(resultFilter(result), message ?? "Result filter failed");
            }
        }