assert

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

assert

Nathan Hüsken
Hey,

Is it somehow possible to write an assert into the haxe code?
So that the current stack is printed and the application aborted?

Thanks!
Nathan

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: assert

Nicolas Cannasse
Le 21/10/2011 12:44, Nathan Hüsken a écrit :
> Hey,
>
> Is it somehow possible to write an assert into the haxe code?
> So that the current stack is printed and the application aborted?

throw "assert" ?

Nicolas


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: assert

Nathan Hüsken
Yes, thank you!

On 10/21/2011 12:52 PM, Nicolas Cannasse wrote:

> Le 21/10/2011 12:44, Nathan Hüsken a écrit :
>> Hey,
>>
>> Is it somehow possible to write an assert into the haxe code?
>> So that the current stack is printed and the application aborted?
>
> throw "assert" ?
>
> Nicolas
>
>


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: assert

Russell Weir
If you happen to need something a little more robust,  I wrote a macro Assert class that compiles code in only in -debug mode, which has methods .isNotNull() .isTrue() .isFalse() and .isEqual()
 

If you are not using the chx classes, you will want to change what it throws by changing
the following lines to something
 
name : "FatalException",
pack : ["chx", "lang"],
to some class of your own. For example, to change Assert to throw flash.errors.Error
 
pack : ["flash", "errors"],
name : "Error",

 
 
On Fri, Oct 21, 2011 at 4:56 AM, Nathan Hüsken <[hidden email]> wrote:
Yes, thank you!

On 10/21/2011 12:52 PM, Nicolas Cannasse wrote:
> Le 21/10/2011 12:44, Nathan Hüsken a écrit :
>> Hey,
>>
>> Is it somehow possible to write an assert into the haxe code?
>> So that the current stack is printed and the application aborted?
>
> throw "assert" ?
>
> Nicolas
>
>


--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org