POV-Ray : Newsgroups : povray.off-topic : Unit Testing question : Re: Unit Testing question Server Time
30 Jul 2024 00:21:04 EDT (-0400)
  Re: Unit Testing question  
From: Darren New
Date: 10 Jun 2011 11:12:12
Message: <4df2344c$1@news.povray.org>
On 6/10/2011 8:05, Le_Forgeron wrote:
> Le 10/06/2011 16:45, Darren New a écrit :
>> On 6/10/2011 1:18, Le_Forgeron wrote:
>>> For instance, in Java, you can redefine the value of 3 and 6.
>>
>> Of all the languages out there, I'm pretty sure Java isn't one of thos
e.
>> :-)  How do you redefine 3 to be 14?
>
> three years late slogan (for the USA): Yes We Can...
>
> http://thedailywtf.com/Articles/Disgruntled-Bomb-Java-Edition.aspx
>
> basically:
>
> import java.lang.*;
> ...
>             Field field = Integer.class.getDeclaredField( "value" );
>             field.setAccessible( true );
>             int i=3;
>             field.setInt(i,14);
> ...
>
>
> Integer a = 2;
> Integer b = 3;
>
> System.out.println( a + b );

That's not redefining the value of 3 and 6. That's redefining the value o
f 
Integer(3) and Integer(6).  The expression "2 + 3" will still return 5.

Note that in Fortran and FORTH at least, it's pretty trivial to make the 

literal 3 refer to the value 15.  (By "pretty trivial" I mean "you might 
do 
it by accident.")

-- 
Darren New, San Diego CA, USA (PST)
   "Coding without comments is like
    driving without turn signals."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.