diff options
author | Ilija Tovilo <ilija.tovilo@me.com> | 2020-09-05 16:33:22 +0200 |
---|---|---|
committer | Ilija Tovilo <ilija.tovilo@me.com> | 2020-09-08 00:08:18 +0200 |
commit | 8a49310f4e1aae962aaecc8bfafaf39877167c52 (patch) | |
tree | 8409e5bf92a18f86b49d17eeaed881553ed7d151 /sapi/phpdbg/tests | |
parent | af0ba0b2d3641d3372aebbe471c4b194dc3f3440 (diff) | |
download | php-git-8a49310f4e1aae962aaecc8bfafaf39877167c52.tar.gz |
Adjust assignment line number for match
Otherwise the assignment will have the same number as the default arm
which will 1. mis-trigger a breakpoint and 2. mark the line as covered
even when it isn't.
Closes GH-6083
Diffstat (limited to 'sapi/phpdbg/tests')
-rw-r--r-- | sapi/phpdbg/tests/match_breakpoints_001.phpt | 30 | ||||
-rw-r--r-- | sapi/phpdbg/tests/match_breakpoints_002.phpt | 32 | ||||
-rw-r--r-- | sapi/phpdbg/tests/match_breakpoints_003.phpt | 32 | ||||
-rw-r--r-- | sapi/phpdbg/tests/match_breakpoints_004.phpt | 34 |
4 files changed, 128 insertions, 0 deletions
diff --git a/sapi/phpdbg/tests/match_breakpoints_001.phpt b/sapi/phpdbg/tests/match_breakpoints_001.phpt new file mode 100644 index 0000000000..9ef74179c1 --- /dev/null +++ b/sapi/phpdbg/tests/match_breakpoints_001.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test match default breakpoint with variable assignment +--INI-- +opcache.enable_cli=0 +--PHPDBG-- +b 5 +b 10 +r +q +--EXPECTF-- +[Successful compilation of %s.php] +prompt> [Breakpoint #0 added at %s.php:5] +prompt> [Breakpoint #1 added at %s.php:10] +prompt> [Breakpoint #1 at %s.php:10, hits: 1] +>00010: default => 'bar', // breakpoint #1 + 00011: }; + 00012: +prompt> +--FILE-- +<?php + +$foo = match (0) { + 0 => 'foo', + default => 'bar', // breakpoint #0 +}; + +$foo = match (1) { + 0 => 'foo', + default => 'bar', // breakpoint #1 +}; diff --git a/sapi/phpdbg/tests/match_breakpoints_002.phpt b/sapi/phpdbg/tests/match_breakpoints_002.phpt new file mode 100644 index 0000000000..21b0b4ef3a --- /dev/null +++ b/sapi/phpdbg/tests/match_breakpoints_002.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test match default breakpoint with property assignment +--INI-- +opcache.enable_cli=0 +--PHPDBG-- +b 7 +b 12 +r +q +--EXPECTF-- +[Successful compilation of %s.php] +prompt> [Breakpoint #0 added at %s.php:7] +prompt> [Breakpoint #1 added at %s.php:12] +prompt> [Breakpoint #1 at %s.php:12, hits: 1] +>00012: default => 'bar', // breakpoint #1 + 00013: }; + 00014: +prompt> +--FILE-- +<?php + +$foo = new stdClass(); + +$foo->bar = match (0) { + 0 => 'foo', + default => 'bar', // breakpoint #0 +}; + +$foo->bar = match (1) { + 0 => 'foo', + default => 'bar', // breakpoint #1 +}; diff --git a/sapi/phpdbg/tests/match_breakpoints_003.phpt b/sapi/phpdbg/tests/match_breakpoints_003.phpt new file mode 100644 index 0000000000..dbd7eb70ab --- /dev/null +++ b/sapi/phpdbg/tests/match_breakpoints_003.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test match default breakpoint with dim assignment +--INI-- +opcache.enable_cli=0 +--PHPDBG-- +b 7 +b 12 +r +q +--EXPECTF-- +[Successful compilation of %s.php] +prompt> [Breakpoint #0 added at %s.php:7] +prompt> [Breakpoint #1 added at %s.php:12] +prompt> [Breakpoint #1 at %s.php:12, hits: 1] +>00012: default => 'bar', // breakpoint #1 + 00013: }; + 00014: +prompt> +--FILE-- +<?php + +$foo = []; + +$foo['foo'] = match (0) { + 0 => 'foo', + default => 'bar', // breakpoint #0 +}; + +$foo->bar = match (1) { + 0 => 'foo', + default => 'bar', // breakpoint #1 +}; diff --git a/sapi/phpdbg/tests/match_breakpoints_004.phpt b/sapi/phpdbg/tests/match_breakpoints_004.phpt new file mode 100644 index 0000000000..d59555e692 --- /dev/null +++ b/sapi/phpdbg/tests/match_breakpoints_004.phpt @@ -0,0 +1,34 @@ +--TEST-- +Test match default breakpoint with static variable assignment +--INI-- +opcache.enable_cli=0 +--PHPDBG-- +b 9 +b 14 +r +q +--EXPECTF-- +[Successful compilation of %s.php] +prompt> [Breakpoint #0 added at %s.php:9] +prompt> [Breakpoint #1 added at %s.php:14] +prompt> [Breakpoint #1 at %s.php:14, hits: 1] +>00014: default => 'bar', // breakpoint #1 + 00015: }; + 00016: +prompt> +--FILE-- +<?php + +class Foo { + public static $bar; +} + +Foo::$bar = match (0) { + 0 => 'foo', + default => 'bar', // breakpoint #0 +}; + +Foo::$bar = match (1) { + 0 => 'foo', + default => 'bar', // breakpoint #1 +}; |