tests: inmprove base_as_notnull*.nit and update tests
authorJean Privat <jean@pryen.org>
Thu, 17 Jul 2014 18:35:07 +0000 (14:35 -0400)
committerJean Privat <jean@pryen.org>
Thu, 17 Jul 2014 18:52:21 +0000 (14:52 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

18 files changed:
tests/base_as_notnull2.nit [new file with mode: 0644]
tests/base_as_notnull_int.nit [new file with mode: 0644]
tests/sav/base_as_notnull.res
tests/sav/base_as_notnull2.res [new file with mode: 0644]
tests/sav/base_as_notnull2_alt1.res [new file with mode: 0644]
tests/sav/base_as_notnull2_alt2.res [new file with mode: 0644]
tests/sav/base_as_notnull2_alt3.res [new file with mode: 0644]
tests/sav/base_as_notnull_alt1.res
tests/sav/base_as_notnull_alt2.res
tests/sav/base_as_notnull_alt3.res
tests/sav/base_as_notnull_alt4.res
tests/sav/base_as_notnull_alt5.res
tests/sav/base_as_notnull_alt6.res
tests/sav/base_as_notnull_alt7.res
tests/sav/base_as_notnull_int.res [new file with mode: 0644]
tests/sav/error_expr_not_ok_alt4.res
tests/sav/error_expr_not_ok_alt5.res
tests/sav/error_expr_not_ok_alt6.res

diff --git a/tests/base_as_notnull2.nit b/tests/base_as_notnull2.nit
new file mode 100644 (file)
index 0000000..d9ad95c
--- /dev/null
@@ -0,0 +1,64 @@
+# 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 G[E]
+       fun foo(e: E): E
+       do
+               var ee = e.as(not null)
+               ee.output
+               return ee
+       end
+end
+
+class A
+       super G[Object]
+       redef fun foo(e)
+       do
+               var ee = e.as(not null)
+               ee.output
+               return ee
+       end
+end
+
+class B[F: Object]
+       super G[nullable F]
+       redef fun foo(e)
+       do
+               var ee = e.as(not null)
+               ee.output
+               return ee
+       end
+end
+
+class C[F: Object]
+       super G[F]
+       redef fun foo(e)
+       do
+               var ee = e.as(not null)
+               ee.output
+               return ee
+       end
+end
+
+var a = new A
+a.foo(1).output
+#alt1#a.foo(null).output
+var b = new B[Int]
+b.foo(2).output
+#alt2#b.foo(null).output
+var c = new C[Int]
+c.foo(3).output
+#alt3#c.foo(null).output
diff --git a/tests/base_as_notnull_int.nit b/tests/base_as_notnull_int.nit
new file mode 100644 (file)
index 0000000..0b19e6e
--- /dev/null
@@ -0,0 +1,23 @@
+# 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
+
+var i: Int = 1
+i.as(not null).output
+var oi: Object = i
+oi.as(not null).output
+var ni: nullable Int = i
+ni.as(not null).output
+
index 8f499ee..2380a43 100644 (file)
@@ -1,3 +1,7 @@
+base_as_notnull.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+base_as_notnull.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+base_as_notnull.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+base_as_notnull.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
 1
 2
 3
diff --git a/tests/sav/base_as_notnull2.res b/tests/sav/base_as_notnull2.res
new file mode 100644 (file)
index 0000000..c426288
--- /dev/null
@@ -0,0 +1,8 @@
+base_as_notnull2.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+base_as_notnull2.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+1
+1
+2
+2
+3
+3
diff --git a/tests/sav/base_as_notnull2_alt1.res b/tests/sav/base_as_notnull2_alt1.res
new file mode 100644 (file)
index 0000000..e6b980e
--- /dev/null
@@ -0,0 +1,3 @@
+alt/base_as_notnull2_alt1.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt1.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt1.nit:58,7--10: Type error: expected Object, got null
diff --git a/tests/sav/base_as_notnull2_alt2.res b/tests/sav/base_as_notnull2_alt2.res
new file mode 100644 (file)
index 0000000..0d136a8
--- /dev/null
@@ -0,0 +1,7 @@
+alt/base_as_notnull2_alt2.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt2.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+Runtime error: Cast failed (alt/base_as_notnull2_alt2.nit:40)
+1
+1
+2
+2
diff --git a/tests/sav/base_as_notnull2_alt3.res b/tests/sav/base_as_notnull2_alt3.res
new file mode 100644 (file)
index 0000000..c166c42
--- /dev/null
@@ -0,0 +1,3 @@
+alt/base_as_notnull2_alt3.nit:30,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt3.nit:50,12--25: Warning: expression is already not null, since it is a `G#0: Object`.
+alt/base_as_notnull2_alt3.nit:64,7--10: Type error: expected Int, got null
index 60b7d08..ad6b798 100644 (file)
@@ -1 +1,6 @@
+alt/base_as_notnull_alt1.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt1.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt1.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt1.nit:50,6--19: Warning: expression is already not null, since it is a `A`.
 alt/base_as_notnull_alt1.nit:50,6--19: Type error: expected B, got A
+alt/base_as_notnull_alt1.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
index c076807..0e0e68c 100644 (file)
@@ -1 +1,6 @@
+alt/base_as_notnull_alt2.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt2.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt2.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt2.nit:51,6--20: Warning: expression is already not null, since it is a `A`.
 alt/base_as_notnull_alt2.nit:51,6--20: Type error: expected B, got A
+alt/base_as_notnull_alt2.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
index a88beb6..bd83530 100644 (file)
@@ -1 +1,5 @@
+alt/base_as_notnull_alt3.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt3.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt3.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt3.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
 alt/base_as_notnull_alt3.nit:53,6--20: Type error: expected B, got A
index ff16195..0050108 100644 (file)
@@ -1 +1,5 @@
+alt/base_as_notnull_alt4.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt4.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt4.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt4.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
 alt/base_as_notnull_alt4.nit:54,6--21: Type error: expected B, got A
index 917dafb..d8136e9 100644 (file)
@@ -1,3 +1,7 @@
+alt/base_as_notnull_alt5.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt5.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt5.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt5.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
 Runtime error: Cast failed (alt/base_as_notnull_alt5.nit:59)
 1
 2
index 49784b7..7083fa3 100644 (file)
@@ -1,3 +1,7 @@
+alt/base_as_notnull_alt6.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt6.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt6.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt6.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
 Runtime error: Cast failed (alt/base_as_notnull_alt6.nit:60)
 1
 2
index 0419b7f..38f0903 100644 (file)
@@ -1 +1,5 @@
+alt/base_as_notnull_alt7.nit:41,6--19: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt7.nit:42,6--20: Warning: expression is already not null, since it is a `A`.
+alt/base_as_notnull_alt7.nit:43,6--19: Warning: expression is already not null, since it is a `B`.
+alt/base_as_notnull_alt7.nit:52,6--19: Warning: expression is already not null, since it is a `B`.
 alt/base_as_notnull_alt7.nit:61,1--17: Type error: as(not null) on null
diff --git a/tests/sav/base_as_notnull_int.res b/tests/sav/base_as_notnull_int.res
new file mode 100644 (file)
index 0000000..4635340
--- /dev/null
@@ -0,0 +1,5 @@
+base_as_notnull_int.nit:18,1--14: Warning: expression is already not null, since it is a `Int`.
+base_as_notnull_int.nit:20,1--15: Warning: expression is already not null, since it is a `Object`.
+1
+1
+1
index 3919001..478efb4 100644 (file)
@@ -106,6 +106,7 @@ alt/error_expr_not_ok_alt4.nit:147,7--18: Type error: expected A, got Array[Int]
 alt/error_expr_not_ok_alt4.nit:149,7--24: Type error: expected A, got String
 alt/error_expr_not_ok_alt4.nit:150,7--18: Warning: Expression is already a Int.
 alt/error_expr_not_ok_alt4.nit:150,7--18: Type error: expected A, got Int
+alt/error_expr_not_ok_alt4.nit:151,7--23: Warning: expression is already not null, since it is a `Int`.
 alt/error_expr_not_ok_alt4.nit:151,7--23: Type error: expected A, got Int
 alt/error_expr_not_ok_alt4.nit:152,7--18: Warning: Expression is already a Int.
 alt/error_expr_not_ok_alt4.nit:152,7--18: Type error: expected A, got Bool
index d9dd373..23a09f5 100644 (file)
@@ -101,6 +101,7 @@ alt/error_expr_not_ok_alt5.nit:147,7--18: Type error: expected A, got Array[Int]
 alt/error_expr_not_ok_alt5.nit:149,7--24: Type error: expected A, got String
 alt/error_expr_not_ok_alt5.nit:150,7--18: Warning: Expression is already a Int.
 alt/error_expr_not_ok_alt5.nit:150,7--18: Type error: expected A, got Int
+alt/error_expr_not_ok_alt5.nit:151,7--23: Warning: expression is already not null, since it is a `Int`.
 alt/error_expr_not_ok_alt5.nit:151,7--23: Type error: expected A, got Int
 alt/error_expr_not_ok_alt5.nit:152,7--18: Warning: Expression is already a Int.
 alt/error_expr_not_ok_alt5.nit:152,7--18: Type error: expected A, got Bool
index 212ed6f..7dbdd2f 100644 (file)
@@ -105,6 +105,7 @@ alt/error_expr_not_ok_alt6.nit:147,7--18: Type error: expected A, got Array[Int]
 alt/error_expr_not_ok_alt6.nit:149,7--24: Type error: expected A, got String
 alt/error_expr_not_ok_alt6.nit:150,7--18: Warning: Expression is already a Int.
 alt/error_expr_not_ok_alt6.nit:150,7--18: Type error: expected A, got Int
+alt/error_expr_not_ok_alt6.nit:151,7--23: Warning: expression is already not null, since it is a `Int`.
 alt/error_expr_not_ok_alt6.nit:151,7--23: Type error: expected A, got Int
 alt/error_expr_not_ok_alt6.nit:152,7--18: Warning: Expression is already a Int.
 alt/error_expr_not_ok_alt6.nit:152,7--18: Type error: expected A, got Bool