Skip to content

Commit 7e0390a

Browse files
committed
Remove TestMoreHelper workaround - use native last SKIP
Now that the control flow fix is merged (PR #121), we can remove the TestMoreHelper workaround that was transforming skip() calls at parse time. Changes: - Removed TestMoreHelper.java - Removed TestMoreHelper calls from StatementParser and StatementResolver - Updated Test::More.pm skip() to use 'last SKIP' directly - Removed skip_internal() from Test::More.pm exports - Cleaned up test.pl.patch to remove skip_internal workaround Results: - skip_control_flow.t: all 3 tests pass ✓ - Baseline maintained: 66683/66880 ✓
1 parent 97346c2 commit 7e0390a

File tree

5 files changed

+6
-102
lines changed

5 files changed

+6
-102
lines changed

dev/import-perl5/patches/test.pl.patch

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,17 @@
11
--- perl5/t/test.pl
22
+++ t/test.pl
3-
@@ -1,3 +1,10 @@
3+
@@ -1,3 +1,7 @@
44
+# --------------------------------------------
5-
+# Modified t/test.pl for running Perl test suite with PerlOnJava:
6-
+#
7-
+# - added subroutine `skip_internal` to workaround the use of non-local goto (`last SKIP`).
8-
+# - no other changes.
5+
+# Modified t/test.pl for running Perl test suite with PerlOnJava
96
+# --------------------------------------------
107
+
118
#
129
# t/test.pl - most of Test::More functionality without the fuss
1310

14-
@@ -587,16 +594,44 @@
11+
@@ -587,16 +591,16 @@
1512
last SKIP;
1613
}
1714

18-
+sub skip_internal {
19-
+ my $why = shift;
20-
+ my $n = @_ ? shift : 1;
21-
+ my $bad_swap;
22-
+ my $both_zero;
23-
+ {
24-
+ local $^W = 0;
25-
+ $bad_swap = $why > 0 && $n == 0;
26-
+ $both_zero = $why == 0 && $n == 0;
27-
+ }
28-
+ if ($bad_swap || $both_zero || @_) {
29-
+ my $arg = "'$why', '$n'";
30-
+ if (@_) {
31-
+ $arg .= join(", ", '', map { qq['$_'] } @_);
32-
+ }
33-
+ die qq[$0: expected skip(why, count), got skip($arg)\n];
34-
+ }
35-
+ for (1..$n) {
36-
+ _print "ok $test # skip $why\n";
37-
+ $test = $test + 1;
38-
+ }
39-
+ local $^W = 0;
40-
+ # last SKIP;
41-
+ 1;
42-
+}
43-
+
4415
sub skip_if_miniperl {
4516
- skip(@_) if is_miniperl();
4617
+ ## PerlOnJava is not miniperl

src/main/java/org/perlonjava/parser/StatementParser.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@ public static Node parseIfStatement(Parser parser) {
237237
elseBranch = parseIfStatement(parser);
238238
}
239239

240-
// Use a macro to emulate Test::More SKIP blocks
241-
TestMoreHelper.handleSkipTest(parser, thenBranch);
242-
243240
return new IfNode(operator.text, condition, thenBranch, elseBranch, parser.tokenIndex);
244241
}
245242

src/main/java/org/perlonjava/parser/StatementResolver.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,6 @@ yield dieWarnNode(parser, "die", new ListNode(List.of(
572572

573573
parser.ctx.symbolTable.exitScope(scopeIndex);
574574

575-
if (label != null && label.equals("SKIP")) {
576-
// Use a macro to emulate Test::More SKIP blocks
577-
TestMoreHelper.handleSkipTest(parser, block);
578-
}
579-
580575
yield new For3Node(label,
581576
true,
582577
null, null,

src/main/java/org/perlonjava/parser/TestMoreHelper.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

src/main/perl/lib/Test/More.pm

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ our @EXPORT = qw(
1616
pass fail diag note done_testing is_deeply subtest
1717
use_ok require_ok BAIL_OUT
1818
skip
19-
skip_internal
2019
eq_array eq_hash eq_set
2120
);
2221

@@ -286,21 +285,15 @@ sub BAIL_OUT {
286285
exit 255;
287286
}
288287

289-
sub skip {
290-
die "Test::More::skip() is not implemented";
291-
}
292-
293-
# Workaround to avoid non-local goto (last SKIP).
294-
# The skip_internal subroutine is called from a macro in TestMoreHelper.java
295-
#
296-
sub skip_internal {
288+
sub skip($;$) {
297289
my ($name, $count) = @_;
290+
$count ||= 1;
298291
for (1..$count) {
299292
$Test_Count++;
300293
my $result = "ok";
301294
print "$Test_Indent$result $Test_Count # skip $name\n";
302295
}
303-
return 1;
296+
last SKIP;
304297
}
305298

306299
# Legacy comparison functions - simple implementations using is_deeply

0 commit comments

Comments
 (0)