From: Jean Privat Date: Wed, 26 Feb 2014 19:32:42 +0000 (-0500) Subject: tests: add base_init_super_call* X-Git-Tag: v0.6.4~11^2~1 X-Git-Url: http://nitlanguage.org tests: add base_init_super_call* Signed-off-by: Jean Privat --- diff --git a/tests/base_init_super_call.nit b/tests/base_init_super_call.nit new file mode 100644 index 0000000..5d863ab --- /dev/null +++ b/tests/base_init_super_call.nit @@ -0,0 +1,142 @@ +# 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 B1 + super A + #alt1#init do super +end + +class B2 + super A + init do super(3) +end + +class B3 + super A + #alt2#init do super(true) +end + +class B4 + super A + #alt3#init do end +end + +class C1 + super A + init(j: Int) do + super + j.output + end +end + +class D1 + super A + init(j) do + super + j.output + end +end + +class E1 + super A + init(j: Bool) do + super(8)#alt4#super + j.output + end +end + +class C2 + super A + init(j: Int) do + super(j) + j.output + end +end + +class D2 + super A + init(j) do + super(j) + j.output + end +end + +class E2 + super A + init(j: Bool) do + super(11)#alt5#super(j) + j.output + end +end + +class C3 + super A + init(j: Int) do + j.output + end +end + +class D3 + super A + init(j) do + j.output + end +end + +class E3 + super A + init(j: Bool) do + super(14)#alt6# + j.output + end +end + +class F1 + super A + init(j: Int, k: Bool) do + super + j.output + end +end + +class F2 + super A + init(j: Int, k: Bool) do + j.output + end +end + +var x +x = new A(1) +x = new B1(2) #alt1# x = new B1 +x = new B2 +x = new B3(4) #alt2# x = new B3 +x = new B4(5) #alt3# x = new B4 +x = new C1(6) +x = new D1(7) +x = new E1(true) +x = new C2(9) +x = new D2(10) +x = new E2(true) +x = new C3(12) +x = new D3(13) +x = new E3(true) +x = new F1(15,true) +x = new F2(16,true) diff --git a/tests/base_init_super_call2.nit b/tests/base_init_super_call2.nit new file mode 100644 index 0000000..f229ddb --- /dev/null +++ b/tests/base_init_super_call2.nit @@ -0,0 +1,158 @@ +# 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 + var i: Int +end + +class B1 + super A + #alt1#init do super +end + +class B2 + super A + init do super(3) +end + +class B3 + super A + #alt2#init do super(true) +end + +class B4 + super A + #alt3#init do end +end + +class C1 + super A + init(j: Int) do + super + j.output + end +end + +class D1 + super A + init(j) do + super + j.output + end +end + +class E1 + super A + init(j: Bool) do + super(8)#alt4#super + j.output + end +end + +class C2 + super A + init(j: Int) do + super(j) + j.output + end +end + +class D2 + super A + init(j) do + super(j) + j.output + end +end + +class E2 + super A + init(j: Bool) do + super(11)#alt5#super(j) + j.output + end +end + +class C3 + super A + init(j: Int) do + j.output + end +end + +class D3 + super A + init(j) do + j.output + end +end + +class E3 + super A + init(j: Bool) do + super(14)#alt6# + j.output + end +end + +class F1 + super A + init(j: Int, k: Bool) do + super + j.output + end +end + +class F2 + super A + init(j: Int, k: Bool) do + j.output + end +end + +var x +x = new A(1) +x.i.output +x = new B1(2) #alt1# x = new B1 +x.i.output +x = new B2 +x.i.output +x = new B3(4) #alt2# x = new B3 +x.i.output +x = new B4(5) #alt3# x = new B4 +x.i.output +x = new C1(6) +x.i.output +x = new D1(7) +x.i.output +x = new E1(true) +x.i.output +x = new C2(9) +x.i.output +x = new D2(10) +x.i.output +x = new E2(true) +x.i.output +x = new C3(12) +x.i.output +x = new D3(13) +x.i.output +x = new E3(true) +x.i.output +x = new F1(15,true) +x.i.output +x = new F2(16,true) +x.i.output diff --git a/tests/sav/base_init_super_call.res b/tests/sav/base_init_super_call.res new file mode 100644 index 0000000..0f283aa --- /dev/null +++ b/tests/sav/base_init_super_call.res @@ -0,0 +1,27 @@ +1 +2 +3 +4 +5 +6 +6 +7 +7 +8 +true +9 +9 +10 +10 +11 +true +12 +12 +13 +13 +14 +true +15 +15 +16 +16 diff --git a/tests/sav/base_init_super_call2.res b/tests/sav/base_init_super_call2.res new file mode 100644 index 0000000..5e26c1f --- /dev/null +++ b/tests/sav/base_init_super_call2.res @@ -0,0 +1,27 @@ +1 +2 +3 +4 +5 +6 +6 +7 +7 +true +8 +9 +9 +10 +10 +true +11 +12 +12 +13 +13 +true +14 +15 +15 +16 +16 diff --git a/tests/sav/base_init_super_call2_alt1.res b/tests/sav/base_init_super_call2_alt1.res new file mode 100644 index 0000000..b4d9a32 --- /dev/null +++ b/tests/sav/base_init_super_call2_alt1.res @@ -0,0 +1 @@ +alt/base_init_super_call2_alt1.nit:23,10--14: Error: Not enough implicit arguments to pass. Got 0, expected at least 1. Signature is (i: Int) diff --git a/tests/sav/base_init_super_call2_alt2.res b/tests/sav/base_init_super_call2_alt2.res new file mode 100644 index 0000000..4cc34a8 --- /dev/null +++ b/tests/sav/base_init_super_call2_alt2.res @@ -0,0 +1 @@ +alt/base_init_super_call2_alt2.nit:33,16--19: Type error: expected Int, got Bool diff --git a/tests/sav/base_init_super_call2_alt3.res b/tests/sav/base_init_super_call2_alt3.res new file mode 100644 index 0000000..6c513f8 --- /dev/null +++ b/tests/sav/base_init_super_call2_alt3.res @@ -0,0 +1 @@ +alt/base_init_super_call2_alt3.nit:38,2--5: Error: Cannot do an implicit constructor call to base_init_super_call2_alt3#A#init(i: Int). Expected at least 1 arguments, got 0. diff --git a/tests/sav/base_init_super_call2_alt4.res b/tests/sav/base_init_super_call2_alt4.res new file mode 100644 index 0000000..6a5c1cf --- /dev/null +++ b/tests/sav/base_init_super_call2_alt4.res @@ -0,0 +1 @@ +alt/base_init_super_call2_alt4.nit:60,3--7: Type error: expected argument #0 of type Int, got implicit argument j of type Bool. Signature is (i: Int) diff --git a/tests/sav/base_init_super_call2_alt5.res b/tests/sav/base_init_super_call2_alt5.res new file mode 100644 index 0000000..2e15e41 --- /dev/null +++ b/tests/sav/base_init_super_call2_alt5.res @@ -0,0 +1 @@ +alt/base_init_super_call2_alt5.nit:84,9: Type error: expected Int, got Bool diff --git a/tests/sav/base_init_super_call2_alt6.res b/tests/sav/base_init_super_call2_alt6.res new file mode 100644 index 0000000..0650fe9 --- /dev/null +++ b/tests/sav/base_init_super_call2_alt6.res @@ -0,0 +1 @@ +alt/base_init_super_call2_alt6.nit:105,2--5: Error: Cannot do an implicit constructor call to base_init_super_call2_alt6#A#init(i: Int). Expected argument #0 of type Int, got implicit argument j of type Bool. diff --git a/tests/sav/base_init_super_call_alt1.res b/tests/sav/base_init_super_call_alt1.res new file mode 100644 index 0000000..73082d3 --- /dev/null +++ b/tests/sav/base_init_super_call_alt1.res @@ -0,0 +1 @@ +alt/base_init_super_call_alt1.nit:23,10--14: Error: Not enough implicit arguments to pass. Got 0, expected at least 1. Signature is (i: Int) diff --git a/tests/sav/base_init_super_call_alt2.res b/tests/sav/base_init_super_call_alt2.res new file mode 100644 index 0000000..ca41f99 --- /dev/null +++ b/tests/sav/base_init_super_call_alt2.res @@ -0,0 +1 @@ +alt/base_init_super_call_alt2.nit:33,16--19: Type error: expected Int, got Bool diff --git a/tests/sav/base_init_super_call_alt3.res b/tests/sav/base_init_super_call_alt3.res new file mode 100644 index 0000000..ca3da80 --- /dev/null +++ b/tests/sav/base_init_super_call_alt3.res @@ -0,0 +1 @@ +alt/base_init_super_call_alt3.nit:38,2--5: Error: Cannot do an implicit constructor call to base_init_super_call_alt3#A#init(i: Int). Expected at least 1 arguments, got 0. diff --git a/tests/sav/base_init_super_call_alt4.res b/tests/sav/base_init_super_call_alt4.res new file mode 100644 index 0000000..cc3d485 --- /dev/null +++ b/tests/sav/base_init_super_call_alt4.res @@ -0,0 +1 @@ +alt/base_init_super_call_alt4.nit:60,3--7: Type error: expected argument #0 of type Int, got implicit argument j of type Bool. Signature is (i: Int) diff --git a/tests/sav/base_init_super_call_alt5.res b/tests/sav/base_init_super_call_alt5.res new file mode 100644 index 0000000..481ff08 --- /dev/null +++ b/tests/sav/base_init_super_call_alt5.res @@ -0,0 +1 @@ +alt/base_init_super_call_alt5.nit:84,9: Type error: expected Int, got Bool diff --git a/tests/sav/base_init_super_call_alt6.res b/tests/sav/base_init_super_call_alt6.res new file mode 100644 index 0000000..3352bce --- /dev/null +++ b/tests/sav/base_init_super_call_alt6.res @@ -0,0 +1 @@ +alt/base_init_super_call_alt6.nit:105,2--5: Error: Cannot do an implicit constructor call to base_init_super_call_alt6#A#init(i: Int). Expected argument #0 of type Int, got implicit argument j of type Bool.