-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Request 29463 assert() user message #150
Conversation
please merge them into one commit. it will be easier for us to see what exactly you have committed. |
I've updated the branch to be 1 commit. Thank you! On Mon, Aug 6, 2012 at 3:00 AM, Xinchen Hui <
Lonny Kapelushnik |
Added 2nd, optional, param to assert. When passed in it will be added to the printed warnings and passed as a 4th param to a callback
I apologize. I had some extra files I accidentally committed earlier. I've removed them and recommitted the correct files in 1 commit. |
Checks if assertion is false */ | ||
PHP_FUNCTION(assert) | ||
{ | ||
zval **assertion; | ||
int val; | ||
int val, descriptionlen = 0; |
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.
should be description_len
This is quite cool, as it enables testing framework authors to use assert() as a base for assertions. |
@@ -28,7 +28,7 @@ var_dump($rao=assert_options("F1","f1")); | |||
|
|||
//Wrong number of parameters for assert() | |||
$sa="0 != 0"; | |||
var_dump($r2=assert($sa,1)); | |||
var_dump($r2=assert($sa,"message",1)); |
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.
Another spacing issue.
Thank you, we’re getting closer. See my other remarks. |
Lars, Thanks for reviewing this. The spacing issue was b/c I was using two different editors. This is now fixed. Also, you were correct that variable length arrays are not C89. I switched it to use safe_emalloc instead. |
@@ -196,7 +200,7 @@ static void php_assert_init_globals(zend_assert_globals *assert_globals_p TSRMLS | |||
} | |||
|
|||
if (ASSERTG(callback)) { | |||
zval *args[3]; | |||
zval **args = safe_emalloc( description_len == 0 ? 3 : 4, sizeof(zval **), 0); |
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.
The leading space before description_len is wrong here
Thanks. I will test the patch locally this weekend. I'll keep you updated. |
Comment on behalf of lstrojny at php.net: Thanks for your contribution. The patch has been merged into 5.4 and master. |
Added 2nd, optional, param to assert. When passed in it will be added to the printed warnings and passed as a 4th param to a callback