diff options
Diffstat (limited to 'ext/opcache/tests')
| -rw-r--r-- | ext/opcache/tests/bug71843.phpt | 25 | ||||
| -rw-r--r-- | ext/opcache/tests/bug72014.phpt | 29 | ||||
| -rw-r--r-- | ext/opcache/tests/issue0140.phpt | 1 | ||||
| -rw-r--r-- | ext/opcache/tests/ssa_bug_002.phpt | 16 | ||||
| -rw-r--r-- | ext/opcache/tests/ssa_bug_003.phpt | 38 | ||||
| -rw-r--r-- | ext/opcache/tests/ssa_bug_004.phpt | 19 | ||||
| -rw-r--r-- | ext/opcache/tests/ssa_bug_005.phpt | 24 |
7 files changed, 152 insertions, 0 deletions
diff --git a/ext/opcache/tests/bug71843.phpt b/ext/opcache/tests/bug71843.phpt new file mode 100644 index 0000000000..73301a6e96 --- /dev/null +++ b/ext/opcache/tests/bug71843.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #71843 (null ptr deref ZEND_RETURN_SPEC_CONST_HANDLER (zend_vm_execute.h:3479)) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=0xFFFFBFFF +--SKIPIF-- +<?php if (!extension_loaded('Zend OPcache')) die("skip"); ?> +--FILE-- +<?php +0 & ~E & ~R; +6 && ~See +?> +okey +--EXPECTF-- +Notice: Use of undefined constant E - assumed 'E' in %sbug71843.php on line %d + +Warning: A non-numeric value encountered in %s on line %d + +Notice: Use of undefined constant R - assumed 'R' in %sbug71843.php on line %d + +Warning: A non-numeric value encountered in %s on line %d + +Notice: Use of undefined constant See - assumed 'See' in %sbug71843.php on line %d +okey diff --git a/ext/opcache/tests/bug72014.phpt b/ext/opcache/tests/bug72014.phpt new file mode 100644 index 0000000000..d2ad96c0f1 --- /dev/null +++ b/ext/opcache/tests/bug72014.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #72014 (Including a file with anonymous classes multiple times leads to fatal error) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +file_put_contents(__DIR__ . "/bug72014.annon.php", <<<PHP +<?php +\$a = new class() { public \$testvar = "Foo\n"; }; +echo \$a->testvar; +PHP +); + +include(__DIR__ . "/bug72014.annon.php"); +include(__DIR__ . "/bug72014.annon.php"); +include(__DIR__ . "/bug72014.annon.php"); +?> +--CLEAN-- +<?php +@unlink(__DIR__ . "/bug72014.annon.php") +?> +--EXPECT-- +Foo +Foo +Foo diff --git a/ext/opcache/tests/issue0140.phpt b/ext/opcache/tests/issue0140.phpt index 98e0e45cc2..97fc11b3c7 100644 --- a/ext/opcache/tests/issue0140.phpt +++ b/ext/opcache/tests/issue0140.phpt @@ -8,6 +8,7 @@ opcache.file_update_protection=0 --SKIPIF-- <?php require_once('skipif.inc'); ?> <?php if (php_sapi_name() != "cli") die("skip CLI only"); ?> +<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow tests excluded by request") ?> --FILE-- <?php define("FILENAME", dirname(__FILE__) . "/issuer0140.inc.php"); diff --git a/ext/opcache/tests/ssa_bug_002.phpt b/ext/opcache/tests/ssa_bug_002.phpt new file mode 100644 index 0000000000..9ff6f799f4 --- /dev/null +++ b/ext/opcache/tests/ssa_bug_002.phpt @@ -0,0 +1,16 @@ +--TEST-- +Incorrect NOP removal on jump to NOP +--FILE-- +<?php + +function test(int $i) : int { + if ($i == 1) { + $x = $i + 1; + } + return $i; +} +var_dump(test(42)); + +?> +--EXPECT-- +int(42) diff --git a/ext/opcache/tests/ssa_bug_003.phpt b/ext/opcache/tests/ssa_bug_003.phpt new file mode 100644 index 0000000000..2895551c08 --- /dev/null +++ b/ext/opcache/tests/ssa_bug_003.phpt @@ -0,0 +1,38 @@ +--TEST-- +Incorrect elision of return type checks +--FILE-- +<?php + +function test1($x) : callable { + if ($x == 1) { + $c = 'foo'; + } elseif ($x == 2) { + $c = new stdClass; + } else { + $c = [$x => &$x]; + } + return $c; +} + +try { + test1(1); +} catch (Error $e) { + echo "Error: {$e->getMessage()}\n"; +} + +class Foo {} +function test2() : Foo { + $obj = new stdClass; + return $obj; +} + +try { + test2(); +} catch (Error $e) { + echo "Error: {$e->getMessage()}\n"; +} + +?> +--EXPECT-- +Error: Return value of test1() must be callable, string returned +Error: Return value of test2() must be an instance of Foo, instance of stdClass returned diff --git a/ext/opcache/tests/ssa_bug_004.phpt b/ext/opcache/tests/ssa_bug_004.phpt new file mode 100644 index 0000000000..20e313045a --- /dev/null +++ b/ext/opcache/tests/ssa_bug_004.phpt @@ -0,0 +1,19 @@ +--TEST-- +Assign elision exception safety: ICALL +--FILE-- +<?php + +set_error_handler(function() { throw new Exception; }); + +function test() { + $x = str_replace(['foo'], [[]], ['foo']); +} +try { + test(); +} catch (Exception $e) { + echo "caught\n"; +} + +?> +--EXPECT-- +caught diff --git a/ext/opcache/tests/ssa_bug_005.phpt b/ext/opcache/tests/ssa_bug_005.phpt new file mode 100644 index 0000000000..fb373e36b3 --- /dev/null +++ b/ext/opcache/tests/ssa_bug_005.phpt @@ -0,0 +1,24 @@ +--TEST-- +Assign elision exception safety: UCALL +--FILE-- +<?php + +function test() { + $dtor = new class { function __destruct() { throw new Exception; } }; + $a = 1; + return [0, $a]; +} + +function test2() { + $x = test(); +} + +try { + test2(); +} catch (Exception $e) { + echo "caught\n"; +} + +?> +--EXPECT-- +caught |
