From 8f424dd36b1783aac9966493fd5a25ccfd0af9ae Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Sat, 11 Nov 2023 13:53:35 +0100 Subject: [PATCH] Test that objects free handler call zend_weakrefs_notify (#12546) --- Zend/tests/weakrefs/notify.phpt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Zend/tests/weakrefs/notify.phpt diff --git a/Zend/tests/weakrefs/notify.phpt b/Zend/tests/weakrefs/notify.phpt new file mode 100644 index 00000000000..1390c7b435a --- /dev/null +++ b/Zend/tests/weakrefs/notify.phpt @@ -0,0 +1,31 @@ +--TEST-- +Object free handler must call zend_weakrefs_notify +--FILE-- +newInstanceWithoutConstructor(); + } catch (\Throwable $e) { + continue; + } + $testedClasses++; + $ref = WeakReference::create($instance); + $instance = null; + gc_collect_cycles(); + if ($ref->get() !== null) { + printf("free handler of %s did not call zend_weakrefs_notify?\n", $class); + } +} + +if ($testedClasses === 0) { + print "Did not test any class\n"; +} +?> +==DONE== +--EXPECT-- +==DONE==