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."); }
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."); }
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."); }
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()); }
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()); }
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()); }
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()); }
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("+"); }
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."); }
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()); }
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()); }
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."); }