tests: Add contract test
authorDelja <deljarry.florian@gmail.com>
Sun, 16 Aug 2020 22:42:34 +0000 (18:42 -0400)
committerDelja <deljarry.florian@gmail.com>
Mon, 16 Nov 2020 20:10:16 +0000 (15:10 -0500)
Add contract test when the `null` parameter is omitted.

Signed-off-by: Delja <deljarry.florian@gmail.com>

tests/contracts_null_parameter.nit [new file with mode: 0644]

diff --git a/tests/contracts_null_parameter.nit b/tests/contracts_null_parameter.nit
new file mode 100644 (file)
index 0000000..da7c073
--- /dev/null
@@ -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