📄 php.test
字号:
source testutil.tcl# ---------------------------------------------# The first series of token tests check to make# sure the browser is properly splitting the# text input into tokens and dumping them# to a file in a known format.# ---------------------------------------------tcltest::test tokens-1.0 { parse into tokens } { browse_tokens [save_file f.php {<HTML>My HTML is $cash=money.</HTML>}]} {0 HTML "\n<HTML>\nMy HTML is $cash=money.\n</HTML>\n" 1.0 5.0}tcltest::test tokens-1.1 { parse into tokens } { browse_tokens [save_file f.php {HTML<?//COMMENT?>HTML}]} {0 HTML "HTML\n<?" 1.0 2.21 COMMENT "COMMENT" 2.2 2.112 HTML "?>\nHTML" 2.11 3.4}tcltest::test tokens-1.2 { parse into tokens } { browse_tokens [save_file f.php {HTML<?//COMMENT?>}]} {0 HTML "HTML\n<?" 1.0 2.21 COMMENT "COMMENT" 2.2 2.112 HTML "?>" 2.11 2.13}tcltest::test tokens-1.3 { parse into tokens } { browse_tokens [save_file f.php {HTML<?php//COMMENT?>HTML}]} {0 HTML "HTML\n<?php" 1.0 2.51 COMMENT "COMMENT" 2.5 2.142 HTML "?>\nHTML" 2.14 3.4}tcltest::test tokens-1.4 { parse into tokens } { browse_tokens [save_file f.php {HTML<?PHP$var?>HTML}]} {0 HTML "HTML\n<?PHP" 1.0 2.51 VARIABLE "var" 2.5 2.92 HTML "?>\nHTML" 2.9 3.4}tcltest::test tokens-1.5 { parse into tokens } { browse_tokens [save_file f.php {<?=$var?>}]} {0 HTML "\n<?=" 1.0 2.31 VARIABLE "var" 2.3 2.72 HTML "?>\n" 2.7 3.0}tcltest::test tokens-1.6 { CRLF -> LF translation } { set fd [open f.php w] fconfigure $fd -translation binary -encoding binary puts -nonewline $fd "\r\n<?=\$var?>\r\n" close $fd browse_tokens f.php} {0 HTML "\n<?=" 1.0 2.31 VARIABLE "var" 2.3 2.72 HTML "?>\n" 2.7 3.0}tcltest::test tokens-2.0 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?#My Comment?>}]]} {1 COMMENT "My Comment" 3.0 3.11}tcltest::test tokens-2.1 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?//My Comment?>}]]} {1 COMMENT "My Comment" 3.0 3.12}tcltest::test tokens-2.2 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?/*My Comment*/?>}]]} {1 COMMENT "My Comment" 3.0 3.14}tcltest::test tokens-2.3 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?/*A "quoted" comment*/?>}]]} {1 COMMENT "A \"quoted\" comment" 3.0 3.22}tcltest::test tokens-2.4 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?/*AnotherComment*/?>}]]} {1 COMMENT "Another\nComment" 3.0 4.9}tcltest::test tokens-3.0 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?$var?>}]]} {1 VARIABLE "var" 3.0 3.4}tcltest::test tokens-3.1 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?$var=1?>}]]} {1 VARIABLE "var" 3.0 3.42 ASSIGNMENT_OPERATOR "" 3.4 3.53 SOMEWORD "1" 3.5 3.6}tcltest::test tokens-3.2 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?$var[]=1?>}]]} {1 VARIABLE "var" 3.0 3.42 OPEN_BRACKET "" 3.4 3.53 CLOSE_BRACKET "" 3.5 3.64 ASSIGNMENT_OPERATOR "" 3.6 3.75 SOMEWORD "1" 3.7 3.8}tcltest::test tokens-3.3 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?$foo = &$bar;?>}]]} {1 VARIABLE "foo" 3.0 3.42 ASSIGNMENT_OPERATOR "" 3.5 3.63 REFERENCE_OPERATOR "" 3.7 3.84 VARIABLE "bar" 3.8 3.125 SEMICOLON "" 3.12 3.13}tcltest::test tokens-3.4 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?$var++;--$var;?>}]]} {1 VARIABLE "var" 3.0 3.42 INCREMENT_OPERATORS "++" 3.4 3.63 SEMICOLON "" 3.6 3.74 INCREMENT_OPERATORS "--" 4.0 4.25 VARIABLE "var" 4.2 4.66 SEMICOLON "" 4.6 4.7}tcltest::test tokens-3.5 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?\$myvar;?>}]]} {1 SOMEWORD "\\$" 3.0 3.22 SOMEWORD "myvar" 3.2 3.73 SEMICOLON "" 3.7 3.8}tcltest::test tokens-3.6 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?<<<END/*not-comment*/END;?>}]]} {1 DOUBLE_QUOTED_STRING "/*not-comment*/" 3.0 5.32 SEMICOLON "" 5.3 5.4}tcltest::test tokens-3.7 { parse into tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?<<<END/*not-comment*//*not-comment*/END;?>}]]} {1 DOUBLE_QUOTED_STRING "/*not-comment*/\n/*not-comment*/" 3.0 6.32 SEMICOLON "" 6.3 6.4}tcltest::test tokens-4.0 { unknown tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?!!$var;?>}]]} {1 UNKNOWN "!" 3.0 3.12 UNKNOWN "!" 3.1 3.23 VARIABLE "var" 3.2 3.64 SEMICOLON "" 3.6 3.7}tcltest::test tokens-4.1 { unknown tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?$var ~= 1;?>}]]} {1 VARIABLE "var" 3.0 3.42 UNKNOWN "~" 3.5 3.63 ASSIGNMENT_OPERATOR "" 3.6 3.74 SOMEWORD "1" 3.8 3.95 SEMICOLON "" 3.9 3.10}tcltest::test tokens-5.0 { double quoted string tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?"hi"?>}]]} {1 DOUBLE_QUOTED_STRING "hi" 3.0 3.4}tcltest::test tokens-5.1 { double quoted string tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?"hithere"?>}]]} {1 DOUBLE_QUOTED_STRING "hi\nthere" 3.0 4.6}tcltest::test tokens-5.2 { double quoted string tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?"hi\"there\""?>}]]} {1 DOUBLE_QUOTED_STRING "hi\\\"there\\\"" 3.0 3.13}tcltest::test tokens-5.3 { double quoted string tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?"hi\\""?>}]]} {1 DOUBLE_QUOTED_STRING "hi\\\\\"" 3.0 3.7}tcltest::test tokens-6.0 { keyword tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?include "file";?>}]]} {1 INCLUDE_KEYWORD "include" 3.0 3.72 DOUBLE_QUOTED_STRING "file" 3.8 3.143 SEMICOLON "" 3.14 3.15}tcltest::test tokens-6.1 { keyword tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?1 and 2?>}]]} {1 SOMEWORD "1" 3.0 3.12 KEYWORD "and" 3.2 3.53 SOMEWORD "2" 3.6 3.7}tcltest::test tokens-6.2 { keyword tokens } { filter_tokens HTML [browse_tokens [save_file f.php {<?if (1) {}?>}]]} {1 KEYWORD "if" 3.0 3.22 OPEN_PAREN "" 3.3 3.43 SOMEWORD "1" 3.4 3.54 CLOSE_PAREN "" 3.5 3.65 OPEN_BRACE "" 3.7 3.86 CLOSE_BRACE "" 3.8 3.9}# ---------------------------------------------# These next tests check the highlighter function# of a browser. When invoked with the -h and -s# options, a browser will emit a file that# contains text tags and file locations that# will be used by the editor to highlight text.# ---------------------------------------------tcltest::test highlight-1.0 { highlight } { browse_highlights [save_file f.php {<HTML>My HTML is $cash=money.</HTML>}]} {}tcltest::test highlight-1.1 { highlight } { browse_highlights [save_file f.php {<?// Comment?>}]} {1 rem 3.0 3.10}tcltest::test highlight-1.2 { highlight } { browse_highlights [save_file f.php {<?"String"?>}]} {1 str 3.0 3.8}tcltest::test highlight-1.3 { highlight } { browse_highlights [save_file f.php {<?'String'?>}]} {1 str 3.0 3.8}tcltest::test highlight-1.4 { highlight } { browse_highlights [save_file f.php {<?<<< ENDStringEND;?>}]} {1 str 3.0 5.3}tcltest::test highlight-1.5 { highlight } { browse_highlights [save_file f.php {<?'$var'?>}]} {1 str 3.0 3.6}tcltest::test highlight-1.6 { highlight } { browse_highlights [save_file f.php {<?"$var"?>}]} {1 str 3.0 3.62 gv 3.1 3.5}tcltest::test highlight-1.7 { highlight } { browse_highlights [save_file f.php {<?print <<<ENDhi $varEND;?>}]} {1 key 3.0 3.52 str 3.6 5.33 gv 4.3 4.7}tcltest::test highlight-1.8 { highlight } { browse_highlights [save_file f.php {<?function foo() { global $var; $var=1;}?>}]} {1 key 3.0 3.82 key 4.4 4.103 gv 4.11 4.154 gv 5.4 5.8}tcltest::test highlight-1.9 { highlight } { browse_highlights [save_file f.php {<?function foo() { $val=1 }?>}]} {1 key 3.0 3.82 lv 3.17 3.21}tcltest::test highlight-1.10 { highlight } { browse_highlights [save_file f.php {<?function foo() { "$val" }?>}]} {1 key 3.0 3.82 str 3.17 3.233 lv 3.18 3.22}tcltest::test highlight-1.11 { highlight } { browse_highlights [save_file f.php {<?$arr[$index]?>}]} {1 gv 3.5 3.112 gv 3.0 3.4}tcltest::test highlight-1.12 { highlight } { browse_highlights [save_file f.php {<?$arr["val1" . "val2"]?>}]} {1 str 3.5 3.112 str 3.14 3.203 gv 3.0 3.4}tcltest::test highlight-1.13 { highlight } { browse_highlights [save_file f.php {<?$arr["ind1"]['ind2']?>}]} {1 str 3.5 3.112 str 3.13 3.193 gv 3.0 3.4}tcltest::test highlight-1.14 { highlight super global } { browse_highlights [save_file f.php {<?function foo() { print $_GET['num']}?>}]} {1 key 3.0 3.82 key 4.4 4.93 str 4.16 4.214 gv 4.10 4.15}tcltest::test highlight-1.15 { highlight function xref } { browse_highlights [save_file f.php {<?function foo() {}foo();?>}]} {1 key 3.0 3.82 fu 4.0 4.3}tcltest::test highlight-2.0 { highlight special keywords } { browse_highlights [save_file f.php {<?function foo($var="default") {}global $var;include "f1.php";include_once "f1.php";require "f1.php";require_once "f1.php";?>}]} {1 key 3.0 3.82 lv 3.13 3.173 str 3.18 3.274 key 4.0 4.65 key 5.0 5.76 str 5.8 5.167 key 6.0 6.128 str 6.13 6.219 key 7.0 7.710 str 7.8 7.1611 key 8.0 8.1212 str 8.13 8.21}tcltest::test highlight-2.1 { highlight other keywords } { browse_highlights [save_file f.php {<?andorxorarrayasbreakcasecfunctionclassconstcontinuedeclaredefaultdiedoechoelseelseifemptyenddeclareendforendforeachendifendswitchendwhileevalexitextendsforforeachifissetlistnewold_functionprintreturnstaticswitchunsetusevarwhile__FUNCTION____FILE____CLASS____LINE__?>}]} {1 key 3.0 3.32 key 4.0 4.23 key 5.0 5.34 key 6.0 6.55 key 7.0 7.26 key 8.0 8.57 key 9.0 9.48 key 10.0 10.99 key 11.0 11.510 key 12.0 12.511 key 13.0 13.812 key 14.0 14.713 key 15.0 15.714 key 16.0 16.315 key 17.0 17.216 key 18.0 18.417 key 19.0 19.418 key 20.0 20.619 key 21.0 21.520 key 22.0 22.1021 key 23.0 23.622 key 24.0 24.1023 key 25.0 25.524 key 26.0 26.925 key 27.0 27.826 key 28.0 28.427 key 29.0 29.428 key 30.0 30.729 key 31.0 31.330 key 32.0 32.731 key 33.0 33.232 key 34.0 34.533 key 35.0 35.434 key 36.0 36.335 key 37.0 37.1236 key 38.0 38.537 key 39.0 39.638 key 40.0 40.639 key 41.0 41.640 key 42.0 42.541 key 43.0 43.342 key 44.0 44.343 key 45.0 45.544 key 46.0 46.1245 key 47.0 47.846 key 48.0 48.947 key 49.0 49.8}# ---------------------------------------------# The rest of the tests check for output that# can be understood by dbimp. Generated tokens# are processed and matched to known constructs# like function and variable assignments.# ---------------------------------------------tcltest::test mode-1.0 { skip html code } { browse [save_file f.php {<HTML>My HTML is $cash=money.</HTML>}]} {Status: Parsing: f.phpPAF_FILE;f.php;php<>}tcltest::test mode-1.1 { skip html code } { browse [save_file f.php {<HTML>function foo() {}</HTML>}]} {Status: Parsing: f.phpPAF_FILE;f.php;php<>}tcltest::test mode-2.0 { php mode } { browse [save_file f.php {<?function foo() {}?>}]} {Status: Parsing: f.phpPAF_FILE;f.php;php<>PAF_FUNC_DEF;foo<>000003.009<>f.php;3.12<>0x0<>{}<>{}<>{}<>{}PAF_FILE_SYMBOLS;f.php<>000003.000<>#<>foo<>fu;3.17<>3.9<>3.12<>{}}tcltest::test mode-2.1 { php mode } { browse [save_file f.php {<? function foo() {} ?>function bar() {}}]} {Status: Parsing: f.phpPAF_FILE;f.php;php<>PAF_FUNC_DEF;foo<>000002.012<>f.php;2.15<>0x0<>{}<>{}<>{}<>{}PAF_FILE_SYMBOLS;f.php<>000002.003<>#<>foo<>fu;2.20<>2.12<>2.15<>{}}tcltest::test mode-2.2 { php mode } { browse [save_file f.php {function bar() {}<? function foo() {} ?>}]} {Status: Parsing: f.phpPAF_FILE;f.php;php<>PAF_FUNC_DEF;foo<>000003.012<>f.php;3.15<>0x0<>{}<>{}<>{}<>{}PAF_FILE_SYMBOLS;f.php<>000003.003<>#<>foo<>fu;3.20<>3.12<>3.15<>{}}tcltest::test mode-2.3 { html->php->html->php mode } { browse [save_file f.php {function bar1() {}<? function foo1() {} ?>function bar2() {}<? function foo2() {} ?>}]} {Status: Parsing: f.phpPAF_FILE;f.php;php<>PAF_FUNC_DEF;foo1<>000003.012<>f.php;3.16<>0x0<>{}<>{}<>{}<>{}PAF_FILE_SYMBOLS;f.php<>000003.003<>#<>foo1<>fu;3.21<>3.12<>3.16<>{}PAF_FUNC_DEF;foo2<>000005.012<>f.php;5.16<>0x0<>{}<>{}<>{}<>{}PAF_FILE_SYMBOLS;f.php<>000005.003<>#<>foo2<>fu;5.21<>5.12<>5.16<>{}}tcltest::test mode-2.4 { php mode } { browse [save_file f.php {<?phpfunction foo() {}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -