PageRenderTime 38ms CodeModel.GetById 1ms app.highlight 33ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Examples/test-suite/go/contract_runme.go

#
Go | 208 lines | 185 code | 22 blank | 1 comment | 42 complexity | e5e427abd206a0b50382dc36099daac3 MD5 | raw file
  1package main
  2
  3import "./contract"
  4
  5func main() {
  6	contract.Test_preassert(1, 2)
  7	contract.Test_postassert(3)
  8	func() {
  9		defer func() {
 10			if recover() == nil {
 11				panic("Failed! Postassertions are broken")
 12			}
 13		}()
 14		contract.Test_postassert(-3)
 15	}()
 16
 17	contract.Test_prepost(2, 3)
 18	contract.Test_prepost(5, -4)
 19	func() {
 20		defer func() {
 21			if recover() == nil {
 22				panic("Failed! Preassertions are broken")
 23			}
 24		}()
 25		contract.Test_prepost(-3, 4)
 26	}()
 27
 28	func() {
 29		defer func() {
 30			if recover() == nil {
 31				panic("Failed! Postassertions are broken")
 32			}
 33		}()
 34		contract.Test_prepost(4, -10)
 35	}()
 36
 37	f := contract.NewFoo()
 38	f.Test_preassert(4, 5)
 39	func() {
 40		defer func() {
 41			if recover() == nil {
 42				panic("Failed! Method preassertion.")
 43			}
 44		}()
 45		f.Test_preassert(-2, 3)
 46	}()
 47
 48	f.Test_postassert(4)
 49	func() {
 50		defer func() {
 51			if recover() == nil {
 52				panic("Failed! Method postassertion")
 53			}
 54		}()
 55		f.Test_postassert(-4)
 56	}()
 57
 58	f.Test_prepost(3, 4)
 59	f.Test_prepost(4, -3)
 60	func() {
 61		defer func() {
 62			if recover() == nil {
 63				panic("Failed! Method preassertion.")
 64			}
 65		}()
 66		f.Test_prepost(-4, 2)
 67	}()
 68
 69	func() {
 70		defer func() {
 71			if recover() == nil {
 72				panic("Failed! Method postassertion.")
 73			}
 74		}()
 75		f.Test_prepost(4, -10)
 76	}()
 77
 78	contract.FooStest_prepost(4, 0)
 79	func() {
 80		defer func() {
 81			if recover() == nil {
 82				panic("Failed! Static method preassertion")
 83			}
 84		}()
 85		contract.FooStest_prepost(-4, 2)
 86	}()
 87
 88	func() {
 89		defer func() {
 90			if recover() == nil {
 91				panic("Failed! Static method posteassertion")
 92			}
 93		}()
 94		contract.FooStest_prepost(4, -10)
 95	}()
 96
 97	b := contract.NewBar()
 98	func() {
 99		defer func() {
100			if recover() == nil {
101				panic("Failed! Inherited preassertion.")
102			}
103		}()
104		b.Test_prepost(2, -4)
105	}()
106
107	d := contract.NewD()
108	func() {
109		defer func() {
110			if recover() == nil {
111				panic("Failed! Inherited preassertion (D).")
112			}
113		}()
114		d.Foo(-1, 1, 1, 1, 1)
115	}()
116
117	func() {
118		defer func() {
119			if recover() == nil {
120				panic("Failed! Inherited preassertion (D).")
121			}
122		}()
123		d.Foo(1, -1, 1, 1, 1)
124	}()
125
126	func() {
127		defer func() {
128			if recover() == nil {
129				panic("Failed! Inherited preassertion (D).")
130			}
131		}()
132		d.Foo(1, 1, -1, 1, 1)
133	}()
134
135	func() {
136		defer func() {
137			if recover() == nil {
138				panic("Failed! Inherited preassertion (D).")
139			}
140		}()
141		d.Foo(1, 1, 1, -1, 1)
142	}()
143
144	func() {
145		defer func() {
146			if recover() == nil {
147				panic("Failed! Inherited preassertion (D).")
148			}
149		}()
150		d.Foo(1, 1, 1, 1, -1)
151	}()
152
153	func() {
154		defer func() {
155			if recover() == nil {
156				panic("Failed! Inherited preassertion (D).")
157			}
158		}()
159		d.Bar(-1, 1, 1, 1, 1)
160	}()
161
162	func() {
163		defer func() {
164			if recover() == nil {
165				panic("Failed! Inherited preassertion (D).")
166			}
167		}()
168		d.Bar(1, -1, 1, 1, 1)
169	}()
170
171	func() {
172		defer func() {
173			if recover() == nil {
174				panic("Failed! Inherited preassertion (D).")
175			}
176		}()
177		d.Bar(1, 1, -1, 1, 1)
178	}()
179
180	func() {
181		defer func() {
182			if recover() == nil {
183				panic("Failed! Inherited preassertion (D).")
184			}
185		}()
186		d.Bar(1, 1, 1, -1, 1)
187	}()
188
189	func() {
190		defer func() {
191			if recover() == nil {
192				panic("Failed! Inherited preassertion (D).")
193			}
194		}()
195		d.Bar(1, 1, 1, 1, -1)
196	}()
197
198	//Namespace
199	my := contract.NewMyClass(1)
200	func() {
201		defer func() {
202			if recover() == nil {
203				panic("Failed! constructor preassertion")
204			}
205		}()
206		my = contract.NewMyClass(0)
207	}()
208}