-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Test equality of "compare" operations in compile phase and runtime #3885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I can't follow this test. It's quite important to be able to understand what a test is going to be testing without having to run the code. Please could you change the PR to be the generated code, with the code to regenerate it as a comment. |
@Danack |
@Danack I think this test can be merged as is. It basically ensures that compile time and runtime comparisons behave the same way - i.e. it makes it impossible to change behavior of compile time comparisons without also changing runtime comparisons. I.e. it generates code that checks whether the equality behavior of the input values in the big array respective to each other remains consistent with the operators. This test is not useful in its generated version: if we ever change any comparison or add an operator, we'll have massive overhead there. And the diff output will also exactly give you a sample of what's wrong. I'll cherry-pick it. |
Zend/tests/compare_equality_001.phpt
Outdated
$f = 0; | ||
|
||
function prepareLine($op1, $op2, $cmp, $type){ | ||
$cmp = (int) $cmp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why go through the int cast here and not makeParam() this as well?
Zend/tests/compare_equality_001.phpt
Outdated
return "\$c++;if ($cmp !== (int)($op1_p $type $op2_p)){echo \"$op1_p $type $op2_p\n\";\$f++;};\n"; | ||
} | ||
|
||
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'compare_equality_temp.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: __DIR__
Zend/tests/compare_equality_001.phpt
Outdated
$var_cnt = count($input); | ||
|
||
foreach($input as $var) { | ||
for ($i = 0; $i < $var_cnt; $i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach ($input as $var2)
?
@rjhdby Maybe add a small comment explaining that this test generates code to compare compile-time evaluation of comparisons with run-time evaluation? |
PS Sorry for answering by separate message. My browser is too old for github and I can't update it because of corporate rules |
As nikita said, a description section would really be a benefit for readers ... I too didn't understand the test, and once it's merged all context from github conversations is lost ... |
It seems this PR has been applied; if so, it should be closed. Anyhow, it would be nice to fix the failing test. |
I will in an hour - was busy until now |
Correctly fail on #3874
Expressions that are not computed on compile time is excluded (e.g. objects)