Skip to content

Commit 5305eb1

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 b99f8d4 commit 5305eb1

11 files changed

Lines changed: 1585 additions & 208 deletions

File tree

dev/import-perl5/config.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ imports:
6262
type: directory
6363

6464
# Specific patched files (applied after directory import above)
65-
- source: perl5/t/test.pl
66-
target: perl5_t/t/test.pl
67-
patch: test.pl.patch
68-
6965
- source: perl5/t/re/pat.t
7066
target: perl5_t/t/re/pat.t
7167
patch: pat.t.patch

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

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

src/main/java/org/perlonjava/codegen/EmitSubroutine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ static void handleApplyOperator(EmitterVisitor emitterVisitor, BinaryOperatorNod
287287
codeRefSlot = emitterVisitor.ctx.symbolTable.allocateLocalVariable();
288288
}
289289
mv.visitVarInsn(Opcodes.ASTORE, codeRefSlot);
290+
emitterVisitor.ctx.javaClassInfo.decrementStackLevel(1);
290291

291292
int nameSlot = emitterVisitor.ctx.javaClassInfo.acquireSpillSlot();
292293
boolean pooledName = nameSlot >= 0;
@@ -326,6 +327,7 @@ static void handleApplyOperator(EmitterVisitor emitterVisitor, BinaryOperatorNod
326327

327328
paramList.elements.get(index).accept(listVisitor);
328329
mv.visitVarInsn(Opcodes.ASTORE, argSlot);
330+
emitterVisitor.ctx.javaClassInfo.decrementStackLevel(1);
329331

330332
mv.visitVarInsn(Opcodes.ALOAD, argsArraySlot);
331333
if (index <= 5) {

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

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

269-
// Use a macro to emulate Test::More SKIP blocks
270-
TestMoreHelper.handleSkipTest(parser, thenBranch);
271-
272269
return new IfNode(operator.text, condition, thenBranch, elseBranch, parser.tokenIndex);
273270
}
274271

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

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

571571
parser.ctx.symbolTable.exitScope(scopeIndex);
572572

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

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

Lines changed: 0 additions & 122 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)