File tree Expand file tree Collapse file tree
packages/phpunit/src/TestIdentifier Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import type { TestResultCache } from '../TestOutput/TestResultCache';
33
44export { PestV1Fixer } from './PestV1Fixer' ;
55export { PestV2Fixer } from './PestV2Fixer' ;
6- export { AliasMap , PestV3Fixer } from './PestV3Fixer' ;
6+ export { AliasMap } from './PestV3Fixer' ;
77
88export const PestFixer = {
99 fixNoTestStarted ( cache : TestResultCache , testResult : TestFailed | TestIgnored ) {
Original file line number Diff line number Diff line change @@ -5,23 +5,10 @@ function hasPrefix(id?: string) {
55}
66
77function decodeDescribePart ( inner : string ) : string {
8- const segments : string [ ] = [ ] ;
9- let current = '' ;
10- let i = 0 ;
11- while ( i < inner . length ) {
12- if ( inner [ i ] === '_' && inner [ i + 1 ] === '_' ) {
13- current += '_' ;
14- i += 2 ;
15- } else if ( inner [ i ] === '_' ) {
16- segments . push ( current ) ;
17- current = '' ;
18- i ++ ;
19- } else {
20- current += inner [ i ] ;
21- i ++ ;
22- }
23- }
24- segments . push ( current ) ;
8+ const segments = inner
9+ . replace ( / _ _ / g, '\0' )
10+ . split ( '_' )
11+ . map ( ( s ) => s . replace ( / \0 / g, '_' ) ) ;
2512 const isFQN = segments . every ( ( p ) => / ^ [ A - Z ] / . test ( p ) ) ;
2613 return `\`${ segments . join ( isFQN ? '\\' : ' ' ) } \`` ;
2714}
@@ -36,8 +23,10 @@ function decodeEvaluable(encoded: string): string {
3623 const methodFull = encoded . slice ( prefixIdx + PREFIX . length ) ;
3724
3825 const datasetIdx = methodFull . search ( / \s + w i t h \s + d a t a \s + s e t \s + / ) ;
39- const methodPart = datasetIdx >= 0 ? methodFull . slice ( 0 , datasetIdx ) : methodFull ;
40- const datasetSuffix = datasetIdx >= 0 ? methodFull . slice ( datasetIdx ) : '' ;
26+ const [ methodPart , datasetSuffix ] =
27+ datasetIdx >= 0
28+ ? [ methodFull . slice ( 0 , datasetIdx ) , methodFull . slice ( datasetIdx ) ]
29+ : [ methodFull , '' ] ;
4130
4231 const segments = methodPart . split ( '_\u2192_' ) ;
4332 if ( segments . length < 2 ) {
Original file line number Diff line number Diff line change 11// Pest v3 bug: Str::beforeLast uses mb_strrpos (char offset) with substr (byte offset).
22// The → character (U+2192) is 3 UTF-8 bytes but 1 char, so names are truncated
33// by 2 bytes per → character.
4- export const PestV3Fixer = {
5- truncatedId ( id : string ) : string | undefined {
6- const count = ( id . match ( / \u2192 / g) ?? [ ] ) . length ;
7- if ( count === 0 ) {
8- return undefined ;
9- }
4+ function truncatedId ( id : string ) : string | undefined {
5+ const count = ( id . match ( / \u2192 / g) ?? [ ] ) . length ;
6+ if ( count === 0 ) {
7+ return undefined ;
8+ }
109
11- return id . slice ( 0 , - count * 2 ) ;
12- } ,
13- } ;
10+ return id . slice ( 0 , - count * 2 ) ;
11+ }
1412
1513export class AliasMap < T > extends Map < string , T > {
1614 override set ( id : string , item : T ) : this {
1715 super . set ( id , item ) ;
18- const truncated = PestV3Fixer . truncatedId ( id ) ;
16+ const truncated = truncatedId ( id ) ;
1917 if ( truncated ) {
2018 super . set ( truncated , item ) ;
2119 }
You can’t perform that action at this time.
0 commit comments