@@ -223,9 +223,24 @@ BEGIN {
223223 }
224224}
225225
226- our @EXPORT_OK = ( @vars , qw( builtins_tests describe test_constraint ) );
226+ our @EXPORT_OK = (
227+ @vars ,
228+ qw( builtins_tests create_BAR_handle_code describe test_constraint )
229+ );
227230our %EXPORT_TAGS = ( vars => \@vars );
228231
232+ sub create_BAR_handle_code {
233+
234+ # This used to be $^X, but that caused a test failure for someone
235+ # (https://github.com/houseabsolute/Specio/issues/25). Then I tried __FILE__, but that doesn't work
236+ # in cases where the file containing __FILE__ is eval'd, which we do in
237+ # `xt/author/no-ref-util.t`. So now I'm just grabbing the first file in %INC.
238+ return <<'EOF' ;
239+ my $file = $INC{ ( keys %INC )[0] };
240+ open BAR, '<', $file or die "Could not open $file for the test";
241+ EOF
242+ }
243+
229244sub builtins_tests {
230245 my $GLOB = shift ;
231246 my $GLOB_OVERLOAD = shift ;
@@ -1356,6 +1371,18 @@ You need to pass in a glob, an object which overloads globification, and an
13561371object which overloads globification to return an open filehandle. See below
13571372for more details on how to create these things.
13581373
1374+ =head2 create_BAR_handle_code()
1375+
1376+ Returns a string you can C<eval > to create a bar filehandle named C<BAR > . This should be used like
1377+ this:
1378+
1379+ local *BAR;
1380+ {
1381+ local $@;
1382+ eval create_BAR_handle_code();
1383+ die $@ if $@;
1384+ }
1385+
13591386=head2 Variables
13601387
13611388This module also exports many variables containing values which are useful for
@@ -1512,9 +1539,8 @@ You can create such a variable like this:
15121539 local *FOO;
15131540 my $GLOB_OVERLOAD = _T::GlobOverload->new( \*FOO );
15141541
1515- If you want to create a glob overloading object that returns a filehandle, do
1516- this:
1542+ If you want to create a glob overloading object that returns a filehandle, do this:
15171543
15181544 local *BAR;
1519- open BAR, '<', $^X or die "Could not open $^X for the test" ;
1545+ open BAR, '<', $some_file or die $! ;
15201546 my $GLOB_OVERLOAD_FH = _T::GlobOverload->new( \*BAR );
0 commit comments