nitunit: add a test to show how non-local redefinition of before/after methods should...
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 15 Dec 2015 22:04:02 +0000 (17:04 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 15 Dec 2015 22:04:02 +0000 (17:04 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

tests/nitunit.args
tests/sav/nitunit_args9.res [new file with mode: 0644]
tests/test_nitunit4/nitunit4.nit [new file with mode: 0644]
tests/test_nitunit4/test_nitunit4.nit [new file with mode: 0644]
tests/test_nitunit4/test_nitunit4_base.nit [new file with mode: 0644]

index 2d7d624..390709a 100644 (file)
@@ -6,3 +6,4 @@ test_doc2.nit --no-color -o $WRITE
 test_nitunit3 --no-color -o $WRITE
 test_nitunit_md.md --no-color -o $WRITE
 test_doc3.nit --no-color -o $WRITE
+test_nitunit4 --no-color -o $WRITE
diff --git a/tests/sav/nitunit_args9.res b/tests/sav/nitunit_args9.res
new file mode 100644 (file)
index 0000000..55f831f
--- /dev/null
@@ -0,0 +1,16 @@
+test_nitunit4/test_nitunit4.nit:22,2--25,4: ERROR: test_foo (in file .nitunit/gen_test_nitunit4.nit): Before Test
+Tested method
+After Test
+Runtime error: Assert failed (test_nitunit4/test_nitunit4_base.nit:31)
+
+DocUnits:
+No doc units found
+Entities: 10; Documented ones: 0; With nitunits: 0; Failures: 0
+
+TestSuites:
+Class suites: 1; Test Cases: 1; Failures: 1
+<testsuites><testsuite package="test_nitunit4"></testsuite><testsuite package="test_nitunit4"></testsuite><testsuite></testsuite><testsuite package="test_nitunit4::nitunit4"></testsuite><testsuite package="test_nitunit4"><testcase classname="nitunit.test_nitunit4.test_nitunit4::TestTestSuite" name="test_nitunit4::TestTestSuite::test_foo"><system-err></system-err><system-out>out</system-out><error message="Before Test
+Tested method
+After Test
+Runtime error: Assert failed (test_nitunit4&#47;test_nitunit4_base.nit:31)
+"></error></testcase></testsuite><testsuite package="test_nitunit4::test_nitunit4_base"></testsuite><testsuite></testsuite></testsuites>
\ No newline at end of file
diff --git a/tests/test_nitunit4/nitunit4.nit b/tests/test_nitunit4/nitunit4.nit
new file mode 100644 (file)
index 0000000..43723c6
--- /dev/null
@@ -0,0 +1,15 @@
+# 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.
+
+module nitunit4
diff --git a/tests/test_nitunit4/test_nitunit4.nit b/tests/test_nitunit4/test_nitunit4.nit
new file mode 100644 (file)
index 0000000..db734a6
--- /dev/null
@@ -0,0 +1,26 @@
+# 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.
+
+module test_nitunit4 is test_suite
+
+import test_nitunit4_base
+
+class TestTestSuite
+       super SuperTestSuite
+
+       fun test_foo do
+               print "Tested method"
+               assert before
+       end
+end
diff --git a/tests/test_nitunit4/test_nitunit4_base.nit b/tests/test_nitunit4/test_nitunit4_base.nit
new file mode 100644 (file)
index 0000000..3e7a1e7
--- /dev/null
@@ -0,0 +1,33 @@
+# 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.
+
+module test_nitunit4_base is test_suite
+
+import test_suite
+
+class SuperTestSuite
+       super TestSuite
+
+       var before = false
+
+       redef fun before_test do
+               print "Before Test"
+               before = true
+       end
+
+       redef fun after_test do
+               print "After Test"
+               assert false
+       end
+end