comparison run/invariant_12.d @ 1559:ec5e144583ea

D1 -> D2 : 1/N
author thomask
date Sun, 19 Aug 2007 19:11:54 +0000
parents 1e6afb94ce6d
children
comparison
equal deleted inserted replaced
1558:d40d75fcd5c5 1559:ec5e144583ea
12 int x; 12 int x;
13 13
14 void test(){ 14 void test(){
15 } 15 }
16 16
17 invariant{ 17 invariant(){
18 assert(!checked); 18 if(checked){
19 assert(0);
20 }
19 checked=true; 21 checked=true;
20 // even number 22 // even number
21 assert((x&1u)==0); 23 if(x & 1u){
24 assert(0);
25 }
22 } 26 }
23 } 27 }
24 28
25 class Child : Parent{ 29 class Child : Parent{
26 } 30 }
31 } 35 }
32 } 36 }
33 37
34 int main(){ 38 int main(){
35 try{ 39 try{
36 assert(!checked); 40 if(checked){
41 assert(0);
42 }
37 GrandChild gc = new GrandChild(); 43 GrandChild gc = new GrandChild();
38 }catch{ 44 }catch{
39 assert(checked); 45 if(!checked){
46 assert(0);
47 }
40 return 0; 48 return 0;
41 } 49 }
42 assert(0); 50 assert(0);
43 } 51 }