コード例 #1
0
 public void TestHereDocIndentedLiteralError()
 {
     var term = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.AllowIndentedEndToken);
     SetTerminal(term);
     TryMatch(@"<<-BEGIN
     test");
     Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
     Assert.IsTrue(_token.IsError(), "Failed to detect error on invalid heredoc.");
 }
コード例 #2
0
        public void TestHereDocIndentedLiteralError()
        {
            var term   = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.AllowIndentedEndToken);
            var parser = TestHelper.CreateParser(term);
            var token  = parser.ParseInput(@"<<-BEGIN
test");

            Assert.IsNotNull(token, "Failed to produce a token on valid string.");
            Assert.IsTrue(token.IsError, "Failed to detect error on invalid heredoc.");
        }
コード例 #3
0
        public void TestHereDocIndentedLiteralError()
        {
            var term = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.AllowIndentedEndToken);

            SetTerminal(term);
            TryMatch(@"<<-BEGIN
test");
            Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
            Assert.IsTrue(_token.IsError(), "Failed to detect error on invalid heredoc.");
        }
コード例 #4
0
        public void TestHereDocLiteralError()
        {
            var term = new HereDocTerminal("Heredoc", "<<", HereDocOptions.None);

            parser = TestHelper.CreateParser(term);
            token  = parser.ParseToken(@"<<BEGIN
test");
            Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
            Assert.IsTrue(token.IsError(), "Failed to detect error on invalid heredoc.");
        }
コード例 #5
0
 public void TestHereDocIndentedLiteral()
 {
     var term = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.AllowIndentedEndToken);
     SetTerminal(term);
     TryMatch(@"<<-BEGIN
     test
                 BEGIN");
     Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
     Assert.IsNotNull(_token.Value, "Token Value field is null - should be string.");
     Assert.IsTrue((string)_token.Value == "test", "Token Value is wrong, got {0} of type {1}", _token.Value, _token.Value.GetType().ToString());
 }
コード例 #6
0
        public void TestHereDocIndentedLiteral()
        {
            var term   = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.AllowIndentedEndToken);
            var parser = TestHelper.CreateParser(term);
            var token  = parser.ParseInput(@"<<-BEGIN
test
                        BEGIN");

            Assert.IsNotNull(token, "Failed to produce a token on valid string.");
            Assert.IsNotNull(token.Value, "Token Value field is null - should be string.");
            Assert.IsTrue((string)token.Value == Environment.NewLine + "test", "Token Value is wrong, got {0} of type {1}", token.Value, token.Value.GetType());
        }
コード例 #7
0
        public void TestHereDocLiteral()
        {
            var term = new HereDocTerminal("Heredoc", "<<", HereDocOptions.None);

            parser = TestHelper.CreateParser(term);
            token  = parser.ParseToken(@"<<BEGIN
test
BEGIN");
            Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
            Assert.IsNotNull(token.Value, "Token Value field is null - should be string.");
            Assert.IsTrue((string)token.Value == "test", "Token Value is wrong, got {0} of type {1}", token.Value, token.Value.GetType().ToString());
        }
コード例 #8
0
        public void TestHereDocIndentedLiteral()
        {
            var term = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.AllowIndentedEndToken);

            SetTerminal(term);
            TryMatch(@"<<-BEGIN
test
                        BEGIN");
            Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
            Assert.IsNotNull(_token.Value, "Token Value field is null - should be string.");
            Assert.IsTrue((string)_token.Value == "test", "Token Value is wrong, got {0} of type {1}", _token.Value, _token.Value.GetType().ToString());
        }
コード例 #9
0
        public void TestHereDocQuoted()
        {
            var quotes = new HashSet <string> {
                "'", "\""
            };
            var term   = new HereDocTerminal("Heredoc", "<<-", quotes, HereDocOptions.RemoveBeginningNewLine);
            var parser = TestHelper.CreateParser(term);
            var token  = parser.ParseInput(@"<<-'BEGIN'
test
BEGIN");

            Assert.IsNotNull(token, "Failed to produce a token on valid string.");
            Assert.IsNotNull(token.Value, "Token Value field is null - should be string.");
            Assert.IsTrue((string)token.Value == "test", "Token Value is wrong, got {0} of type {1}", token.Value, token.Value.GetType());
        }
コード例 #10
0
 public HereDocTestGrammar()
     : base(true) {
     var heredoc = new HereDocTerminal("HereDoc", "<<", HereDocOptions.None);
     heredoc.AddSubType("<<-", HereDocOptions.AllowIndentedEndToken);
     var @string = new StringLiteral("string", "\"");
     var program = new NonTerminal("program");
     program.Rule = heredoc + @"+" + @string + this.NewLine + @"+" + @string
         | heredoc + @"+" + heredoc + @"+" + @string + this.NewLine
         | heredoc + @"+" + @string + this.NewLine
         | heredoc + @"+" + @string + @"+" + heredoc
         | heredoc + @"+" + heredoc
         | heredoc;
     this.Root = program;
     this.MarkPunctuation("+");
 }
コード例 #11
0
        public void TestHereDocUndentedNotAllowedError()
        {
            var quotes = new HashSet <string> {
                "'", "\""
            };
            var term = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.RemoveBeginningNewLine | HereDocOptions.RemoveIndents);

            term.AddSubType("<<-", quotes, HereDocOptions.None);
            var parser = TestHelper.CreateParser(term);
            var token  = parser.ParseInput(@"<<-BEGIN
test1
    test2
      test3
    BEGIN");

            Assert.IsNotNull(token, "Failed to produce a token on valid string.");
            Assert.IsTrue(token.IsError, "Failed to detect error on invalid heredoc.");
        }
コード例 #12
0
            public HereDocTestGrammar()
                : base(true)
            {
                var heredoc = new HereDocTerminal("HereDoc", "<<", HereDocOptions.None);

                heredoc.AddSubType("<<-", HereDocOptions.AllowIndentedEndToken);
                var @string = new StringLiteral("string", "\"");
                var program = new NonTerminal("program");

                program.Rule = heredoc + @"+" + @string + this.NewLine + @"+" + @string
                               | heredoc + @"+" + heredoc + @"+" + @string + this.NewLine
                               | heredoc + @"+" + @string + this.NewLine
                               | heredoc + @"+" + @string + @"+" + heredoc
                               | heredoc + @"+" + heredoc
                               | heredoc;
                this.Root = program;
                this.MarkPunctuation("+");
            }
コード例 #13
0
        public void TestHereDocUndented()
        {
            var quotes = new HashSet <string> {
                "'", "\""
            };
            var term = new HereDocTerminal("Heredoc", "<<-", HereDocOptions.RemoveBeginningNewLine | HereDocOptions.RemoveIndents | HereDocOptions.AllowIndentedEndToken);

            term.AddSubType("<<-", quotes, HereDocOptions.None);
            var parser = TestHelper.CreateParser(term);
            var token  = parser.ParseInput(@"<<-BEGIN
        test0
test1
    test2
      test3
    BEGIN");

            Assert.IsNotNull(token, "Failed to produce a token on valid string.");
            Assert.IsNotNull(token.Value, "Token Value field is null - should be string.");
            var nl = Environment.NewLine;

            Assert.IsTrue((string)token.Value == $"    test0{nl}test1{nl}test2{nl}  test3", "Token Value is wrong, got {0} of type {1}", token.Value, token.Value.GetType());
        }
コード例 #14
0
        public void TestHereDocLiteral() {
            var term = new HereDocTerminal("Heredoc","<<",HereDocOptions.None);
            parser = TestHelper.CreateParser(term);
            token = parser.ParseToken(@"<<BEGIN
test
BEGIN");
            Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
            Assert.IsNotNull(token.Value, "Token Value field is null - should be string.");
            Assert.IsTrue((string)token.Value == "test", "Token Value is wrong, got {0} of type {1}", token.Value, token.Value.GetType().ToString());
        }
コード例 #15
0
        public void TestHereDocLiteralErrorIndented() {
            var term = new HereDocTerminal("Heredoc", "<<", HereDocOptions.None);
            parser = TestHelper.CreateParser(term);
            token = parser.ParseToken(@"<<BEGIN
test
     BEGIN");
            Assert.IsNotNull(_token, "Failed to produce a token on valid string.");
            Assert.IsTrue(token.IsError(), "Failed to detect error on invalid heredoc.");
        }