From: Jean Privat Date: Mon, 21 Jul 2014 18:57:49 +0000 (-0400) Subject: tests: add base_attr_readonly X-Git-Tag: v0.6.7~31^2 X-Git-Url: http://nitlanguage.org tests: add base_attr_readonly Signed-off-by: Jean Privat --- diff --git a/tests/base_attr_readonly.nit b/tests/base_attr_readonly.nit new file mode 100644 index 0000000..7b6ef58 --- /dev/null +++ b/tests/base_attr_readonly.nit @@ -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 index 0000000..d00491f --- /dev/null +++ b/tests/sav/base_attr_readonly.res @@ -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 index 0000000..7405b6f --- /dev/null +++ b/tests/sav/base_attr_readonly_alt1.res @@ -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 index 0000000..00750ed --- /dev/null +++ b/tests/sav/base_attr_readonly_alt2.res @@ -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 index 0000000..5c34535 --- /dev/null +++ b/tests/sav/base_attr_readonly_alt3.res @@ -0,0 +1 @@ +alt/base_attr_readonly_alt3.nit:25,17--24: Error: a readonly attribute needs a value