tests: extends `base_prot` to check more visibility configuration
authorJean Privat <jean@pryen.org>
Mon, 24 Mar 2014 15:13:10 +0000 (11:13 -0400)
committerJean Privat <jean@pryen.org>
Tue, 25 Mar 2014 15:22:57 +0000 (11:22 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

21 files changed:
tests/base_prot.nit
tests/base_prot0.nit [new file with mode: 0644]
tests/base_prot2.nit
tests/base_prot3.nit
tests/sav/base_prot.res
tests/sav/base_prot0.res [new file with mode: 0644]
tests/sav/base_prot2.res
tests/sav/base_prot2_alt1.res
tests/sav/base_prot2_alt2.res
tests/sav/base_prot2_alt3.res
tests/sav/base_prot2_alt4.res
tests/sav/base_prot3.res
tests/sav/base_prot3_alt1.res [new file with mode: 0644]
tests/sav/base_prot3_alt2.res [new file with mode: 0644]
tests/sav/base_prot3_alt3.res [new file with mode: 0644]
tests/sav/base_prot3_alt4.res [new file with mode: 0644]
tests/sav/base_prot3_alt5.res [new file with mode: 0644]
tests/sav/base_prot3_alt6.res [new file with mode: 0644]
tests/sav/base_prot3_alt7.res [new file with mode: 0644]
tests/sav/base_prot3_alt8.res [new file with mode: 0644]
tests/sav/base_prot3_alt9.res [new file with mode: 0644]

index c7e2930..95d1065 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 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
@@ -16,7 +14,9 @@
 
 import kernel
 
-class A
+import base_prot0
+
+redef class A
        fun pub do 0.output
        protected fun pro do 1.output
        private fun pri do 2.output
@@ -30,6 +30,7 @@ class O1
                a.pub
                a.pro
                a.pri
+               3.output
        end
        init do end
 end
diff --git a/tests/base_prot0.nit b/tests/base_prot0.nit
new file mode 100644 (file)
index 0000000..9be3552
--- /dev/null
@@ -0,0 +1,18 @@
+# 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
+end
index 4611f85..b6dbfcb 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 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
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import base_prot0
 private import base_prot
 
-class A2
+class B
        super A
-       fun o
-       do
+       redef fun pub do 10.output
+       redef fun pro do 11.output
+       #alt1#redef fun pri do 12.output
+       fun o do
                pub
                pro
-               #alt1#pri
+               #alt2#pri
        end
-       init do end
 end
 
 class O2
        fun o
        do
-               var a = new A
+               var a = new B
                a.pub
-               #alt2#a.pro
-               #alt3#a.pri
-
-               var a2 = new A2
-               a2.o
-               a2.pub
-               #alt4#a2.pro
-               #alt5#a2.pri
+               #alt3#a.pro
+               #alt4#a.pri
+               13.output
        end
        init do end
 end
index df87cd0..191cfa2 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 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
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import base_prot0
 private import base_prot2
-intrude import base_prot
+
+class C
+       super A
+       #alt5#redef fun pub do 20.output
+       #alt6#redef fun pro do 21.output
+       #alt1#redef fun pri do 22.output
+       fun o do
+               #alt7#pub
+               #alt8#pro
+               #alt2#pri
+       end
+end
 
 class O3
        fun o
        do
-               var a = new A
-               a.pub
-               a.pro
-               a.pri
+               var a = new C
+               #alt9#a.pub
+               #alt3#a.pro
+               #alt4#a.pri
+               23.output
        end
        init do end
 end
 
 (new O3).o
-
diff --git a/tests/sav/base_prot0.res b/tests/sav/base_prot0.res
new file mode 100644 (file)
index 0000000..e69de29
index 0e4b84c..c18edb9 100644 (file)
@@ -1 +1 @@
-alt/base_prot2_alt1.nit:25,3--5: Error: Method or variable 'pri' unknown in A2.
+alt/base_prot2_alt1.nit:22,12--14: Error: No property B::pri is inherited. Remove the redef keyword to define a new property.
index be87afb..f861feb 100644 (file)
@@ -1 +1 @@
-alt/base_prot2_alt2.nit:35,3--7: Error: Method 'pro' is protected and can only acceded by self. none
+alt/base_prot2_alt2.nit:26,3--5: Error: Method or variable 'pri' unknown in B.
index d6e7a77..f597f61 100644 (file)
@@ -1 +1 @@
-alt/base_prot2_alt3.nit:36,3--7: Error: Method 'pri' doesn't exists in A.
+alt/base_prot2_alt3.nit:35,3--7: Error: Method 'pro' is protected and can only acceded by self.
index 0142026..221e070 100644 (file)
@@ -1 +1 @@
-alt/base_prot2_alt4.nit:41,3--8: Error: Method 'pro' is protected and can only acceded by self. none
+alt/base_prot2_alt4.nit:36,3--7: Error: Method 'pri' doesn't exists in B.
diff --git a/tests/sav/base_prot3_alt1.res b/tests/sav/base_prot3_alt1.res
new file mode 100644 (file)
index 0000000..5ecf371
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt1.nit:22,12--14: Error: No property C::pri is inherited. Remove the redef keyword to define a new property.
diff --git a/tests/sav/base_prot3_alt2.res b/tests/sav/base_prot3_alt2.res
new file mode 100644 (file)
index 0000000..956aacd
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt2.nit:26,3--5: Error: Method or variable 'pri' unknown in C.
diff --git a/tests/sav/base_prot3_alt3.res b/tests/sav/base_prot3_alt3.res
new file mode 100644 (file)
index 0000000..a384502
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt3.nit:35,3--7: Error: Method 'pro' doesn't exists in C.
diff --git a/tests/sav/base_prot3_alt4.res b/tests/sav/base_prot3_alt4.res
new file mode 100644 (file)
index 0000000..d7f2b51
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt4.nit:36,3--7: Error: Method 'pri' doesn't exists in C.
diff --git a/tests/sav/base_prot3_alt5.res b/tests/sav/base_prot3_alt5.res
new file mode 100644 (file)
index 0000000..d375312
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt5.nit:20,12--14: Error: No property C::pub is inherited. Remove the redef keyword to define a new property.
diff --git a/tests/sav/base_prot3_alt6.res b/tests/sav/base_prot3_alt6.res
new file mode 100644 (file)
index 0000000..da112d3
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt6.nit:21,12--14: Error: No property C::pro is inherited. Remove the redef keyword to define a new property.
diff --git a/tests/sav/base_prot3_alt7.res b/tests/sav/base_prot3_alt7.res
new file mode 100644 (file)
index 0000000..06cbec1
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt7.nit:24,3--5: Error: Method or variable 'pub' unknown in C.
diff --git a/tests/sav/base_prot3_alt8.res b/tests/sav/base_prot3_alt8.res
new file mode 100644 (file)
index 0000000..168d1c8
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt8.nit:25,3--5: Error: Method or variable 'pro' unknown in C.
diff --git a/tests/sav/base_prot3_alt9.res b/tests/sav/base_prot3_alt9.res
new file mode 100644 (file)
index 0000000..a708c8f
--- /dev/null
@@ -0,0 +1 @@
+alt/base_prot3_alt9.nit:34,3--7: Error: Method 'pub' doesn't exists in C.