tests: add base_init_combine.nit
authorJean Privat <jean@pryen.org>
Tue, 13 May 2014 10:00:30 +0000 (06:00 -0400)
committerJean Privat <jean@pryen.org>
Tue, 13 May 2014 15:40:13 +0000 (11:40 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

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

diff --git a/tests/base_init_combine.nit b/tests/base_init_combine.nit
new file mode 100644 (file)
index 0000000..e30298f
--- /dev/null
@@ -0,0 +1,60 @@
+# 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 do 1.output
+end
+
+class B
+       init do 2.output
+end
+
+class C
+       super A
+       super B
+
+       init do 3.output
+end
+
+class D
+       super A
+       super B
+
+       var i: Int
+end
+
+class E
+       super A
+       super B
+
+       var i: Int
+       init(i: Int) do
+               self.i = i
+               i.output
+       end
+end
+
+class F
+       super E
+       #alt1# var z: Int
+end
+
+var a = new A
+var b = new B
+var c = new C
+var d = new D(4)
+var e = new E(5)
+var f = new F(6)
diff --git a/tests/sav/base_init_combine.res b/tests/sav/base_init_combine.res
new file mode 100644 (file)
index 0000000..d210e23
--- /dev/null
@@ -0,0 +1,13 @@
+1
+2
+1
+2
+3
+1
+2
+1
+2
+5
+1
+2
+6
diff --git a/tests/sav/base_init_combine_alt1.res b/tests/sav/base_init_combine_alt1.res
new file mode 100644 (file)
index 0000000..5759dba
--- /dev/null
@@ -0,0 +1 @@
+alt/base_init_combine_alt1.nit:52,6: Error: base_init_combine_alt1#F cannot inherit constructors from E because there is attributes without initial values: z: Int