comparison run/invariant_13.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
10 int x; 10 int x;
11 11
12 void test(){ 12 void test(){
13 } 13 }
14 14
15 invariant{ 15 invariant(){
16 // even number 16 // even number
17 assert(x&1==0); 17 if(x & 1){
18 assert(0);
19 }
18 } 20 }
19 } 21 }
20 22
21 class Child : Parent{ 23 class Child : Parent{
22 } 24 }
24 class GrandChild : Child{ 26 class GrandChild : Child{
25 this(int x){ 27 this(int x){
26 this.x=x; 28 this.x=x;
27 } 29 }
28 30
29 invariant{ 31 invariant(){
30 assert(x>2); 32 if(x <= 2){
33 assert(0);
34 }
31 } 35 }
32 } 36 }
33 37
34 int main(){ 38 int main(){
35 try{ 39 try{