From 027b5c040feccad0f0f49b763c8e37a59394efb4 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sun, 1 May 2016 20:54:04 -0400 Subject: [PATCH] tests: add `error_names` and extends the `names` hierarchy Signed-off-by: Jean Privat --- tests/error_names.nit | 37 +++++++++++++++++++ tests/names1.nit | 90 +++++++++++++++++++++++++++++++++++++++++++++ tests/sav/error_names.res | 6 +++ 3 files changed, 133 insertions(+) create mode 100644 tests/error_names.nit create mode 100644 tests/names1.nit create mode 100644 tests/sav/error_names.res diff --git a/tests/error_names.nit b/tests/error_names.nit new file mode 100644 index 0000000..a2eb360 --- /dev/null +++ b/tests/error_names.nit @@ -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 index 0000000..f141a9b --- /dev/null +++ b/tests/names1.nit @@ -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 index 0000000..5cc3609 --- /dev/null +++ b/tests/sav/error_names.res @@ -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`? -- 1.7.9.5