@@ -10,26 +10,51 @@ public function invoke($test) {
10
10
if (!isset ($ test ->contentModelFlags )) {
11
11
$ test ->contentModelFlags =array ('PCDATA ' );
12
12
}
13
- foreach ($ test ->contentModelFlags as $ flag ) {
14
- $ result =$ this ->tokenize ($ test ,$ flag );
15
- $ expect =array ();
16
- $ last =null ;
17
- foreach ($ test ->output as $ tok ) {
13
+ if (!isset ($ test ->ignoreErrorOrder )) {
14
+ $ test ->ignoreErrorOrder =false ;
15
+ }
16
+
17
+ // Get expected result array (and maybe error count).
18
+ $ expect =array ();
19
+ $ expectedErrorCount =0 ;// This is only used when ignoreErrorOrder = true.
20
+ foreach ($ test ->output as $ tok ) {
21
+ // If we're ignoring error order and this is a parse error, just count.
22
+ if ($ test ->ignoreErrorOrder &&$ tok ==='ParseError ' ) {
23
+ $ expectedErrorCount ++;
24
+ }else {
18
25
// Normalize character tokens from the test
19
- if ($ tok [0 ] ==='Character ' &&$ last [0 ] ==='Character ' ) {
20
- $ last [1 ] .=$ tok [1 ];
21
- continue ;
26
+ if ($ expect &&$ tok [0 ] ==='Character ' &&$ expect [count ($ expect ) -1 ][0 ] ==='Character ' ) {
27
+ $ expect [count ($ expect ) -1 ][1 ] .=$ tok [1 ];
28
+ }else {
29
+ $ expect [] =$ tok ;
30
+ }
31
+ }
32
+ }
33
+
34
+ // Run test for each content model flag.
35
+ foreach ($ test ->contentModelFlags as $ flag ) {
36
+ $ output =$ this ->tokenize ($ test ,$ flag );
37
+ $ result =array ();
38
+ $ resultErrorCount =0 ;// This is only used when ignoreErrorOrder = true.
39
+ foreach ($ outputas $ tok ) {
40
+ // If we're ignoring error order and this is a parse error, just count.
41
+ if ($ test ->ignoreErrorOrder &&$ tok ==='ParseError ' ) {
42
+ $ resultErrorCount ++;
43
+ }else {
44
+ $ result [] =$ tok ;
22
45
}
23
- // XXX we should also normalize our results... somewhere
24
- // (probably not here)
25
- $ expect [] =$ tok ;
26
- $ last =&$ expect [count ($ expect ) -1 ];
27
46
}
28
47
$ this ->assertIdentical ($ expect ,$ result ,
29
48
'In test " ' .str_replace ('% ' ,'%% ' ,$ test ->description ).
30
49
'" with content model ' .$ flag .': %s '
31
50
);
32
- if ($ expect !=$ result ) {
51
+ if ($ test ->ignoreErrorOrder ) {
52
+ $ this ->assertIdentical ($ expectedErrorCount ,$ resultErrorCount ,
53
+ 'Wrong error count in test " ' .str_replace ('% ' ,'%% ' ,$ test ->description ).
54
+ '" with content model ' .$ flag .': %s '
55
+ );
56
+ }
57
+ if ($ expect !=$ result || ($ test ->ignoreErrorOrder &&$ expectedErrorCount !==$ resultErrorCount )) {
33
58
echo "Input: " ;str_dump ($ test ->input );
34
59
echo "\nExpected: \n" ;echo $ this ->tokenDump ($ expect );
35
60
echo "\nActual: \n" ;echo $ this ->tokenDump ($ result );