Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions test/TestSupport/CompiledFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@
* `#[RunInSeparateProcess]` (or use `setUpBeforeClass` for an entire
* `TestCase` that shares one fixture across methods).
*
* Failure attribution: when a verify file calls `Assert::*` and it
* fails, the exception's throw site is the verify file (`path:line`),
* and the `require` frame is the calling `testFoo` method — PHPUnit
* Verify contract: a verify file `return`s a
* `function (CompiledFixture $fixture): void` that runs its `Assert::*`
* calls when invoked, so the fixture dependency is an explicit typed
* parameter rather than an implicit in-scope variable. The driver
* loads the closure with `require` and calls it with the fixture.
*
* Failure attribution: when a verify file's `Assert::*` fails, the
* exception's throw site is the verify file (`path:line`), and the
* closure-invocation frame is the calling `testFoo` method — PHPUnit
* reports both.
*
* Usage:
* $fixture = CompiledFixture::compile($sourceDir, 'array-sugar');
* $fixture->registerAutoload('App\\ArraySugar\\');
* try {
* require __DIR__ . '/../../fixture/compile/array_sugar/verify/foo.php';
* $runtime = require __DIR__ . '/../../fixture/compile/array_sugar/verify/foo.php';
* $runtime($fixture);
* } finally {
* $fixture->cleanup();
* }
Expand Down
6 changes: 4 additions & 2 deletions test/Transpiler/Monomorphize/ArraySugarIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public function testNullableReturnEnforcesConcreteType(): void
$fixture = CompiledFixture::compile($this->sourceDir, 'array-sugar-verify');
$fixture->registerAutoload('App\\ArraySugar\\');
try {
require __DIR__ . '/../../fixture/compile/array_sugar/verify/nullable_return.php';
$runtime = require __DIR__ . '/../../fixture/compile/array_sugar/verify/nullable_return.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -104,7 +105,8 @@ public function testSugarBeforeGenericClosureStillSpecializes(): void
?: throw new RuntimeException('Fixture missing');
$fixture = CompiledFixture::compile($source, 'array-sugar-marker-offset');
try {
require __DIR__ . '/../../fixture/compile/array_sugar_before_generic_closure/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/array_sugar_before_generic_closure/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
21 changes: 14 additions & 7 deletions test/Transpiler/Monomorphize/ArrowSpecializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public function testArrowSpecializationEndToEndSingleCapture(): void
'arrow-capture',
);
try {
require __DIR__ . '/../../fixture/compile/arrow_capture_at_declaration/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_capture_at_declaration/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -108,7 +109,8 @@ public function testArrowSpecializationEndToEndMultipleCaptures(): void
'arrow-multi',
);
try {
require __DIR__ . '/../../fixture/compile/arrow_multiple_captures/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_multiple_captures/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -122,7 +124,8 @@ public function testArrowSpecializationEndToEndNoCaptures(): void
'arrow-empty',
);
try {
require __DIR__ . '/../../fixture/compile/arrow_no_captures/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_no_captures/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -138,7 +141,8 @@ public function testArrowSpecializationCaptureShadowingParamName(): void
'arrow-shadow',
);
try {
require __DIR__ . '/../../fixture/compile/arrow_capture_shadowing/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_capture_shadowing/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -164,7 +168,8 @@ public function testArrowSpecializationMultipleArgTuples(): void
$out,
);

require __DIR__ . '/../../fixture/compile/arrow_multiple_arg_tuples/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_multiple_arg_tuples/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -218,7 +223,8 @@ public function testArrowSpecializationReservedArgsCaptureAlsoTriggersRename():
$out,
);

require __DIR__ . '/../../fixture/compile/arrow_reserved_args_capture/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_reserved_args_capture/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -250,7 +256,8 @@ public function testArrowSpecializationReservedCaptureAutoRenamesDispatcherParam
$out,
);

require __DIR__ . '/../../fixture/compile/arrow_reserved_tag_capture/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_reserved_tag_capture/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ public function testScalarAliasClassTypeArgumentsResolveAndRunAtRuntime(): void
);
try {
$fixture->registerAutoload('App');
require __DIR__ . '/../../fixture/compile/scalar_alias_class_resolves/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/scalar_alias_class_resolves/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ public function testSpecializedClassLoadsAndResolvesBuiltinsAtRuntime(): void
$fixture = CompiledFixture::compile($this->sourceDir, 'builtin-via-use-runtime');
$fixture->registerAutoload('App\\BuiltinViaUse\\');
try {
require __DIR__ . '/../../fixture/compile/builtin_interface_via_use/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/builtin_interface_via_use/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
12 changes: 8 additions & 4 deletions test/Transpiler/Monomorphize/ClosureArrowDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public function testClosureWithSingleDefaultUsesPadding(): void
'cdef-single',
);
try {
require __DIR__ . '/../../fixture/compile/closure_defaults_single/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_defaults_single/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -43,7 +44,8 @@ public function testArrowWithSingleDefaultUsesPadding(): void
'adef-single',
);
try {
require __DIR__ . '/../../fixture/compile/arrow_defaults_single/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_defaults_single/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -135,7 +137,8 @@ public function testDefaultOnClosureWithUseClause(): void
'cdef-use',
);
try {
require __DIR__ . '/../../fixture/compile/closure_defaults_with_use/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_defaults_with_use/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -150,7 +153,8 @@ public function testDefaultOnArrowWithImplicitCapture(): void
'adef-cap',
);
try {
require __DIR__ . '/../../fixture/compile/arrow_defaults_with_implicit_capture/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/arrow_defaults_with_implicit_capture/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
36 changes: 24 additions & 12 deletions test/Transpiler/Monomorphize/ClosureConformanceIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function testConformingClosuresCompileEraseAndRun(): void
'closure-conformance-run',
);
try {
require __DIR__ . '/../../fixture/compile/closure_conformance_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_conformance_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -43,7 +44,8 @@ public function testDnfGroupedSignaturesCompileEraseAndRun(): void
'closure-conformance-dnf',
);
try {
require __DIR__ . '/../../fixture/compile/closure_conformance_dnf_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_conformance_dnf_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -61,7 +63,8 @@ public function testUserFunctionNamedClosureInExpressionColonsExecutes(): void
'closure-named-user-fn',
);
try {
require __DIR__ . '/../../fixture/compile/closure_named_user_function_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_named_user_function_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -78,7 +81,8 @@ public function testArraySugarSignaturesCompileEraseAndRun(): void
'closure-conformance-sugar',
);
try {
require __DIR__ . '/../../fixture/compile/closure_conformance_array_sugar_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_conformance_array_sugar_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -96,7 +100,8 @@ public function testExceptionFactoryAgainstBuiltinThrowableTargetCompilesAndRuns
);
$fixture->registerAutoload('App\\ClosureBuiltinOk\\');
try {
require __DIR__ . '/../../fixture/compile/closure_conformance_builtin_ok/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_conformance_builtin_ok/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -124,7 +129,8 @@ public function testConformingClosureArgumentCompilesEraseAndRuns(): void
);
$fixture->registerAutoload('App\\ClosureArgRun\\');
try {
require __DIR__ . '/../../fixture/compile/closure_arg_instance_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_arg_instance_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -152,7 +158,8 @@ public function testConformingStaticClosureArgumentCompilesEraseAndRuns(): void
);
$fixture->registerAutoload('App\\ClosureArgStaticRun\\');
try {
require __DIR__ . '/../../fixture/compile/closure_arg_static_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_arg_static_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -180,7 +187,8 @@ public function testConformingFreeFunctionClosureArgumentCompilesEraseAndRuns():
);
$fixture->registerAutoload('App\\ClosureArgFnRun\\');
try {
require __DIR__ . '/../../fixture/compile/closure_arg_free_fn_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_arg_free_fn_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -208,7 +216,8 @@ public function testConformingPlainMethodClosureArgumentCompilesEraseAndRuns():
);
$fixture->registerAutoload('App\\PlainArgRun\\');
try {
require __DIR__ . '/../../fixture/compile/closure_arg_plain_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_arg_plain_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -236,7 +245,8 @@ public function testConformingPlainFreeFunctionClosureArgumentCompilesEraseAndRu
);
$fixture->registerAutoload('App\\PlainFnArgRun\\');
try {
require __DIR__ . '/../../fixture/compile/closure_arg_plain_fn_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_arg_plain_fn_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -265,7 +275,8 @@ public function testBucket3SelfCallClosureArgumentCompilesEraseAndRuns(): void
);
$fixture->registerAutoload('App\\Bucket3Run\\');
try {
require __DIR__ . '/../../fixture/compile/closure_arg_bucket3_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_arg_bucket3_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -295,7 +306,8 @@ public function testGroundedGenericClosureConformsWhenTypeParameterResolves(): v
);
$fixture->registerAutoload('App\\ClosureGroundRuntime\\');
try {
require __DIR__ . '/../../fixture/compile/closure_conformance_grounded_runtime/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_conformance_grounded_runtime/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ public function testRuntimeRoutingThroughDispatcher(): void
'disp-routing',
);
try {
require __DIR__ . '/../../fixture/compile/closure_dispatcher_runtime_routing/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_dispatcher_runtime_routing/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand All @@ -142,7 +143,8 @@ public function testUnknownTagAtRuntimeThrows(): void
'disp-unknown',
);
try {
require __DIR__ . '/../../fixture/compile/closure_dispatcher_unknown_tag/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_dispatcher_unknown_tag/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -291,7 +293,8 @@ public function testFirstClassCallableTurbofishClosureEmitsValidForwardingClosur
'fcc-closure',
);
try {
require __DIR__ . '/../../fixture/compile/turbofish_fcc_closure/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/turbofish_fcc_closure/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public function testBareNewSelfInNonDefaultsGenericBodyIsNotRejectedAndRuns(): v
);
try {
$fixture->registerAutoload('App\\BareNewSelfInGenericBody');
require __DIR__ . '/../../fixture/compile/bare_new_self_in_generic_body/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/bare_new_self_in_generic_body/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public function testArrowFixtureSynthesizesUseClauseFromImplicitCapture(): void
$out,
);

require __DIR__ . '/../../fixture/compile/closure_dispatcher_arrow/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_dispatcher_arrow/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -100,7 +101,8 @@ public function testUseClauseFixturePropagatesByRefThroughDispatcher(): void
preg_match_all('/function closure_f_T_[0-9a-f]+\(/', $out, $matches);
self::assertCount(2, $matches[0]);

require __DIR__ . '/../../fixture/compile/closure_dispatcher_use_clause/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_dispatcher_use_clause/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down Expand Up @@ -131,7 +133,8 @@ public function testDefaultsFixturePadsEmptyTurbofish(): void
preg_match_all('/function closure_f_T_[0-9a-f]+\(/', $out, $fMatches);
self::assertCount(2, $fMatches[0]);

require __DIR__ . '/../../fixture/compile/closure_dispatcher_defaults/verify/runtime.php';
$runtime = require __DIR__ . '/../../fixture/compile/closure_dispatcher_defaults/verify/runtime.php';
$runtime($fixture);
} finally {
$fixture->cleanup();
}
Expand Down
Loading
Loading