Nice/testsuite/compiler/designByContract assert.testsuite,1.5,1.6

Artem Gr Kozarezov <[email protected]> Sat, 09 Apr 2005 20:59:14 +0000
Newsgroups gmane.comp.lang.nice.cvs
Message-ID <[email protected]>
Update of /cvsroot/nice/Nice/testsuite/compiler/designByContract
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12826/testsuite/compiler/designByContract

Modified Files:
	assert.testsuite 
Log Message:
Allow Object to be used for assertion message.

Index: assert.testsuite
===================================================================
RCS file: /cvsroot/nice/Nice/testsuite/compiler/designByContract/assert.testsuite,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** assert.testsuite	2 Apr 2005 09:14:24 -0000	1.5
--- assert.testsuite	9 Apr 2005 20:59:12 -0000	1.6
***************
*** 74,77 ****
--- 74,78 ----
    try{
      assert 0 == 1;
+     throw new Exception( "AssertionFailed not thrown." );
    }catch(AssertionFailed afe){
      let message = afe.getMessage(); assert message != null;
***************
*** 93,94 ****
--- 94,119 ----
      throw new Exception( "AssertionFailed not thrown." );
    }catch(AssertionFailed ok){}
+ 
+ /// PASS
+   // support Object message
+   try{
+     !assert 0 == 1 : new Foo();
+     throw new Exception( "AssertionFailed not thrown." );
+   }catch(AssertionFailed ok){
+     !assert ok.getMessage().equals("bar");
+     !assert ok.getCause() == null;
+   }
+   /// Toplevel
+ class Foo {
+   toString() = "bar";
+ }
+ 
+ /// PASS
+   // if the message is Throwable, it should become a "cause" (as in java.lang.AssertionError).
+   let cause = new Exception("bar");
+   try{
+     !assert 0 == 1 : cause;
+     throw new Exception( "AssertionFailed not thrown." );
+   }catch(AssertionFailed ok){
+     !assert ok.getCause() == cause;
+   }



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click