public void First_Character_Isnt_Less_Than_Returns_Html_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.Html, "echo(\"test\");" }
     });
 }
 public void Standard_Open_And_Close_Tags_Returns_OpenTag_And_CloseTag_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?php" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void All_Tokens_Not_In_PHP_Open_Close_Tags_Returns_Html_Token()
 {
     TokenAssert.AreHtmlTokens(new[] {
         "+", "&", "&&", "=", "``", ",", "//", "///", "/* comment */", "~",
         ".=", "--", "/=", "/", ";", "==", "@", ">", ">=", "===", "-"
     });
 }
 public void Bad_Open_Tag_Returns_Html_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.Html, "<=$variable?>" }
     });
 }
 public void Asp_Open_And_Close_Tags_Returns_OpenTag_And_CloseTag_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<%" },
         { PhpTokenType.CloseTag, "%>" }
     });
 }
 public void Infinity_Number_Returns_Number_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Number,
                         "5863527282178658728638282465756887109828727827654321987654313467543856894567354783568567456845674567" +
                         "4568456879567967806789567835672457356845681754328057895676305123516234516879145256946795686296754296" +
                         "8541234634578356854683456735423475469675723465689456825624590764786234635685673456283456895645687456" +
                         "8923745902834758902347590234652908357902384759023847590238457092384572345908273459087234590872345234");
 }
 public void Simple_Open_And_Close_Tags_With_Variable_Returns_OpenTagWithEcho_And_Variable_And_CloseTag_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTagWithEcho, "<%=" },
         { PhpTokenType.Variable, "$variable" },
         { PhpTokenType.CloseTag, "%>" }
     });
 }
Example #8
0
 public void HereDoc_With_Extra_Whitespace_Returns_HereDocString_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.HereDocString, "<<<\t \t _EOT_ \t \t\n<<<\n_EOT_" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
Example #9
0
 public void HereDoc_Single_Quoted_Terminal_Returns_HereDocString_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.HereDocString, "<<<'_EOT_'\ntest\n_EOT_" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void Equals_Equals_Equals_Returns_IdenticalOperator_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.IdenticalOperator, "===" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void Equals_Sign_Returns_AssignmentOperator_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.AssignmentOperator, "=" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
Example #12
0
 public void HereDoc_With_Other_Tokens_Returns_HereDocString_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.HereDocString, "<<<EOT\n//@\n'test'\"value\"<<<\nEOT" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void Simple_Open_And_Close_Tags_Around_Backslash_R_Backslash_N_Returns_WhiteSpace_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, "\r" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void Identifier_With_Underscore_Right_Space_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.Identifier, "var_dump" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.CloseTag, "?>" },
     });
 }
 public void Dollar_Sign_Dollar_Sign_Word_Returns_VariableVariable_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.VariableVariable, "$" },
         { PhpTokenType.Variable, "$foo" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.CloseTag, "?>" },
     });
 }
Example #16
0
 public void Three_Less_Thans_Returns_HereDocString_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.Variable, "$test" },
         { PhpTokenType.AssignmentOperator, "=" },
         { PhpTokenType.HereDocString, "<<<EOT\nEOT" },
         { PhpTokenType.EndOfStatement, ";" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void Invalid_Hexadecimal_Number_Returns_Unknown_Token()
 {
     new string[] { "g", "G", }.Iter(x =>
                                     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Unknown, "0x" },
         { PhpTokenType.Identifier, x + "aaAAffFF" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.CloseTag, "?>" },
     }));
 }
 public void Print_Addition_Returns_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?php" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Identifier, "print" },
         { PhpTokenType.LeftParenthesis, "(" },
         { PhpTokenType.Number, "1" },
         { PhpTokenType.AdditionOperator, "+" },
         { PhpTokenType.Number, "2" },
         { PhpTokenType.RightParenthesis, ")" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
Example #19
0
 public void HereDoc_In_Arguments_Returns_HereDocString_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?php" },
         { PhpTokenType.Identifier, "var_dump" },
         { PhpTokenType.LeftParenthesis, "(" },
         { PhpTokenType.arrayKeyword, "array" },
         { PhpTokenType.LeftParenthesis, "(" },
         { PhpTokenType.HereDocString, "<<<EOD\nfoobar!\nEOD" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.RightParenthesis, ")" },
         { PhpTokenType.RightParenthesis, ")" },
         { PhpTokenType.EndOfStatement, ";" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
Example #20
0
 public void PHP_Supports_C_And_C_Plus_Plus_And_Perl_Style_Comments()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.OpenTag, "<?php" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Identifier, "echo" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.String, "'This is a test'" },
         { PhpTokenType.EndOfStatement, ";" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Comment, "// This is a one-line c++ style comment" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.Comment, "/*  This is a multi line comment\n       yet another line of comment */" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Identifier, "echo" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.String, "'This is yet another test'" },
         { PhpTokenType.EndOfStatement, ";" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Identifier, "echo" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.String, "'One Final Test'" },
         { PhpTokenType.EndOfStatement, ";" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.Comment, "# This is a one-line shell-style comment" },
         { PhpTokenType.WhiteSpace, "\n" },
         { PhpTokenType.CloseTag, "?>" },
     });
 }
 public void Basic_Ternary_Expression_Returns_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.Identifier, "print" },
         { PhpTokenType.LeftParenthesis, "(" },
         { PhpTokenType.LeftParenthesis, "(" },
         { PhpTokenType.Identifier, "true" },
         { PhpTokenType.OrOperator, "||" },
         { PhpTokenType.Identifier, "false" },
         { PhpTokenType.RightParenthesis, ")" },
         { PhpTokenType.TernaryOperator, "?" },
         { PhpTokenType.String, "'yay'" },
         { PhpTokenType.ColonOperator, ":" },
         { PhpTokenType.String, "'nay'" },
         { PhpTokenType.RightParenthesis, ")" },
         { PhpTokenType.EndOfStatement, ";" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
 public void Up_Carrot_Equals_Returns_XorEqualOperator_Token()
 {
     TokenAssert.IsValid(PhpTokenType.XorEqualOperator, "^=");
 }
 public void Tab_Returns_WhiteSpace_Token()
 {
     TokenAssert.IsValid(PhpTokenType.WhiteSpace, "\t");
 }
 public void Backslash_N_Returns_WhiteSpace_Token()
 {
     TokenAssert.IsValid(PhpTokenType.WhiteSpace, "\n");
 }
 public void Up_Carrot_Returns_XorOperator_Token()
 {
     TokenAssert.IsValid(PhpTokenType.XorOperator, "^");
 }
 public void LessThan_QuestionMark_Equals_Returns_OpenTagWithEcho_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTagWithEcho, "<?=" }
     });
 }
 public void ElseIf_Returns_ElseIfKeyword_Token()
 {
     TokenAssert.IsValid(PhpTokenType.elseifKeyword, "elseif");
 }
 public void Identifier_With_Underscore_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Identifier, "var_dump");
 }
 public void ElseIfx_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Identifier, "elseifx");
 }
 public void E_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Identifier, "e");
 }