tests: add new test package `names` for test_model_visitor
authorJean Privat <jean@pryen.org>
Sat, 23 Apr 2016 21:58:24 +0000 (17:58 -0400)
committerJean Privat <jean@pryen.org>
Wed, 27 Apr 2016 13:51:03 +0000 (09:51 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/names/README.md [new file with mode: 0644]
tests/names/n0.nit [new file with mode: 0644]
tests/names/n1.nit [new file with mode: 0644]
tests/names/n2.nit [new file with mode: 0644]
tests/names/n3.nit [new file with mode: 0644]
tests/names/package.ini [new file with mode: 0644]
tests/sav/test_model_visitor_args1.res
tests/sav/test_model_visitor_args2.res [new file with mode: 0644]
tests/test_model_visitor.args

diff --git a/tests/names/README.md b/tests/names/README.md
new file mode 100644 (file)
index 0000000..9ddf943
--- /dev/null
@@ -0,0 +1 @@
+Group of modules used to test various full_name configurations and conflicts.
diff --git a/tests/names/n0.nit b/tests/names/n0.nit
new file mode 100644 (file)
index 0000000..02008bb
--- /dev/null
@@ -0,0 +1,67 @@
+# 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.
+
+# Root module
+module n0
+
+import end
+
+# Root interface
+interface Object
+end
+
+# A public class
+class A
+       # A public method in a public class
+       fun a do end
+
+       # A private method in a public class
+       private fun z do end
+end
+
+# A public subclass in the same module
+class A0
+       super A
+       super P
+
+       # Redefinition it the same module of a public method
+       redef fun a do end
+
+       # Redefinition it the same module of a private method
+       redef fun z do end
+
+       # Redefinition it the same module of a private method
+       redef fun p do end
+end
+
+# A private class
+private class P
+       # A private method in a private class
+       fun p do end
+end
+
+# A private subclass introduced in the same module
+private class P0
+       super A
+       super P
+
+       # Redefinition it the same module of a public method
+       redef fun a do end
+
+       # Redefinition it the same module of a private method
+       redef fun z do end
+
+       # Redefinition it the same module of a private method
+       redef fun p do end
+end
diff --git a/tests/names/n1.nit b/tests/names/n1.nit
new file mode 100644 (file)
index 0000000..7cfb359
--- /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.
+
+# Second module
+module n1
+
+intrude import 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/names/n2.nit b/tests/names/n2.nit
new file mode 100644 (file)
index 0000000..96486e2
--- /dev/null
@@ -0,0 +1,33 @@
+# 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.
+
+# A alternative second module, used to make name conflicts
+module n2
+
+import n0
+
+# A refinement of a class
+redef class A
+       # Name conflict? A second public method
+       fun b do end
+
+       # Name conflict? A second private method
+       fun z do end
+end
+
+# Name conflict? A second private class
+private class P
+       # Name conflict? A private method in an homonym class.
+       fun p do end
+end
diff --git a/tests/names/n3.nit b/tests/names/n3.nit
new file mode 100644 (file)
index 0000000..85310c8
--- /dev/null
@@ -0,0 +1,35 @@
+# 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.
+
+# The bottom module
+module n3
+
+intrude import n1
+import n2
+
+# a refinement of a subclass in a submodule
+redef class A1
+       # a refinement (3 distinct modules)
+       redef fun a do end
+       # a refinement (3 distinct modules)
+       redef fun p do end
+end
+
+# a refinement of a subclass in a submodule
+redef class P1
+       # a refinement (3 distinct modules)
+       redef fun a do end
+       # a refinement (3 distinct modules)
+       redef fun p do end
+end
diff --git a/tests/names/package.ini b/tests/names/package.ini
new file mode 100644 (file)
index 0000000..e69de29
index b058aab..c19ddce 100644 (file)
@@ -50,3 +50,118 @@ All public entities:
 
 All documented public entities:
  list:
+
+Names:
+
+# Classes of entities
+ population: 9
+ minimum value: 1
+ maximum value: 17
+ total value: 55
+ average value: 6.11
+ distribution:
+  <=1: sub-population=3 (33.33%); cumulated value=3 (5.45%)
+  <=4: sub-population=2 (22.22%); cumulated value=6 (10.90%)
+  <=8: sub-population=2 (22.22%); cumulated value=14 (25.45%)
+  <=16: sub-population=1 (11.11%); cumulated value=15 (27.27%)
+  <=32: sub-population=1 (11.11%); cumulated value=17 (30.90%)
+ list:
+  MMethodDef: 17 (30.90%)
+  MMethod: 15 (27.27%)
+  MClassDef: 7 (12.72%)
+  MClass: 7 (12.72%)
+  MAttributeDef: 3 (5.45%)
+  MAttribute: 3 (5.45%)
+  MPackage: 1 (1.81%)
+  MGroup: 1 (1.81%)
+  MModule: 1 (1.81%)
+
+# Name length of entities
+ population: 55
+ minimum value: 12
+ maximum value: 36
+ total value: 1124
+ average value: 20.43
+ distribution:
+  <=12: sub-population=1 (1.81%); cumulated value=12 (1.06%)
+  <=24: sub-population=46 (83.63%); cumulated value=874 (77.75%)
+  <=48: sub-population=8 (14.54%); cumulated value=238 (21.17%)
+ list:
+  base_simple3::base_simple3::C::_val2: 36 (3.20%)
+  base_simple3::base_simple3::C::_val1: 36 (3.20%)
+  base_simple3::base_simple3::B::_val: 35 (3.11%)
+  base_simple3$A$Object::init: 27 (2.40%)
+  base_simple3$C$Object::init: 27 (2.40%)
+  base_simple3::base_simple3: 26 (2.31%)
+  base_simple3::Object::init: 26 (2.31%)
+  base_simple3::Int::output: 25 (2.22%)
+  base_simple3$Object$init: 24 (2.13%)
+  base_simple3::Sys::main: 23 (2.04%)
+  ...
+  base_simple3$Sys: 16 (1.42%)
+  base_simple3$Int: 16 (1.42%)
+  base_simple3::A: 15 (1.33%)
+  base_simple3::B: 15 (1.33%)
+  base_simple3::C: 15 (1.33%)
+  base_simple3$B: 14 (1.24%)
+  base_simple3$C: 14 (1.24%)
+  base_simple3$A: 14 (1.24%)
+  base_simple3>: 13 (1.15%)
+  base_simple3: 12 (1.06%)
+
+# All entities
+base_simple3   MPackage        
+base_simple3>  MGroup  
+base_simple3::base_simple3     MModule 
+base_simple3::Object   MClass  
+base_simple3$Object    MClassDef       
+base_simple3::Object::init     MMethod 
+base_simple3$Object$init       MMethodDef      
+base_simple3::Bool     MClass  
+base_simple3$Bool      MClassDef       
+base_simple3::Int      MClass  
+base_simple3$Int       MClassDef       
+base_simple3::Int::output      MMethod 
+base_simple3$Int$output        MMethodDef      
+base_simple3::A        MClass  
+base_simple3$A MClassDef       
+base_simple3$A$Object::init    MMethodDef      
+base_simple3::A::run   MMethod 
+base_simple3$A$run     MMethodDef      
+base_simple3::B        MClass  
+base_simple3$B MClassDef       
+base_simple3::base_simple3::B::_val    MAttribute      
+base_simple3$B$_val    MAttributeDef   
+base_simple3::B::val   MMethod 
+base_simple3$B$val     MMethodDef      
+base_simple3::B::val=  MMethod 
+base_simple3$B$val=    MMethodDef      
+base_simple3::B::init  MMethod 
+base_simple3$B$init    MMethodDef      
+base_simple3::B::run   MMethod 
+base_simple3$B$run     MMethodDef      
+base_simple3::C        MClass  
+base_simple3$C MClassDef       
+base_simple3::base_simple3::C::_val1   MAttribute      
+base_simple3$C$_val1   MAttributeDef   
+base_simple3::C::val1  MMethod 
+base_simple3$C$val1    MMethodDef      
+base_simple3::C::val1= MMethod 
+base_simple3$C$val1=   MMethodDef      
+base_simple3::base_simple3::C::_val2   MAttribute      
+base_simple3$C$_val2   MAttributeDef   
+base_simple3::C::val2  MMethod 
+base_simple3$C$val2    MMethodDef      
+base_simple3::C::val2= MMethod 
+base_simple3$C$val2=   MMethodDef      
+base_simple3$C$Object::init    MMethodDef      
+base_simple3::Sys      MClass  
+base_simple3$Sys       MClassDef       
+base_simple3::Sys::foo MMethod 
+base_simple3$Sys$foo   MMethodDef      
+base_simple3::Sys::bar MMethod 
+base_simple3$Sys$bar   MMethodDef      
+base_simple3::Sys::baz MMethod 
+base_simple3$Sys$baz   MMethodDef      
+base_simple3::Sys::main        MMethod 
+base_simple3$Sys$main  MMethodDef      
diff --git a/tests/sav/test_model_visitor_args2.res b/tests/sav/test_model_visitor_args2.res
new file mode 100644 (file)
index 0000000..46ed3c4
--- /dev/null
@@ -0,0 +1,177 @@
+All entities, including fictive ones:
+ list:
+  MMethodDef: 33 (46.47%)
+  MClassDef: 15 (21.12%)
+  MMethod: 8 (11.26%)
+  MClass: 8 (11.26%)
+  MModule: 4 (5.63%)
+  MGroup: 1 (1.40%)
+  MPackage: 1 (1.40%)
+  Model: 1 (1.40%)
+All entities:
+ list:
+  MMethodDef: 33 (46.47%)
+  MClassDef: 15 (21.12%)
+  MMethod: 8 (11.26%)
+  MClass: 8 (11.26%)
+  MModule: 4 (5.63%)
+  MGroup: 1 (1.40%)
+  MPackage: 1 (1.40%)
+  Model: 1 (1.40%)
+
+All non-private entities:
+ list:
+  MMethodDef: 10 (29.41%)
+  MClassDef: 8 (23.52%)
+  MMethod: 5 (14.70%)
+  MClass: 4 (11.76%)
+  MModule: 4 (11.76%)
+  MGroup: 1 (2.94%)
+  MPackage: 1 (2.94%)
+  Model: 1 (2.94%)
+
+All documented non-private entities:
+ list:
+
+All public entities:
+ list:
+  MMethodDef: 10 (29.41%)
+  MClassDef: 8 (23.52%)
+  MMethod: 5 (14.70%)
+  MClass: 4 (11.76%)
+  MModule: 4 (11.76%)
+  MGroup: 1 (2.94%)
+  MPackage: 1 (2.94%)
+  Model: 1 (2.94%)
+
+All documented public entities:
+ list:
+
+Names:
+
+# Classes of entities
+ population: 7
+ minimum value: 1
+ maximum value: 33
+ total value: 70
+ average value: 10.00
+ distribution:
+  <=1: sub-population=2 (28.57%); cumulated value=2 (2.85%)
+  <=4: sub-population=1 (14.28%); cumulated value=4 (5.71%)
+  <=8: sub-population=2 (28.57%); cumulated value=16 (22.85%)
+  <=16: sub-population=1 (14.28%); cumulated value=15 (21.42%)
+  <=64: sub-population=1 (14.28%); cumulated value=33 (47.14%)
+ list:
+  MMethodDef: 33 (47.14%)
+  MClassDef: 15 (21.42%)
+  MMethod: 8 (11.42%)
+  MClass: 8 (11.42%)
+  MModule: 4 (5.71%)
+  MGroup: 1 (1.42%)
+  MPackage: 1 (1.42%)
+
+# Name length of entities
+ population: 70
+ minimum value: 5
+ maximum value: 29
+ total value: 1045
+ average value: 14.92
+ distribution:
+  <=5: sub-population=1 (1.42%); cumulated value=5 (0.47%)
+  <=10: sub-population=13 (18.57%); cumulated value=109 (10.43%)
+  <=20: sub-population=44 (62.85%); cumulated value=637 (60.95%)
+  <=40: sub-population=12 (17.14%); cumulated value=294 (28.13%)
+ list:
+  names::n3$::n1::P1$::n0::P::p: 29 (2.77%)
+  names::n1$::n0::P0$::n0::A::z: 29 (2.77%)
+  names::n1$::n0::P0$::n0::P::p: 29 (2.77%)
+  names::n3$::n1::P1$A::a: 23 (2.20%)
+  names::n1$A0$::n0::A::z: 23 (2.20%)
+  names::n1$A0$::n0::P::p: 23 (2.20%)
+  names::n0$P0$::n0::A::z: 23 (2.20%)
+  names::n0$P0$::n0::P::p: 23 (2.20%)
+  names::n3$A1$::n0::P::p: 23 (2.20%)
+  names::n1$::n0::P0$A::a: 23 (2.20%)
+  ...
+  names::n0: 9 (0.86%)
+  names$A$z: 9 (0.86%)
+  names::A0: 9 (0.86%)
+  names::n3: 9 (0.86%)
+  names::A: 8 (0.76%)
+  names$A0: 8 (0.76%)
+  names$A1: 8 (0.76%)
+  names$A: 7 (0.66%)
+  names>: 6 (0.57%)
+  names: 5 (0.47%)
+
+# All entities
+names  MPackage        Group of modules used to test various full_name configurations and conflicts.
+names> MGroup  Group of modules used to test various full_name configurations and conflicts.
+names::n3      MModule The bottom module
+names::n3$A1   MClassDef       a refinement of a subclass in a submodule
+names::n3$A1$A::a      MMethodDef      a refinement (3 distinct modules)
+names::n3$A1$::n0::P::p        MMethodDef      a refinement (3 distinct modules)
+names::n3$::n1::P1     MClassDef       a refinement of a subclass in a submodule
+names::n3$::n1::P1$A::a        MMethodDef      a refinement (3 distinct modules)
+names::n3$::n1::P1$::n0::P::p  MMethodDef      a refinement (3 distinct modules)
+names::n0      MModule Root module
+names::Object  MClass  
+names$Object   MClassDef       Root interface
+names::Object::init    MMethod 
+names$Object$init      MMethodDef      
+names::A       MClass  
+names$A        MClassDef       A public class
+names::A::a    MMethod 
+names$A$a      MMethodDef      A public method in a public class
+names::n0::A::z        MMethod 
+names$A$z      MMethodDef      A private method in a public class
+names::A0      MClass  
+names$A0       MClassDef       A public subclass in the same module
+names$A0$A::a  MMethodDef      Redefinition it the same module of a public method
+names$A0$::n0::A::z    MMethodDef      Redefinition it the same module of a private method
+names$A0$::n0::P::p    MMethodDef      Redefinition it the same module of a private method
+names::n0::P   MClass  
+names::n0$P    MClassDef       A private class
+names::n0::P::p        MMethod 
+names::n0$P$p  MMethodDef      A private method in a private class
+names::n0::P0  MClass  
+names::n0$P0   MClassDef       A private subclass introduced in the same module
+names::n0$P0$A::a      MMethodDef      Redefinition it the same module of a public method
+names::n0$P0$::n0::A::z        MMethodDef      Redefinition it the same module of a private method
+names::n0$P0$::n0::P::p        MMethodDef      Redefinition it the same module of a private method
+names::n1      MModule Second module
+names::n1$A    MClassDef       A refinement of a class
+names::n1$A$a  MMethodDef      A refinement in the same class
+names::n1$A$z  MMethodDef      A refinement in the same class
+names::n1::A::b        MMethod 
+names::n1$A$b  MMethodDef      A public method introduced in a refinement
+names::n1$A0   MClassDef       A refinement of a subclass
+names::n1$A0$A::a      MMethodDef      A refinement+redefinition
+names::n1$A0$::n0::A::z        MMethodDef      A refinement+redefinition
+names::n1$A0$::n0::P::p        MMethodDef      A refinement+redefinition
+names::A1      MClass  
+names$A1       MClassDef       A subclass introduced in a submodule
+names$A1$A::a  MMethodDef      A redefinition in a subclass from a different module
+names$A1$::n0::A::z    MMethodDef      A redefinition in a subclass from a different module
+names$A1$::n0::P::p    MMethodDef      A redefinition in a subclass from a different module
+names::n1$::n0::P      MClassDef       A refinement of a class
+names::n1$::n0::P$p    MMethodDef      A refinement in the same class
+names::n1$::n0::P0     MClassDef       A refinement of a subclass
+names::n1$::n0::P0$A::a        MMethodDef      A refinement+redefinition
+names::n1$::n0::P0$::n0::A::z  MMethodDef      A refinement+redefinition
+names::n1$::n0::P0$::n0::P::p  MMethodDef      A refinement+redefinition
+names::n1::P1  MClass  
+names::n1$P1   MClassDef       A private subclass introduced in a different module
+names::n1$P1$A::a      MMethodDef      A redefinition in a subclass from a different module
+names::n1$P1$::n0::A::z        MMethodDef      A redefinition in a subclass from a different module
+names::n1$P1$::n0::P::p        MMethodDef      A redefinition in a subclass from a different module
+names::n2      MModule A alternative second module, used to make name conflicts
+names::n2$A    MClassDef       A refinement of a class
+names::n2::A::b        MMethod 
+names::n2$A$b  MMethodDef      Name conflict? A second public method
+names::n2::A::z        MMethod 
+names::n2$A$z  MMethodDef      Name conflict? A second private method
+names::n2::P   MClass  
+names::n2$P    MClassDef       Name conflict? A second private class
+names::n2::P::p        MMethod 
+names::n2$P$p  MMethodDef      Name conflict? A private method in an homonym class.