in reply to Re^3: Listing out the characters included in a character class [wide character warning]
in thread Listing out the characters included in a character class

Test::More is used widely. It's highly improbable it can cause any errors. Regarding the wide characters, maybe all you needed was Test::More::UTF8?

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re^4: Listing out the characters included in a character class [wide character warning]
  • Download Code

Replies are listed 'Best First'.
Re^5: Listing out the characters included in a character class [wide character warning]
by Polyglot (Chaplain) on Nov 04, 2023 at 11:59 UTC
    If the Test::More were already capable of handling UTF8 characters, why the need of Test::More::UTF8? And if, for a UTF8 application, the second option is to be used, why is this not made more prominent? I saw nothing about it in the documentation for Test::More, and it's hard to even know of its existence as advertised.

    In any case, it's nice to know that there was something better. At this point, I may just roll my own tests anyhow...we'll see. (I don't need anything overly complex to begin with.)

    Blessings,

    ~Polyglot~

Re^5: Listing out the characters included in a character class [wide character warning]
by Polyglot (Chaplain) on Nov 28, 2023 at 07:01 UTC
    Well, I finally got around to the troublesome matter of the testing script for the module, and found I was forced to use one of the tools for testing...so, Test::More::UTF8 it was.

    ...until it wasn't.

    Something is different in the coding for the UTF8, it appears, and the script failed to run. Rather than more hours trying to troubleshoot what is unfamiliar to me, I've abandoned the /t folder for testing and gone the other route of having my own test.pl script in the main folder for the module. In that I use "Test::Simple" for a few simple tests, then run my own tests. It seems to work okay, but I wish it were better.

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use 5.008;
    use utf8;
    use FindBin qw($Bin);
    use lib "$Bin/lib";
    use blib './lib/';
    use Regexp::CharClasses::Thai;
    use Regexp::CharClasses::Thai qw(:all);
    
    
    binmode STDOUT, ':utf8';
    
    use Test::Simple 'no_plan';
    
    my $failure = 0;
    
    #########################
    # TEST ITEMS
    
    ok( q"'ก' =~ /\p{IsThai}/" );
    ok( q"'ก' =~ /\p{InThaiCons}/" );
    ok( q"'ก' =~ /\p{InThaiMCons}/" );
    
    is( q"'ก' =~ /\p{IsKokai}/",1,' Match for  "ก" =~ /\p{IsKokai}/');
    is( q"'ก' =~ /\p{InThai}/",1,' Match for  "ก" =~ /\p{InThai}/');
    is( q"'ก' =~ /\p{InThaiAlpha}/",1,' Match for  "ก" =~ /\p{InThaiAlpha}/');
    is( q"'ก' =~ /\p{InThaiCons}/",1,' Match for  "ก" =~ /\p{InThaiCons}/');
    isnt( q"'ก' =~ /\p{InThaiHCons}/",0,' No match for  "ก" =~ /\p{InThaiHCons}/');
    is( q"'ก' =~ /\p{InThaiMCons}/",1,' Match for  "ก" =~ /\p{InThaiMCons}/');
    isnt( q"'ก' =~ /\p{InThaiLCons}/",0,' No match for  "ก" =~ /\p{InThaiLCons}/');
    isnt( q"'ก' =~ /\p{InThaiDigit}/",0,' No match for  "ก" =~ /\p{InThaiDigit}/');
    isnt( q"'ก' =~ /\p{InThaiTone}/",0,' No match for  "ก" =~ /\p{InThaiTone}/');
    isnt( q"'ก' =~ /\p{InThaiVowel}/",0,' No match for  "ก" =~ /\p{InThaiVowel}/');
    isnt( q"'ก' =~ /\p{InThaiCompVowel}/",0,' No match for  "ก" =~ /\p{InThaiCompVowel}/');
    isnt( q"'ก' =~ /\p{InThaiPreVowel}/",0,' No match for  "ก" =~ /\p{InThaiPreVowel}/');
    isnt( q"'ก' =~ /\p{InThaiPostVowel}/",0,' No match for  "ก" =~ /\p{InThaiPostVowel}/');
    isnt( q"'ก' =~ /\p{InThaiPunct}/",0,' No match for  "ก" =~ /\p{InThaiPunct}/');
    is( q"'ก' =~ /\p{InThaiFinCons}/",1,' Match for  "ก" =~ /\p{InThaiFinCons}/');
    isnt( q"'ก' =~ /\p{InThaiMute}/",0,' No match for  "ก" =~ /\p{InThaiMute}/');
     
    
    is( q"'ไ' =~ /\p{InThai}/",1,' Match for  "ไ" =~ /\p{InThai}/');
    is( q"'ไ' =~ /\p{InThaiAlpha}/",1,' Match for  "ไ" =~ /\p{InThaiAlpha}/');
    is( q"'ไ' =~ /\p{InThaiWord}/",1,' Match for  "ไ" =~ /\p{InThaiWord}/');
    isnt( q"'ไ' =~ /\p{InThaiCons}/",0,' No match for  "ไ" =~ /\p{InThaiCons}/');
    isnt( q"'ไ' =~ /\p{InThaiHCons}/",0,' No match for  "ไ" =~ /\p{InThaiHCons}/');
    isnt( q"'ไ' =~ /\p{InThaiMCons}/",0,' No match for  "ไ" =~ /\p{InThaiMCons}/');
    isnt( q"'ไ' =~ /\p{InThaiLCons}/",0,' No match for  "ไ" =~ /\p{InThaiLCons}/');
    isnt( q"'ไ' =~ /\p{InThaiDigit}/",0,' No match for  "ไ" =~ /\p{InThaiDigit}/');
    isnt( q"'ไ' =~ /\p{InThaiTone}/",0,' No match for  "ไ" =~ /\p{InThaiTone}/');
    is( q"'ไ' =~ /\p{InThaiVowel}/",1,' Match for  "ไ" =~ /\p{InThaiVowel}/');
    isnt( q"'ไ' =~ /\p{InThaiCompVowel}/",0,' No match for  "ไ" =~ /\p{InThaiCompVowel}/');
    is( q"'ไ' =~ /\p{InThaiPreVowel}/",1,' Match for  "ไ" =~ /\p{InThaiPreVowel}/');
    isnt( q"'ไ' =~ /\p{InThaiPostVowel}/",0,' No match for  "ไ" =~ /\p{InThaiPostVowel}/');
    isnt( q"'ไ' =~ /\p{InThaiPunct}/",0,' No match for  "ไ" =~ /\p{InThaiPunct}/');
    is( q"'ไ' =~ /\p{IsSaraaimaimalai}/",1,' Match for  "ไ" =~ /\p{IsSaraaimaimalai}/');
    
    
        my $pv = 'ข่าวนี้ได้แพร่สะพัดออกไปอย่างรวดเร็ว';
        my $prevowel_syllables = $pv  =~ s/
                (
                (?:\p{InThaiPreVowel})
                (?:
                  (?:\p{InThaiDualC1}\p{InThaiDualC2})
                  |
                  (?:\p{InThaiCons}){1}
                )
                (?:\p{InThaiTone}\p{InThaiCompVowel}\p{InThaiPostVowel}){0,3}
                  (?:
                    (?:\p{InThaiFinCons}\p{IsYoyak}\p{IsWowaen}){0,5}
                    (?!\p{InThaiPostVowel})
                  )*
                (?:\p{InThaiMute})?
                )           
                /($1)/gx;
    
        print "Syllables with pre-vowels in 'ข่าวนี้ได้แพร่สะพัดออกไปอย่างรวดเร็ว' --> $pv: $prevowel_syllables\n";  # 4
    
    if ($prevowel_syllables == 4) { print "Syllables test succeeded.\n\n" } else { print "Syllables test FAILED.\n\n"; $failure++};
    
    if ($failure) {
    	print "No success: $failure tests failed.\n";
    	exit $failure;
    } else {
    	print "Success.  All tests passed.\n";
    	exit 0;
    };
    
    exit;
    
    
    sub is {
    my $test = shift @_;
    my $val = shift @_;
    my $say = shift @_;
    	print "TEST: $say\t";
    	if ((eval($test)) == $val) {
    		print "Passed in the affirmative.\n" 
    	} else { 
    		print "FAILED! INCORRECTLY NEGATIVE.\n";
    		$failure++ 
    	};
    };
    
    sub isnt {
    my $test = shift @_;
    my $val = shift @_;
    my $say = shift @_;
    	print "TEST: $say\t";
    	if (eval($test) != $val) { 
    		print "FAILED! INCORRECTLY AFFIRMATIVE.\n";
    		$failure++ 
    	} else { 
    		print "Passed in the negative.\n" 
    	};
    };
    
    
    EDIT: Cleaned it up a bit and changed to "pre" tags, hoping for better readability.

    Maybe someday I'll figure out the Test::More::UTF8. Until then, this approach will hopefully at least get the module installed.

    Blessings,

    ~Polyglot~

      > the script failed to run

      What happened? What errors did you get?

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        It couldn't find the same functions as the script had been written with using the Test::More. I don't remember the exact message, but calling a non-existent function doesn't usually work. In this case, I think it was the "is" and "isnt" functions that are used for the tests. As soon as I realized it was not a drop-in replacement, I looked for other options.

        Blessings,

        ~Polyglot~