コード例 #1
0
        public void Simplify_PhpCodeWithConstants_ConstantsFolded()
        {
            var sourceCodeRep = new MemoryCodeRepository(
                "<?php\r\n" +
                "echo 'Hello ' . 'World' . '!';\r\n" +
                "echo 60 * 60 * 24;\r\n" +
                "echo 6 + 6 * 6;\r\n" +
                "$a = -3;\r\n" +
                "$b = -3.1;",

                "constants.php"
                );
            var logger   = new LoggerMessageCounter();
            var workflow = new Workflow(sourceCodeRep, stage: Stage.Ust)
            {
                IsSimplifyUst = true,
                Logger        = logger
            };

            workflow.Process();

            Assert.IsTrue(logger.ContainsDebugMessagePart("Hello World!"));
            Assert.IsTrue(logger.ContainsDebugMessagePart("86400"));
            Assert.IsTrue(logger.ContainsDebugMessagePart("42"));
            Assert.IsTrue(logger.ContainsDebugMessagePart("-3"));
            Assert.IsTrue(logger.ContainsDebugMessagePart("-3.1"));
        }
コード例 #2
0
        public void Preprocess_CodeWithConstants_ConstantsFolded()
        {
            var sourceCodeRep = new MemoryCodeRepository(
                "<?php\r\n" +
                "echo 'Hello ' . 'World' . '!';\r\n" +
                "echo 60 * 60 * 24;\r\n" +
                "echo 6 + 6 * 6;"
                );
            var logger   = new LoggerMessageCounter();
            var workflow = new Workflow(sourceCodeRep, Language.Php, stage: Stage.Preprocess);

            workflow.IsIncludePreprocessing = true;
            workflow.Logger = logger;
            workflow.Process();

            Assert.IsTrue(logger.ContainsDebugMessagePart("Hello World!"));
            Assert.IsTrue(logger.ContainsDebugMessagePart("86400"));
            Assert.IsTrue(logger.ContainsDebugMessagePart("42"));
        }