lzss_symbolic.t 907 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!perl -T
  2. use utf8;
  3. use 5.036;
  4. use Test::More;
  5. use Compression::Util qw(:all);
  6. plan tests => 2;
  7. foreach my $file (__FILE__) {
  8. my $str = do {
  9. local $/;
  10. open my $fh, '<:utf8', $file;
  11. <$fh>;
  12. };
  13. my $enc = lzss_compress_symbolic([map { ord($_) } $str =~ /(\X)/g]);
  14. my $dec = lzss_decompress_symbolic($enc);
  15. ok(length($enc) < length($str));
  16. is($str, join('', map { chr($_) } @$dec));
  17. }
  18. __END__
  19. # International class; name and street
  20. class 国際( なまえ, Straße ) {
  21. # Say who am I!
  22. method 言え {
  23. say "I am #{self.なまえ} from #{self.Straße}";
  24. }
  25. }
  26. # all the people of the world!
  27. var 民族 = [
  28. 国際( "高田 Friederich", "台湾" ),
  29. 国際( "Smith Σωκράτης", "Cantù" ),
  30. 国際( "Stanisław Lec", "południow" ),
  31. ];
  32. 民族.each { |garçon|
  33. garçon.言え;
  34. }