tests: new tests base_adaptive_loop_null2.nit base_adaptive_loop_isa.nit
authorJean Privat <jean@pryen.org>
Thu, 18 Jun 2015 02:12:29 +0000 (22:12 -0400)
committerJean Privat <jean@pryen.org>
Thu, 18 Jun 2015 03:09:10 +0000 (23:09 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_adaptive_loop_isa.nit [new file with mode: 0644]
tests/base_adaptive_loop_null2.nit [new file with mode: 0644]
tests/sav/base_adaptive_loop_isa.res [new file with mode: 0644]
tests/sav/base_adaptive_loop_isa_alt1.res [new file with mode: 0644]
tests/sav/base_adaptive_loop_null2.res [new file with mode: 0644]
tests/sav/base_adaptive_loop_null2_alt1.res [new file with mode: 0644]
tests/sav/base_adaptive_loop_null_alt1.res

diff --git a/tests/base_adaptive_loop_isa.nit b/tests/base_adaptive_loop_isa.nit
new file mode 100644 (file)
index 0000000..26af488
--- /dev/null
@@ -0,0 +1,52 @@
+# 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 standard::kernel
+
+
+interface A
+end
+
+class B
+       super A
+       var next: A
+end
+
+class C
+       super A
+end
+
+class D
+       super A
+end
+
+fun foo(a: A): Int
+do
+       var i = 0
+       if a isa B then while i < 10 do
+               i += 1
+
+               if a isa C then return i
+               if not a isa B then return -i
+               a = a.next #alt1#
+       end
+       return i
+end
+
+var c = new C
+var b = new B(c)
+var bd = new B(new D)
+foo(c).output
+foo(b).output
+foo(bd).output
diff --git a/tests/base_adaptive_loop_null2.nit b/tests/base_adaptive_loop_null2.nit
new file mode 100644 (file)
index 0000000..40f5674
--- /dev/null
@@ -0,0 +1,59 @@
+# 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 standard::kernel
+
+var x
+x = null
+
+var i = 0
+while i < 2 do
+       var y
+       y = x
+       if y == null then 1.output
+       y = x
+       if y != null then 2.output
+       y = x
+       if y isa Int then 3.output
+       y = x
+       if y isa nullable Int then 4.output
+       y = x
+       if y isa nullable Bool then 5.output
+       y = x or else 6
+       y.output
+       #alt1#x = 1
+
+       i += 1
+end
+
+x = 10
+i = 0
+while i < 2 do
+       var y
+       y = x
+       if y == null then 1.output
+       y = x
+       if y != null then 2.output
+       y = x
+       if y isa Int then 3.output
+       y = x
+       if y isa nullable Int then 4.output
+       y = x
+       if y isa nullable Bool then 5.output
+       y = x or else 6
+       y.output
+       #alt1#x = null
+
+       i += 1
+end
diff --git a/tests/sav/base_adaptive_loop_isa.res b/tests/sav/base_adaptive_loop_isa.res
new file mode 100644 (file)
index 0000000..7c0510a
--- /dev/null
@@ -0,0 +1,3 @@
+0
+2
+-2
diff --git a/tests/sav/base_adaptive_loop_isa_alt1.res b/tests/sav/base_adaptive_loop_isa_alt1.res
new file mode 100644 (file)
index 0000000..a9f3a8f
--- /dev/null
@@ -0,0 +1,4 @@
+alt/base_adaptive_loop_isa_alt1.nit:41,10--16: Warning: expression is already a `B`.
+0
+10
+10
diff --git a/tests/sav/base_adaptive_loop_null2.res b/tests/sav/base_adaptive_loop_null2.res
new file mode 100644 (file)
index 0000000..741dade
--- /dev/null
@@ -0,0 +1,26 @@
+base_adaptive_loop_null2.nit:24,5: Warning: expression is always `null`.
+base_adaptive_loop_null2.nit:26,5: Warning: expression is always `null`.
+base_adaptive_loop_null2.nit:30,5--22: Warning: expression is already a `nullable Int` since it is a `null`.
+base_adaptive_loop_null2.nit:32,5--23: Warning: expression is already a `nullable Bool` since it is a `null`.
+base_adaptive_loop_null2.nit:33,6: Warning: expression is always `null`.
+base_adaptive_loop_null2.nit:45,5: Warning: expression is not null, since it is a `Int`.
+base_adaptive_loop_null2.nit:47,5: Warning: expression is not null, since it is a `Int`.
+base_adaptive_loop_null2.nit:49,5--13: Warning: expression is already a `Int`.
+base_adaptive_loop_null2.nit:51,5--22: Warning: expression is already a `nullable Int` since it is a `Int`.
+base_adaptive_loop_null2.nit:54,6: Warning: expression is not null, since it is a `Int`.
+1
+4
+5
+6
+1
+4
+5
+6
+2
+3
+4
+10
+2
+3
+4
+10
diff --git a/tests/sav/base_adaptive_loop_null2_alt1.res b/tests/sav/base_adaptive_loop_null2_alt1.res
new file mode 100644 (file)
index 0000000..e8a4e3a
--- /dev/null
@@ -0,0 +1,18 @@
+alt/base_adaptive_loop_null2_alt1.nit:30,5--22: Warning: expression is already a `nullable Int`.
+alt/base_adaptive_loop_null2_alt1.nit:51,5--22: Warning: expression is already a `nullable Int`.
+1
+4
+5
+6
+2
+3
+4
+1
+2
+3
+4
+10
+1
+4
+5
+6
index 573541a..e4d78f8 100644 (file)
@@ -1 +1,2 @@
+alt/base_adaptive_loop_null_alt1.nit:23,7: Warning: expression is always `null`.
 0