syntax: 'meth' -> 'fun', 'attr' -> 'var'
[nit.git] / tests / error_defs.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2008 Jean Privat <jean@pryen.org>
4 #
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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 import kernel
18
19 #alt1#class Object
20 redef class Object #!alt1#
21 fun bar: Int do return 10 + baz
22 end
23
24 class A
25 fun foo: Int do return 100 + bar
26 #alt2# fun foo(c: Char) do (200 + bar).output
27 redef fun bar: Int do return 20 + baz #!alt3#
28 #alt3# fun bar: Int do return 30 + baz
29 #alt4# fun baz(c: Char) do 2.output
30 #alt5# redef fun baz(c: Char) do 2.output
31
32 init do end
33 end
34
35 #alt6#class A
36 #alt6# fun foo: Int do return 300 + bar
37 #alt6#end
38 #alt7#redef class A
39 #alt7# fun foo: Int do return 300 + bar
40 #alt7#end
41 #alt8#redef class A
42 #alt8# redef fun foo: Int do return 300 + bar
43 #alt8#end
44
45
46 fun baz: Int do return 1
47
48 baz.output
49 bar.output
50 (new A).foo.output
51 #alt2#(new A).foo('x')
52 #alt4#(new A).baz('y')
53 #alt5#(new A).baz('y')