tests: add `error_names` and extends the `names` hierarchy
authorJean Privat <jean@pryen.org>
Mon, 2 May 2016 00:54:04 +0000 (20:54 -0400)
committerJean Privat <jean@pryen.org>
Mon, 2 May 2016 15:37:34 +0000 (11:37 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

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

diff --git a/tests/error_names.nit b/tests/error_names.nit
new file mode 100644 (file)
index 0000000..a2eb360
--- /dev/null
@@ -0,0 +1,37 @@
+# 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.
+
+intrude import names::n0
+intrude import names::n1
+intrude import names::n2
+intrude import names::n3
+intrude import names1
+
+var a
+
+a = new A1
+a = new names::A1
+a = new names::n0::A1
+a = new names::n1::A1
+a = new names::n2::A1
+a = new names1::A1
+a = new names1::names1::A1
+
+a = new P1
+a = new names::P1
+a = new names::n0::P1
+a = new names::n1::P1
+a = new names::n2::P1
+a = new names1::P1
+a = new names1::names1::P1
diff --git a/tests/names1.nit b/tests/names1.nit
new file mode 100644 (file)
index 0000000..f141a9b
--- /dev/null
@@ -0,0 +1,90 @@
+# 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.
+
+# An alternative second module in a distinct package
+module names1
+
+intrude import names::n0
+
+# A refinement of a class
+redef class A
+       # A refinement in the same class
+       redef fun a do end
+
+       # A refinement in the same class
+       redef fun z do end
+
+       # A public method introduced in a refinement
+       fun b do end
+end
+
+# A refinement of a subclass
+redef class A0
+       # A refinement+redefinition
+       redef fun a do end
+
+       # A refinement+redefinition
+       redef fun z do end
+
+       # A refinement+redefinition
+       redef fun p do end
+end
+
+# A subclass introduced in a submodule
+class A1
+       super A
+       super P
+
+       # A redefinition in a subclass from a different module
+       redef fun a do end
+
+       # A redefinition in a subclass from a different module
+       redef fun z do end
+
+       # A redefinition in a subclass from a different module
+       redef fun p do end
+end
+
+# A refinement of a class
+redef class P
+       # A refinement in the same class
+       redef fun p do end
+end
+
+# A refinement of a subclass
+redef class P0
+       # A refinement+redefinition
+       redef fun a do end
+
+       # A refinement+redefinition
+       redef fun z do end
+
+       # A refinement+redefinition
+       redef fun p do end
+end
+
+# A private subclass introduced in a different module
+private class P1
+       super A
+       super P
+
+       # A redefinition in a subclass from a different module
+       redef fun a do end
+
+       # A redefinition in a subclass from a different module
+       redef fun z do end
+
+       # A redefinition in a subclass from a different module
+       redef fun p do end
+end
diff --git a/tests/sav/error_names.res b/tests/sav/error_names.res
new file mode 100644 (file)
index 0000000..5cc3609
--- /dev/null
@@ -0,0 +1,6 @@
+error_names.nit:23,9--10: Error: class `A1` not found in module `error_names`. Did you mean `names::A1` or `names1::A1`?
+error_names.nit:25,9--21: Error: class `A1` not found in module `error_names`. Did you mean `names::A1` or `names1::A1`?
+error_names.nit:27,9--21: Error: class `A1` not found in module `error_names`. Did you mean `names::A1` or `names1::A1`?
+error_names.nit:31,9--10: Error: class `P1` not found in module `error_names`. Did you mean `names::n1::P1` or `names1::names1::P1`?
+error_names.nit:33,9--21: Error: class `P1` not found in module `error_names`. Did you mean `names::n1::P1` or `names1::names1::P1`?
+error_names.nit:35,9--21: Error: class `P1` not found in module `error_names`. Did you mean `names::n1::P1` or `names1::names1::P1`?