Re: RE: RFC: expectations/assertions

From: Date: Wed, 05 Feb 2014 07:17:35 +0000
Subject: Re: RE: RFC: expectations/assertions
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-72244@lists.php.net to get a copy of this message
Hi! >> php > assert('function() {return FALSE;}'); >> php > assert('function() {return TRUE;}'); This runs function() code, which produces a closure. The closure is not false, so assert is not fired. >> php > assert(eval('function() {return FALSE;};')); The eval here returns NULL (http://3v4l.org/cPpgj) so of course assert will be fired here. From eval's manual: eval() returns NULL unless return is called in the evaluated code, in which case the value passed to return is returned. Compare: http://3v4l.org/vhe1p http://3v4l.org/B79r3 >> Warning: assert(): Assertion failed in php shell code on line 1 >> >> so closure in eval() works. I don't see reason not to allow closure Did you try: assert(eval('function() {return TRUE;};')); Testing hypothesis usually involves not only testing something that confirms it, but also something that may refute it. Otherwise you're not really testing, you are just convincing yourself. > Added this to inconsistent behaviors RFC to track. > > https://wiki.php.net/rfc/inconsistent-behaviors#assert There's no inconsistent behaviors here and IMHO this RFC is turning into "things people misunderstand in PHP". Maybe it should be moved to a blog or some other space, because it by now has very little to do with what RFCs are for. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#72244) next »