tests: add 3 old uncommitted tests
authorJean Privat <jean@pryen.org>
Tue, 20 Nov 2012 16:25:51 +0000 (11:25 -0500)
committerJean Privat <jean@pryen.org>
Tue, 20 Nov 2012 16:25:51 +0000 (11:25 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_inheritance.nit [new file with mode: 0644]
tests/base_primitive_fun.nit [new file with mode: 0644]
tests/base_simple_import.nit [new file with mode: 0644]
tests/sav/base_inheritance.res [new file with mode: 0644]
tests/sav/base_primitive_fun.res [new file with mode: 0644]
tests/sav/base_simple_import.res [new file with mode: 0644]

diff --git a/tests/base_inheritance.nit b/tests/base_inheritance.nit
new file mode 100644 (file)
index 0000000..9f1c5ac
--- /dev/null
@@ -0,0 +1,61 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+interface Object
+end
+
+enum Int
+       fun output is intern
+end
+
+class A
+       fun foo do 1.output
+end
+
+class B
+       super A
+end
+
+class C
+       super B
+       redef fun foo do 2.output
+end
+
+class D
+       super C
+end
+
+class D2
+       super C
+       redef fun foo do 3.output
+end
+
+class E
+       super D
+       super D2
+end
+
+fun test(a: A)
+do
+       a.foo
+end
+
+test(new A)
+test(new B)
+test(new C)
+test(new D)
+test(new D2)
+test(new E)
diff --git a/tests/base_primitive_fun.nit b/tests/base_primitive_fun.nit
new file mode 100644 (file)
index 0000000..5f22f53
--- /dev/null
@@ -0,0 +1,42 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import end
+
+interface Object
+       type T: Object
+       fun output do 0.output
+       fun foo: T do return self
+       fun bar(t: T) do t.output
+end
+
+enum Int
+       redef type T: Int
+       redef fun output is intern
+       redef fun foo: T do return self
+       redef fun bar(t: T) do t.output
+end
+
+fun test(o: Object)
+do
+       o.output
+       o.foo.output
+       o.bar(o)
+end
+
+5.output
+5.foo.output
+4.bar(5)
+
+test(5)
diff --git a/tests/base_simple_import.nit b/tests/base_simple_import.nit
new file mode 100644 (file)
index 0000000..5f9bfc6
--- /dev/null
@@ -0,0 +1,40 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2005-2008 Jean Privat <jean@pryen.org>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import base_simple
+
+class C
+       super A
+       redef fun bar(i: Int)
+       do
+               i.output
+               i.output
+               i.output
+       end
+       fun this_is_a_dead_method
+       do
+               0.output
+       end
+
+       init
+       do
+               1.output
+       end
+end
+
+var a = new C  # A complex construction
+a.foo(2)       # A monormphic call
+a.bar(3)       # A polymorphic call
diff --git a/tests/sav/base_inheritance.res b/tests/sav/base_inheritance.res
new file mode 100644 (file)
index 0000000..167851e
--- /dev/null
@@ -0,0 +1,6 @@
+1
+1
+2
+2
+3
+3
diff --git a/tests/sav/base_primitive_fun.res b/tests/sav/base_primitive_fun.res
new file mode 100644 (file)
index 0000000..caa8ab7
--- /dev/null
@@ -0,0 +1,6 @@
+5
+5
+5
+5
+5
+5
diff --git a/tests/sav/base_simple_import.res b/tests/sav/base_simple_import.res
new file mode 100644 (file)
index 0000000..f799204
--- /dev/null
@@ -0,0 +1,6 @@
+1
+2
+2
+3
+3
+3