tests: add syntax_callref.nit
authorJean Privat <jean@pryen.org>
Tue, 9 Jul 2019 15:11:03 +0000 (11:11 -0400)
committerJean Privat <jean@pryen.org>
Tue, 13 Aug 2019 15:02:28 +0000 (11:02 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/sav/syntax_callref.res [new file with mode: 0644]
tests/sav/syntax_callref_alt1.res [new file with mode: 0644]
tests/syntax_callref.nit [new file with mode: 0644]

diff --git a/tests/sav/syntax_callref.res b/tests/sav/syntax_callref.res
new file mode 100644 (file)
index 0000000..c3ae17c
--- /dev/null
@@ -0,0 +1,11 @@
+syntax_callref.nit:40,5--8: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:41,5--12: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:42,5--16: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:43,6--13: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:44,5--18: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:48,5--10: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:49,5--14: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:50,5--18: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:51,6--15: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:52,5--20: Error: NOT YET IMPLEMENTED callref expressions.
+syntax_callref.nit:54,5--11: Error: NOT YET IMPLEMENTED callref expressions.
diff --git a/tests/sav/syntax_callref_alt1.res b/tests/sav/syntax_callref_alt1.res
new file mode 100644 (file)
index 0000000..253e163
--- /dev/null
@@ -0,0 +1 @@
+alt/syntax_callref_alt1.nit:47,5--6: Error: `y` is a variable, not a method.
diff --git a/tests/syntax_callref.nit b/tests/syntax_callref.nit
new file mode 100644 (file)
index 0000000..074c7c7
--- /dev/null
@@ -0,0 +1,54 @@
+# 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.
+
+redef class Object
+       fun foo: Object
+       do
+               print "foo{self}"
+               return self
+       end
+       fun bar: Object
+       do
+               print "baz{self}"
+               return self
+       end
+       fun baz: Object
+       do
+               print "baz{self}"
+               return self
+       end
+end
+
+class Y
+       var quux: Object = self
+end
+
+var x
+
+# self is the implicit receiver
+x = &foo
+x = &foo.bar
+x = &foo.bar.baz
+x = (&foo.bar).baz
+x = &(foo.bar).baz
+
+var y = new Y
+#alt1#x = &y # error since y is a variable
+x = &y.foo
+x = &y.foo.bar
+x = &y.foo.bar.baz
+x = (&y.foo.bar).baz
+x = &(y.foo.bar).baz
+
+x = &y.quux