This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
APItest/t/utf8.t: Add missing test
authorKarl Williamson <khw@cpan.org>
Thu, 6 Oct 2016 00:34:15 +0000 (18:34 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 13 Oct 2016 17:18:12 +0000 (11:18 -0600)
Under some circumstances we weren't validating that the generated
warnings are correct.  This required reordering some 'if' tests, and
revised special casing of the overflow test.

ext/XS-APItest/t/utf8.t

index f104c5d..c6d78bf 100644 (file)
@@ -1921,20 +1921,10 @@ foreach my $test (@tests) {
                         diag $call;
                     }
 
-                    if (! $do_warning
-                        && ($warning eq 'utf8' || $warning eq $category))
-                    {
-                        if (!is(scalar @warnings, 0,
-                                            "$this_name: No warnings generated"))
-                        {
-                            diag $call;
-                            output_warnings(@warnings);
+                    if ($will_overflow) {
+                        if (! $do_warning && $warning eq 'utf8') {
+                            goto no_warnings_expected;
                         }
-                    }
-                    elsif ($will_overflow
-                           && ! $disallow_flag
-                           && $warning eq 'utf8')
-                    {
 
                         # Will get the overflow message instead of the expected
                         # message under these circumstances, as they would
@@ -1954,9 +1944,12 @@ foreach my $test (@tests) {
                             output_warnings(@warnings) if scalar @warnings;
                         }
                     }
-                    elsif ($warn_flag
+                    elsif (   ! $do_warning
                            && ($warning eq 'utf8' || $warning eq $category))
                     {
+                        goto no_warnings_expected;
+                    }
+                    elsif ($warn_flag) {
                         if (is(scalar @warnings, 1,
                                "$this_name: Got a single warning "))
                         {
@@ -1973,6 +1966,15 @@ foreach my $test (@tests) {
                             }
                         }
                     }
+                    else {
+                      no_warnings_expected:
+                        unless (is(scalar @warnings, 0,
+                                  "$this_name: Got no warnings"))
+                        {
+                            diag $call;
+                            output_warnings(@warnings);
+                        }
+                    }
 
                     # Check CHECK_ONLY results when the input is disallowed.  Do
                     # this when actually disallowed, not just when the