59e2b47471c28025f5adbff917678747de33f485
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2019-2020 Louis-Vincent Boudreault <lv.boudreault95@gmail.com>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
27 redef fun toto
(x
) do return x
+ self
29 fun mult_by
(x
: Int): Int do return x
* self
58 return "x is {x.as(not null)}"
67 assert f1
.call
== "in A::fun1"
69 assert f2
.call
== "in B::fun1"
72 assert f3
.call
(10) == 100
75 assert f4
.call
== "in B::fun1"
77 var f5
: Fun0[Object] = &f4
.call
78 assert f5
.call
== "in B::fun1"
79 assert f5
.call
== "in B::fun1"
81 assert (&10.toto
).call
(100) == 110
82 assert (&"allo".toto
).call
(1) == 2
86 var ps
= [p1
,p1
,p1
,p1
,p1
]
91 var c1
= new C
[nullable Object](null)
92 var c2
= new C
[nullable Int](null)
97 assert f6
.call
== "x is null"
98 assert f7
.call
== "x is null"
103 assert f6
.call
== "x is test"
104 assert f7
.call
== "x is 100"