Skip to content

Commit

Permalink
fix Test::More
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Oct 21, 2024
1 parent a1fb1f3 commit 276f731
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions FEATURE_MATRIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,14 @@ Here’s an alternative approach using the Exporter module:
Here’s an alternative approach using the Symbol module:

```perl
use Symbol 'qualify_to_ref';
use Symbol;

sub import {
my $pkg = shift;
my $callpkg = caller(0);

# Dynamically assign the Dumper function to the caller's namespace
my $sym_ref = qualify_to_ref('Dumper', $callpkg);
my $sym_ref = Symbol::qualify_to_ref('Dumper', $callpkg);
*$sym_ref = \&Dumper;

return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/perlonjava/runtime/RuntimeScalar.java
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ public RuntimeScalar createReference() {
// Return a reference to the subroutine with this name: \&$a
public RuntimeScalar createCodeReference(String packageName) {
String name = NameNormalizer.normalizeVariableName(this.toString(), packageName);
System.out.println("Creating code reference: " + name + " got: " + GlobalContext.getGlobalCodeRef(name));
// System.out.println("Creating code reference: " + name + " got: " + GlobalContext.getGlobalCodeRef(name));
return GlobalContext.getGlobalCodeRef(name);
}

Expand Down
23 changes: 13 additions & 10 deletions src/main/perl/lib/Test/More.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package Test::More;

use strict;
use warnings;
use Exporter 'import';
# use Exporter 'import';
use Symbol 'qualify_to_ref';

our @EXPORT = qw(
Expand All @@ -14,15 +14,18 @@ my $Test_Count = 0;
my $Plan_Count;
my $Failed_Count = 0;

# sub import {
# my $package = shift;
# my $caller = caller;
#
# for my $symbol (@EXPORT) {
# my $full_name = qualify_to_ref($symbol, $caller);
# *$full_name = \&{$symbol};
# }
# }
sub import {
my $package = shift;
my $caller = caller;
if (@_) {
plan(@_);
}

for my $symbol (@EXPORT) {
my $full_name = Symbol::qualify_to_ref($symbol, $caller);
*$full_name = \&{$symbol};
}
}

sub plan {
my ($directive, $arg) = @_;
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/regex_named_capture.pl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;
use Test::More tests => 4;

# Test case 1: Simple named capture
my $string1 = 'foo';
Expand Down

0 comments on commit 276f731

Please sign in to comment.