atoomic / perl

a repo to show what could be p7
Other
18 stars 8 forks source link

t/op/each.t: Ensure test numbers print properly #340

Closed jkeenan closed 3 years ago

jkeenan commented 3 years ago

In Perl 5, test.pl's next_test() is called 3 times within this file in order to make use of test numbers in 'print' statements. The return values of these 3 sub calls were stored in global variable @tests, then subsequently accessed via code like '$::tests[0]'.

When preparing this file to run under strict-by-default, variable '@tests' was lexically scoped with 'my'. But subsequent code was still calling elements of @main::tests, even though this array had not yet been assigned to. As a result, the line number was not appearing in the test description.

    ok 15 - keys (%hash)
    ok
    ok  # DESTROY called
    ok
    ok 19 - Check length of "\x{1234}"

This patch corrects the scoping.

    ok 15 - keys (%hash)
    ok 16
    ok 17 # DESTROY called
    ok 18
    ok 19 - Check length of "\x{1234}"

Branches forked from alpha after alpha-dev-02-strict was merged in (e.g., alpha-dev-03-warnings and branches forked therefrom) will have to be rebased on alpha once this branch is merged thereto.

jkeenan commented 3 years ago

This was merged to alpha in commit a47e6077476125040edd2c737f0e87e9aec1a559.