Created
August 27, 2009 14:31
-
-
Save dtjohnso/176329 to your computer and use it in GitHub Desktop.
Test to see if missing parentheses can be detected by a simple arithmetic count algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Discussion @ http://andyanglea.com/blog/2009/08/if-problems | |
Error-free case: | |
12 1 23 4 3 2 3 4 3210 NO ERRORS | |
01 2 12 3 4 3 2 3 4321 NO ERRORS | |
if (($condition1 != $a) || ((len($condition2) == $b) && (!isset($_POST['submit'])))) { | |
Missing one ( case: | |
1* 0 12 3 2 1 2 3 210- ERROR DETECTED (ends with negative number) | |
1* 2 12 3 4 3 2 3 4321 ERROR DETECTED (ends with positive number) | |
if ( $condition1 != $a) || ((len($condition2) == $b) && (!isset($_POST['submit'])))) { | |
Missing one ) and one ( case: | |
12 * *3 4 3 2 3 4 3210 !UNDETECTABLE ERROR | |
01 * *2 3 4 3 2 3 4321 !UNDETECTABLE ERROR | |
if (($condition1 != $a || (len($condition2) == $b) && (!isset($_POST['submit'])))) { | |
Missing one ) and two ( case: | |
12 * ** 3 2 1 2 3 210- ERROR DETECTED (ends with negative number) | |
12 * ** 3 4 3 2 3 4321 ERROR DETECTED (ends with positive number) | |
if (($condition1 != $a || len($condition2) == $b) && (!isset($_POST['submit'])))) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment