From c68edb3eb949883b2c9b640861e602468c52bdad Mon Sep 17 00:00:00 2001 From: Delja Date: Sun, 16 Aug 2020 18:42:34 -0400 Subject: [PATCH] tests: Add contract test Add contract test when the `null` parameter is omitted. Signed-off-by: Delja --- tests/contracts_null_parameter.nit | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/contracts_null_parameter.nit diff --git a/tests/contracts_null_parameter.nit b/tests/contracts_null_parameter.nit new file mode 100644 index 0000000..da7c073 --- /dev/null +++ b/tests/contracts_null_parameter.nit @@ -0,0 +1,31 @@ +# 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. + +class A + + var null_attribut: nullable Int + + fun set_null_attribut(i: nullable Int) + is + ensure(null_attribut == i) + do + null_attribut = i + end +end + + +var a = new A +a.set_null_attribut +a.set_null_attribut(10) +a.set_null_attribut -- 1.7.9.5