tests: add base_init_super_call3.nit and it does not stack-overflow
authorJean Privat <jean@pryen.org>
Sat, 16 Aug 2014 01:09:21 +0000 (21:09 -0400)
committerJean Privat <jean@pryen.org>
Sat, 16 Aug 2014 01:18:14 +0000 (21:18 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_init_super_call3.nit [new file with mode: 0644]
tests/sav/base_init_super_call3.res [new file with mode: 0644]

diff --git a/tests/base_init_super_call3.nit b/tests/base_init_super_call3.nit
new file mode 100644 (file)
index 0000000..430026d
--- /dev/null
@@ -0,0 +1,101 @@
+# 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 kernel
+
+class A
+       init(i: Int) do i.output
+end
+
+class B
+       super A
+       init(i)
+       do
+               super
+               (i+1).output
+       end
+end
+
+class C
+       super A
+       init(i)
+       do
+               (i+1).output
+               super
+       end
+end
+
+class D
+       super A
+       init(i)
+       is
+               nosuper
+       do
+               (i+1).output
+       end
+end
+
+class E
+       super A
+       init(i)
+       do
+               (i+1).output
+       end
+end
+
+class F
+       super A
+       redef init(i)
+       do
+               super
+               (i+1).output
+       end
+end
+
+class G
+       super A
+       redef init(i)
+       do
+               (i+1).output
+               super
+       end
+end
+
+class H
+       super A
+       redef init(i)
+       is
+               nosuper
+       do
+               (i+1).output
+       end
+end
+
+class I
+       super A
+       redef init(i)
+       do
+               (i+1).output
+       end
+end
+
+var a = new A(10)
+var b = new B(20)
+var c = new C(30)
+var d = new D(40)
+var e = new E(50)
+var f = new F(60)
+var g = new G(70)
+var h = new H(80)
+var i = new I(90)
diff --git a/tests/sav/base_init_super_call3.res b/tests/sav/base_init_super_call3.res
new file mode 100644 (file)
index 0000000..aa7d0fd
--- /dev/null
@@ -0,0 +1,15 @@
+10
+20
+21
+31
+30
+41
+50
+51
+60
+61
+71
+70
+81
+90
+91