This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest/t/utf8.t: Fix some convoluted code
authorKarl Williamson <khw@cpan.org>
Sun, 14 May 2017 04:50:26 +0000 (22:50 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 13 Jul 2017 03:14:24 +0000 (21:14 -0600)
This code got overly complex as time went by, and can be cleaned up.

ext/XS-APItest/t/utf8.t

index dacb2ee..d932790 100644 (file)
@@ -945,41 +945,22 @@ for my $restriction (sort keys %restriction_types) {
                             }
                         }
                         else {
-                            $test_name_suffix
-                                        = " if contains forbidden code points";
-                            if ($this_error_type eq "c9strict") {
-                                $bytes = $restriction_types{""}{'valid_strings'};
-                                $expected_offset
-                                 = $restriction_types{"c9strict"}
-                                                     {'first_invalid_offset'};
-                                $expected_count
-                                  = $restriction_types{"c9strict"}
-                                                      {'first_invalid_count'};
-                            }
-                            elsif ($this_error_type eq "strict") {
-                                $bytes = $restriction_types{""}{'valid_strings'};
-                                $expected_offset
-                                  = $restriction_types{"strict"}
-                                                      {'first_invalid_offset'};
-                                $expected_count
-                                  = $restriction_types{"strict"}
-                                                      {'first_invalid_count'};
 
-                            }
-                            elsif ($this_error_type eq "fits_in_31_bits") {
-                                $bytes = $restriction_types{""}{'valid_strings'};
-                                $expected_offset
-                                  = $restriction_types{"fits_in_31_bits"}
-                                                      {'first_invalid_offset'};
-                                $expected_count
-                                    = $restriction_types{"fits_in_31_bits"}
-                                                        {'first_invalid_count'};
-                            }
-                            else {
+                            if (! exists $restriction_types{$this_error_type}) {
                                 fail("Internal test error: Unknown error type "
                                 . "'$this_error_type'");
                                 next;
                             }
+                            $test_name_suffix
+                                        = " if contains forbidden code points";
+
+                            $bytes = $restriction_types{""}{'valid_strings'};
+                            $expected_offset
+                                 = $restriction_types{$this_error_type}
+                                                     {'first_invalid_offset'};
+                            $expected_count
+                                  = $restriction_types{$this_error_type }
+                                                      {'first_invalid_count'};
                         }
                     }