1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Verification if it's possible to define a contract in different context (abstract class, interface and class) and it's possible to inherit it.
18 fun foo
(x
: Int, y
: Float)is abstract, expect
(x
!= 10)
21 abstract class AbstractClass
22 fun bar
(x
: Int, y
: Float)is abstract, expect
(x
>= 1), ensure
(y
== 10.0)
26 fun baz
(x
: Int, y
: Float)is abstract, ensure
(y
<= 10.0, y
== 42.0)
35 redef fun foo
(x
: Int, y
: Float)
37 if x
== 10 then print
"Error"
40 redef fun baz
(x
: Int, y
: Float)
45 redef fun bar
(x
: Int, y
: Float)
47 if x
< 1 then print
"Error"
52 var first
= new MySubClass
53 first
.foo
(11,2.0) # Ok
54 first
.bar
(1,10.0) # Ok
55 first
.baz
(9,42.0) # Fail y > 10 (y = 42.0)