Skip to content

Commit

Permalink
GH-21 - Add support for class keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
hkoba committed Feb 12, 2025
1 parent 858c649 commit 7df21cb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/App/perlminlint/Plugin/LintPM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ sub find_module {
local $_ = $plugin->app->read_file($fn, '');

while (/(?:^|\n) [\ \t]* (?# line beginning + space)
package [\n\ \t]+ (?# newline is allowed here)
(?:package|class) [\n\ \t]+ (?# newline is allowed here)
([\w:]+) (?# module name)
\s* [;\{] (?# statement or block)
/xsg) {
Expand Down
8 changes: 8 additions & 0 deletions t/in/8.d/lib/Foo.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use v5.38;
use experimental 'class';
class
Foo;

use Foo::Bar;

1;
5 changes: 5 additions & 0 deletions t/in/8.d/lib/Foo/Bar.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use v5.38;
use experimental 'class';
class
Foo::Bar;
1;
15 changes: 15 additions & 0 deletions t/lint.t
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ my $inputdir = $bindir . "in";
is_deeply [$out, $?], ["Module Foo is OK\n", 0], $fn;
}

{
my $test = "$inputdir/8";
my $fn = "$test.d/lib/Foo.pm";
my $want = "$fn syntax OK\n";
my $out = qx($^X $script $fn 2>&1);
is_deeply [$out, $?], ["Module Foo is OK\n", 0], $fn;
}

{
my $test = "$inputdir/8";
my $fn = "$test.d/lib/Foo/Bar.pm";
my $want = "$fn syntax OK\n";
my $out = qx($^X $script $fn 2>&1);
is_deeply [$out, $?], ["Module Foo::Bar is OK\n", 0], $fn;
}

done_testing();

Expand Down

0 comments on commit 7df21cb

Please sign in to comment.