From 7199fb501a1df07b8adaa7d2a9dc4c3bcffae772 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 3 Jun 2015 10:24:41 -0400 Subject: [PATCH] tests: add base_attr_abstract[34].nit Signed-off-by: Jean Privat --- tests/base_attr_abstract3.nit | 76 +++++++++++++++++++++++++++++++++++++ tests/base_attr_abstract4.nit | 75 ++++++++++++++++++++++++++++++++++++ tests/sav/base_attr_abstract3.res | 9 +++++ tests/sav/base_attr_abstract4.res | 4 ++ 4 files changed, 164 insertions(+) create mode 100644 tests/base_attr_abstract3.nit create mode 100644 tests/base_attr_abstract4.nit create mode 100644 tests/sav/base_attr_abstract3.res create mode 100644 tests/sav/base_attr_abstract4.res diff --git a/tests/base_attr_abstract3.nit b/tests/base_attr_abstract3.nit new file mode 100644 index 0000000..d67a45f --- /dev/null +++ b/tests/base_attr_abstract3.nit @@ -0,0 +1,76 @@ +# 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 + var i: Int is abstract, autoinit + fun j: Int is abstract, autoinit + fun j=(o: Int) is abstract, autoinit +end + +class B + super A + var k: Int is abstract, autoinit + fun l: Int is abstract, autoinit + fun l=(o: Int) is abstract, autoinit +end + +class C + super B + redef fun i do + 'i'.output + return 1 + end + redef fun i=(o) do + 'i'.output + '='.output + o.output + end + redef fun j do + 'j'.output + return 2 + end + redef fun j=(o) do + 'j'.output + '='.output + o.output + end + redef fun k do + 'k'.output + return 3 + end + redef fun k=(o) + do + 'k'.output + '='.output + o.output + end + redef fun l do + 'l'.output + return 4 + end + redef fun l=(o) do + 'l'.output + '='.output + o.output + end +end + +var c = new C(10,20,30,40) +'\n'.output +c.i.output +c.j.output +c.k.output +c.l.output diff --git a/tests/base_attr_abstract4.nit b/tests/base_attr_abstract4.nit new file mode 100644 index 0000000..876b85a --- /dev/null +++ b/tests/base_attr_abstract4.nit @@ -0,0 +1,75 @@ +# 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 + var i: Int is abstract + fun j: Int is abstract + fun j=(o: Int) is abstract +end + +class B + super A + var k: Int is abstract + fun l: Int is abstract + fun l=(o: Int) is abstract +end + +class C + super B + redef fun i do + 'i'.output + return 1 + end + redef fun i=(o) do + 'i'.output + '='.output + o.output + end + redef fun j do + 'j'.output + return 2 + end + redef fun j=(o) do + 'j'.output + '='.output + o.output + end + redef fun k do + 'k'.output + return 3 + end + redef fun k=(o) + do + 'k'.output + '='.output + o.output + end + redef fun l do + 'l'.output + return 4 + end + redef fun l=(o) do + 'l'.output + '='.output + o.output + end +end + +var c = new C +c.i.output +c.j.output +c.k.output +c.l.output diff --git a/tests/sav/base_attr_abstract3.res b/tests/sav/base_attr_abstract3.res new file mode 100644 index 0000000..d328d13 --- /dev/null +++ b/tests/sav/base_attr_abstract3.res @@ -0,0 +1,9 @@ +i=10 +jj=20 +k=30 +ll=40 + +i1 +j2 +k3 +l4 diff --git a/tests/sav/base_attr_abstract4.res b/tests/sav/base_attr_abstract4.res new file mode 100644 index 0000000..4d4bee4 --- /dev/null +++ b/tests/sav/base_attr_abstract4.res @@ -0,0 +1,4 @@ +i1 +j2 +k3 +l4 -- 1.7.9.5