tests: add base_init_basic.nit
authorJean Privat <jean@pryen.org>
Wed, 20 Aug 2014 01:43:12 +0000 (21:43 -0400)
committerJean Privat <jean@pryen.org>
Mon, 25 Aug 2014 17:05:38 +0000 (13:05 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_init_basic.nit [new file with mode: 0644]
tests/sav/base_init_basic.res [new file with mode: 0644]
tests/sav/base_init_basic_alt1.res [new file with mode: 0644]
tests/sav/base_init_basic_alt2.res [new file with mode: 0644]
tests/sav/base_init_basic_alt3.res [new file with mode: 0644]
tests/sav/base_init_basic_alt4.res [new file with mode: 0644]

diff --git a/tests/base_init_basic.nit b/tests/base_init_basic.nit
new file mode 100644 (file)
index 0000000..6842aa3
--- /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 do 'a'.output #alt1,2#
+end
+
+class B
+       super A
+       init do 'b'.output #alt1,2#
+end
+
+class C
+       super A
+       var c: Int
+       init do 'c'.output #alt2#
+end
+
+class D
+       super B
+       super C
+       #alt3#var b: Int
+       #alt4#var b = 11
+       init do 'd'.output #alt2#
+end
+
+class E
+       super B
+       super C
+       var e: Int
+       init do 'e'.output #alt1,2#
+end
+
+class F
+       super D
+       super E
+       init do 'f'.output #alt1,2#
+end
+
+class G
+       super D
+       super E
+       var g: Int
+       init do 'g'.output #alt2#
+end
+
+class H
+       super F
+       super G
+       init do 'h'.output #alt1,2#
+end
+
+
+var a = new A
+'\n'.output
+
+var b = new B
+'\n'.output
+
+var c = new C(1)
+'\n'.output
+c.c.output
+
+var d = new D(2)
+'\n'.output
+d.c.output
+
+var e = new E(3, 30)
+'\n'.output
+e.c.output
+e.e.output
+
+var f = new F(4, 40)
+'\n'.output
+f.c.output
+f.e.output
+
+var g = new G(5, 50, 500)
+'\n'.output
+g.c.output
+g.e.output
+g.g.output
+
+var h = new H(6, 60, 600)
+'\n'.output
+h.c.output
+h.e.output
+h.g.output
diff --git a/tests/sav/base_init_basic.res b/tests/sav/base_init_basic.res
new file mode 100644 (file)
index 0000000..024fc50
--- /dev/null
@@ -0,0 +1,20 @@
+a
+ab
+ac
+1
+abcd
+2
+abce
+3
+30
+abcdef
+4
+40
+abcdeg
+5
+50
+500
+abcdefgh
+6
+60
+600
diff --git a/tests/sav/base_init_basic_alt1.res b/tests/sav/base_init_basic_alt1.res
new file mode 100644 (file)
index 0000000..debd61b
--- /dev/null
@@ -0,0 +1,20 @@
+
+
+c
+1
+cd
+2
+c
+3
+30
+cd
+4
+40
+cdg
+5
+50
+500
+cdg
+6
+60
+600
diff --git a/tests/sav/base_init_basic_alt2.res b/tests/sav/base_init_basic_alt2.res
new file mode 100644 (file)
index 0000000..a08a7a2
--- /dev/null
@@ -0,0 +1,20 @@
+
+
+
+1
+
+2
+
+3
+30
+
+4
+40
+
+5
+50
+500
+
+6
+60
+600
diff --git a/tests/sav/base_init_basic_alt3.res b/tests/sav/base_init_basic_alt3.res
new file mode 100644 (file)
index 0000000..a7be1ec
--- /dev/null
@@ -0,0 +1,2 @@
+alt/base_init_basic_alt3.nit:47,7: Error: conflict for inherited inits base_init_basic_alt3#E#init(c=, e=) and base_init_basic_alt3#D#init(c=, b=)
+alt/base_init_basic_alt3.nit:53,7: Error: conflict for inherited inits base_init_basic_alt3#E#init(c=, e=) and base_init_basic_alt3#D#init(c=, b=)
diff --git a/tests/sav/base_init_basic_alt4.res b/tests/sav/base_init_basic_alt4.res
new file mode 100644 (file)
index 0000000..024fc50
--- /dev/null
@@ -0,0 +1,20 @@
+a
+ab
+ac
+1
+abcd
+2
+abce
+3
+30
+abcdef
+4
+40
+abcdeg
+5
+50
+500
+abcdefgh
+6
+60
+600