diff --git a/tests/Test_Cli.php b/tests/Test_Cli.php index 156a509..d5101a2 100644 --- a/tests/Test_Cli.php +++ b/tests/Test_Cli.php @@ -406,7 +406,6 @@ function test_decolorize() { } function test_strwidth() { - $this->markTestSkipped('Unknown failure'); // Save. $test_strwidth = getenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH' ); if ( function_exists( 'mb_detect_order' ) ) { @@ -446,12 +445,14 @@ function test_strwidth() { } // Nepali जस्ट ट॓स्ट गर्दै - 1st word: 3 spacing + 1 combining, 2nd word: 3 spacing + 2 combining, 3rd word: 3 spacing + 2 combining = 9 spacing chars + 2 spaces = 11 chars. + // Note: ICU's grapheme_strlen() treats Devanagari conjuncts (consonant + virama + consonant) as single graphemes. + // Modern ICU versions (54.1+) return 8 for this string, while PCRE \X returns 11. $str = "\xe0\xa4\x9c\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\x9f \xe0\xa4\x9f\xe0\xa5\x93\xe0\xa4\xb8\xe0\xa5\x8d\xe0\xa4\x9f \xe0\xa4\x97\xe0\xa4\xb0\xe0\xa5\x8d\xe0\xa4\xa6\xe0\xa5\x88"; putenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH' ); if ( \cli\can_use_icu() ) { - $this->assertSame( 11, \cli\strwidth( $str ) ); // Tests grapheme_strlen(). + $this->assertSame( 8, \cli\strwidth( $str ) ); // Tests grapheme_strlen() - ICU treats conjuncts as single graphemes. putenv( 'PHP_CLI_TOOLS_TEST_STRWIDTH=2' ); // Test preg_split( '/\X/u' ). $this->assertSame( 11, \cli\strwidth( $str ) ); } else {