tests: add base_attr_readonly
authorJean Privat <jean@pryen.org>
Mon, 21 Jul 2014 18:57:49 +0000 (14:57 -0400)
committerJean Privat <jean@pryen.org>
Tue, 22 Jul 2014 03:15:36 +0000 (23:15 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_attr_readonly.nit [new file with mode: 0644]
tests/sav/base_attr_readonly.res [new file with mode: 0644]
tests/sav/base_attr_readonly_alt1.res [new file with mode: 0644]
tests/sav/base_attr_readonly_alt2.res [new file with mode: 0644]
tests/sav/base_attr_readonly_alt3.res [new file with mode: 0644]

diff --git a/tests/base_attr_readonly.nit b/tests/base_attr_readonly.nit
new file mode 100644 (file)
index 0000000..7b6ef58
--- /dev/null
@@ -0,0 +1,29 @@
+# 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 Foo
+       var a1 = 1 is readonly
+       fun run
+       do
+               #alt1#a1 = 2
+               #alt2#_a1 = 3 #hack
+               a1.output
+       end
+       #alt3# var a2: Int is readonly
+end
+
+var f = new Foo
+f.run
diff --git a/tests/sav/base_attr_readonly.res b/tests/sav/base_attr_readonly.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/base_attr_readonly_alt1.res b/tests/sav/base_attr_readonly_alt1.res
new file mode 100644 (file)
index 0000000..7405b6f
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_readonly_alt1.nit:21,3--8: Error: Method or variable 'a1=' unknown in Foo.
diff --git a/tests/sav/base_attr_readonly_alt2.res b/tests/sav/base_attr_readonly_alt2.res
new file mode 100644 (file)
index 0000000..00750ed
--- /dev/null
@@ -0,0 +1 @@
+3
diff --git a/tests/sav/base_attr_readonly_alt3.res b/tests/sav/base_attr_readonly_alt3.res
new file mode 100644 (file)
index 0000000..5c34535
--- /dev/null
@@ -0,0 +1 @@
+alt/base_attr_readonly_alt3.nit:25,17--24: Error: a readonly attribute needs a value