コード例 #1
0
 public void First_Character_Isnt_Less_Than_Returns_Html_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.Html, "echo(\"test\");" }
     });
 }
コード例 #2
0
 public void Standard_Open_And_Close_Tags_Returns_OpenTag_And_CloseTag_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?php" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
コード例 #3
0
 public void All_Tokens_Not_In_PHP_Open_Close_Tags_Returns_Html_Token()
 {
     TokenAssert.AreHtmlTokens(new[] {
         "+", "&", "&&", "=", "``", ",", "//", "///", "/* comment */", "~",
         ".=", "--", "/=", "/", ";", "==", "@", ">", ">=", "===", "-"
     });
 }
コード例 #4
0
 public void Bad_Open_Tag_Returns_Html_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.Html, "<=$variable?>" }
     });
 }
コード例 #5
0
 public void Asp_Open_And_Close_Tags_Returns_OpenTag_And_CloseTag_Tokens()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<%" },
         { PhpTokenType.CloseTag, "%>" }
     });
 }
コード例 #6
0
 public void Infinity_Number_Returns_Number_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Number,
                         "5863527282178658728638282465756887109828727827654321987654313467543856894567354783568567456845674567" +
                         "4568456879567967806789567835672457356845681754328057895676305123516234516879145256946795686296754296" +
                         "8541234634578356854683456735423475469675723465689456825624590764786234635685673456283456895645687456" +
                         "8923745902834758902347590234652908357902384759023847590238457092384572345908273459087234590872345234");
 }
コード例 #7
0
 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, "%>" }
     });
 }
コード例 #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, "?>" }
     });
 }
コード例 #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, "?>" }
     });
 }
コード例 #10
0
 public void Equals_Equals_Equals_Returns_IdenticalOperator_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.IdenticalOperator, "===" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
コード例 #11
0
 public void Equals_Sign_Returns_AssignmentOperator_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.AssignmentOperator, "=" },
         { PhpTokenType.CloseTag, "?>" }
     });
 }
コード例 #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, "?>" }
     });
 }
コード例 #13
0
 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, "?>" }
     });
 }
コード例 #14
0
 public void Identifier_With_Underscore_Right_Space_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(new TokenPairs
     {
         { PhpTokenType.OpenTag, "<?" },
         { PhpTokenType.Identifier, "var_dump" },
         { PhpTokenType.WhiteSpace, " " },
         { PhpTokenType.CloseTag, "?>" },
     });
 }
コード例 #15
0
 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, "?>" },
     });
 }
コード例 #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, "?>" }
     });
 }
コード例 #17
0
 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, "?>" },
     }));
 }
コード例 #18
0
 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, "?>" }
     });
 }
コード例 #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, "?>" }
     });
 }
コード例 #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, "?>" },
     });
 }
コード例 #21
0
 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, "?>" }
     });
 }
コード例 #22
0
 public void Up_Carrot_Equals_Returns_XorEqualOperator_Token()
 {
     TokenAssert.IsValid(PhpTokenType.XorEqualOperator, "^=");
 }
コード例 #23
0
 public void Tab_Returns_WhiteSpace_Token()
 {
     TokenAssert.IsValid(PhpTokenType.WhiteSpace, "\t");
 }
コード例 #24
0
 public void Backslash_N_Returns_WhiteSpace_Token()
 {
     TokenAssert.IsValid(PhpTokenType.WhiteSpace, "\n");
 }
コード例 #25
0
 public void Up_Carrot_Returns_XorOperator_Token()
 {
     TokenAssert.IsValid(PhpTokenType.XorOperator, "^");
 }
コード例 #26
0
 public void LessThan_QuestionMark_Equals_Returns_OpenTagWithEcho_Token()
 {
     TokenAssert.IsValid(new TokenPairs {
         { PhpTokenType.OpenTagWithEcho, "<?=" }
     });
 }
コード例 #27
0
 public void ElseIf_Returns_ElseIfKeyword_Token()
 {
     TokenAssert.IsValid(PhpTokenType.elseifKeyword, "elseif");
 }
コード例 #28
0
 public void Identifier_With_Underscore_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Identifier, "var_dump");
 }
コード例 #29
0
 public void ElseIfx_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Identifier, "elseifx");
 }
コード例 #30
0
 public void E_Returns_Identifier_Token()
 {
     TokenAssert.IsValid(PhpTokenType.Identifier, "e");
 }