From: Jean Privat Date: Fri, 26 Feb 2016 21:06:56 +0000 (-0500) Subject: tests: add base_attr_optional.nit X-Git-Url: http://nitlanguage.org tests: add base_attr_optional.nit Signed-off-by: Jean Privat --- diff --git a/tests/base_attr_optional.nit b/tests/base_attr_optional.nit new file mode 100644 index 0000000..4417afe --- /dev/null +++ b/tests/base_attr_optional.nit @@ -0,0 +1,43 @@ +# 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 A + var i: Int = 99 is optional + + var o: Object = 999 is optional +end + +var a = new A +a.i.output +a.o.output + +a.i = 1 +a.o = 10 +a.i.output +a.o.output + +a.i = null +a.o = null +a.i.output +a.o.output + +a = new A(2) +a.i.output +a.o.output + +a = new A(3, true) +a.i.output +a.o.output diff --git a/tests/sav/base_attr_optional.res b/tests/sav/base_attr_optional.res new file mode 100644 index 0000000..c879e94 --- /dev/null +++ b/tests/sav/base_attr_optional.res @@ -0,0 +1,10 @@ +99 +999 +1 +10 +99 +999 +2 +999 +3 +true