update NOTICE and LICENSE
[nit.git] / tests / test_eq.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2004-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 var i = 1
18 var j = 1
19 var k = 2
20 var s = "Maison"
21 var t = "Maison"
22 var a: Object
23 var b: Object
24
25 print("* literal int")
26 print(1 is 1)
27 print(1 is 1)
28 print(not 1 is 2)
29 print(not 1 is 2)
30 print("* int variable")
31 print(i is j)
32 print(j is i)
33 print(not i is k)
34 print(i is 1)
35 print(not i is 2)
36
37 print("* same type object")
38 print(s is s)
39 a = s
40 print(s is a)
41 a = s
42 print(not s is t)
43 b = t
44 print(not s is b)
45 print(not s is b)
46
47 print("* different type object")
48 a = s.iterator
49 print(not s is a)
50 a = 5
51 print(not s is a)
52 print(not s is 5)
53
54 print("* boxed native")
55 a = i
56 b = i
57 print(i is a)
58 print(b is i)
59 print(b is a)
60 a = 5
61 b = 5.ascii
62 print(not 5 is 5.ascii)
63 print(not a is 5.ascii)
64 print(not 5 is b)
65 print(not a is b)
66
67 print("* null")
68 var a1: nullable Object = null
69 var b1: nullable Object = null
70 print(not null is s)
71 print(not s is null)
72 print(not a1 is s)
73 print(not s is a1)
74 print(null is null)
75 print(b1 is null)
76 print(b1 is a1)
77 print(not i is null)
78 print(not i is a1)
79 print(not null is i)
80 print(not a1 is i)