nitunit: update tests.
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 2 Sep 2014 15:43:42 +0000 (11:43 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 2 Sep 2014 15:43:42 +0000 (11:43 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

tests/niti.skip
tests/nitunit.args
tests/sav/nitunit_args1.res
tests/sav/nitunit_args2.res [new file with mode: 0644]
tests/sav/nitunit_args3.res [new file with mode: 0644]
tests/test_nitunit.nit
tests/test_test_nitunit.nit [new file with mode: 0644]

index f09cabb..db41ecd 100644 (file)
@@ -20,3 +20,5 @@ nitcc_parser_gen
 mnit
 emscripten
 nitserial_args
+nitunit_args2
+nitunit_args3
index 7572830..cc7239d 100644 (file)
@@ -1 +1,3 @@
 test_nitunit.nit --no-color -o $WRITE
+test_nitunit.nit --gen-suite --only-show
+test_nitunit.nit --gen-suite --only-show --private
index bf738b9..e115c1d 100644 (file)
@@ -1,12 +1,20 @@
 test_nitunit.nit:20,1--22,0: ERROR: test_nitunit.test_nitunit::X.<class> (in .nitunit/test_nitunit2.nit): Runtime error: Assert failed (.nitunit/test_nitunit2.nit:5)
 
-test_nitunit.nit:23,2--25,0: FAILURE: test_nitunit.test_nitunit::X.test_nitunit::X::toto (in .nitunit/test_nitunit3.nit): .nitunit/test_nitunit3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
+test_nitunit.nit:23,2--25,0: FAILURE: test_nitunit.test_nitunit::X.test_nitunit::X::foo (in .nitunit/test_nitunit3.nit): .nitunit/test_nitunit3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
+
+test_test_nitunit.nit:36,2--40,4: ERROR: test_foo1 (in file .nitunit/test_test_nitunit_TestX_test_foo1.nit): Runtime error: Assert failed (test_test_nitunit.nit:39)
 
 Results saved in out/nitunit_args1.write
-Entities: 3; Documented ones: 3; With nitunits: 3; Failures: 2
+
+DocUnits:
+Entities: 27; Documented ones: 3; With nitunits: 3; Failures: 2
+
+TestSuites:
+Class suites: 1; Test Cases: 3; Failures: 1
 <testsuites><testsuite package="test_nitunit"><testcase classname="test_nitunit.&lt;module&gt;" name="&lt;module&gt;"><system-err></system-err><system-out>assert true
 </system-out></testcase><testcase classname="test_nitunit.test_nitunit::X" name="&lt;class&gt;"><system-err></system-err><system-out>assert false
 </system-out><error message="Runtime error: Assert failed (.nitunit/test_nitunit2.nit:5)
-"></error></testcase><testcase classname="test_nitunit.test_nitunit::X" name="test_nitunit::X::toto"><system-err></system-err><system-out>assert undefined_identifier
+"></error></testcase><testcase classname="test_nitunit.test_nitunit::X" name="test_nitunit::X::foo"><system-err></system-err><system-out>assert undefined_identifier
 </system-out><failure message=".nitunit/test_nitunit3.nit:5,8--27: Error: Method or variable 'undefined_identifier' unknown in Sys.
-"></failure></testcase></testsuite></testsuites>
\ No newline at end of file
+"></failure></testcase></testsuite><testsuite package="test_test_nitunit"><testcase classname="test_test_nitunit.test_test_nitunit::TestX" name="test_test_nitunit::TestX::test_foo"><system-err></system-err><system-out>out</system-out></testcase><testcase classname="test_test_nitunit.test_test_nitunit::TestX" name="test_test_nitunit::TestX::test_foo1"><system-err></system-err><system-out>out</system-out><error message="Runtime error: Assert failed (test_test_nitunit.nit:39)
+"></error></testcase><testcase classname="test_test_nitunit.test_test_nitunit::TestX" name="test_test_nitunit::TestX::test_foo2"><system-err></system-err><system-out>out</system-out></testcase></testsuite></testsuites>
\ No newline at end of file
diff --git a/tests/sav/nitunit_args2.res b/tests/sav/nitunit_args2.res
new file mode 100644 (file)
index 0000000..bc00752
--- /dev/null
@@ -0,0 +1,229 @@
+module test_test_nitunit is test_suite
+
+import test_suite
+import test_nitunit
+
+class TestX
+       super TestSuite
+
+       fun test_foo do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               subject.foo
+       end
+
+       fun test_foo1 do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               var a: Int
+               var b: Int
+               subject.foo1(a, b)
+       end
+
+       fun test_foo3 do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               var exp: Y[X]
+               var res = subject.foo3
+               assert exp == res
+       end
+end
+
+class TestY
+       super TestSuite
+
+       fun test_bra do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject[e]
+               assert exp == res
+       end
+
+       fun test_bra_assign do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var i: Int
+               subject[e] = i
+       end
+
+       fun test_plus do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject + e
+               assert exp == res
+       end
+
+       fun test_minus do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject - e
+               assert exp == res
+       end
+
+       fun test_star do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject * e
+               assert exp == res
+       end
+
+       fun test_slash do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject / e
+               assert exp == res
+       end
+
+       fun test_percent do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject % e
+               assert exp == res
+       end
+
+       fun test_unary_minus do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var exp: Int
+               var res = -subject
+               assert exp == res
+       end
+
+       fun test_equals do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: nullable Object
+               var exp: Bool
+               var res = subject == e
+               assert exp == res
+       end
+
+       fun test_not_equals do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: nullable Object
+               var exp: Bool
+               var res = subject != e
+               assert exp == res
+       end
+
+       fun test_lt do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject < e
+               assert exp == res
+       end
+
+       fun test_le do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject <= e
+               assert exp == res
+       end
+
+       fun test_compare do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject <=> e
+               assert exp == res
+       end
+
+       fun test_ge do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject >= e
+               assert exp == res
+       end
+
+       fun test_gt do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject > e
+               assert exp == res
+       end
+end
+
+class TestZ
+       super TestSuite
+
+       fun test_bra do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               var exp: Bool
+               var res = subject[i, j]
+               assert exp == res
+       end
+
+       fun test_bra_assign do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               var k: Bool
+               subject[i, j] = k
+       end
+
+       fun test_foo= do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               subject.foo(i) = j
+       end
+
+       fun test_bar= do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               var k: Int
+               subject.bar(i, j) = k
+       end
+end
diff --git a/tests/sav/nitunit_args3.res b/tests/sav/nitunit_args3.res
new file mode 100644 (file)
index 0000000..e93c6ca
--- /dev/null
@@ -0,0 +1,246 @@
+module test_test_nitunit is test_suite
+
+import test_suite
+intrude import test_nitunit
+
+class TestX
+       super TestSuite
+
+       fun test_foo do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               subject.foo
+       end
+
+       fun test_foo1 do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               var a: Int
+               var b: Int
+               subject.foo1(a, b)
+       end
+
+       fun test_foo2 do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               var exp: Bool
+               var res = subject.foo2
+               assert exp == res
+       end
+
+       fun test_foo3 do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               var exp: Y[X]
+               var res = subject.foo3
+               assert exp == res
+       end
+
+       fun test_foo3= do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: X
+               var foo3: Y[X]
+               subject.foo3 = foo3
+       end
+end
+
+class TestY
+       super TestSuite
+
+       fun test_bra do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject[e]
+               assert exp == res
+       end
+
+       fun test_bra_assign do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var i: Int
+               subject[e] = i
+       end
+
+       fun test_plus do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject + e
+               assert exp == res
+       end
+
+       fun test_minus do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject - e
+               assert exp == res
+       end
+
+       fun test_star do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject * e
+               assert exp == res
+       end
+
+       fun test_slash do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject / e
+               assert exp == res
+       end
+
+       fun test_percent do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Int
+               var res = subject % e
+               assert exp == res
+       end
+
+       fun test_unary_minus do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var exp: Int
+               var res = -subject
+               assert exp == res
+       end
+
+       fun test_equals do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: nullable Object
+               var exp: Bool
+               var res = subject == e
+               assert exp == res
+       end
+
+       fun test_not_equals do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: nullable Object
+               var exp: Bool
+               var res = subject != e
+               assert exp == res
+       end
+
+       fun test_lt do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject < e
+               assert exp == res
+       end
+
+       fun test_le do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject <= e
+               assert exp == res
+       end
+
+       fun test_compare do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject <=> e
+               assert exp == res
+       end
+
+       fun test_ge do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject >= e
+               assert exp == res
+       end
+
+       fun test_gt do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Y[X]
+               var e: Int
+               var exp: Bool
+               var res = subject > e
+               assert exp == res
+       end
+end
+
+class TestZ
+       super TestSuite
+
+       fun test_bra do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               var exp: Bool
+               var res = subject[i, j]
+               assert exp == res
+       end
+
+       fun test_bra_assign do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               var k: Bool
+               subject[i, j] = k
+       end
+
+       fun test_foo= do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               subject.foo(i) = j
+       end
+
+       fun test_bar= do
+               assert not_implemented: false # TODO remove once implemented
+
+               var subject: Z
+               var i: Int
+               var j: Int
+               var k: Int
+               subject.bar(i, j) = k
+       end
+end
index 4afd56d..b583197 100644 (file)
@@ -22,5 +22,39 @@ module test_nitunit
 class X
        # a 'failure' unit test (does not compile)
        #     assert undefined_identifier
-       fun toto do end
+       fun foo do end
+
+       fun foo1(a, b: Int) do end
+
+       private fun foo2: Bool do return true
+
+       var foo3: Y[X] = new Y[X]
+end
+
+class Y[E: X]
+       fun [](e: Int): Int do return e
+       fun []=(e, i: Int) do end
+
+       fun +(e: Int): Int do return e
+       fun -(e: Int): Int do return e
+       fun *(e: Int): Int do return e
+       fun /(e: Int): Int do return e
+       fun %(e: Int): Int do return e
+       fun -: Int do return -1
+
+       redef fun ==(e) do return true
+       redef fun !=(e) do return true
+
+       fun <(e: Int): Bool do return true
+       fun <=(e: Int): Bool do return true
+       fun <=>(e: Int): Bool do return true
+       fun >=(e: Int): Bool do return true
+       fun >(e: Int): Bool do return true
+end
+
+class Z
+       fun [](i, j: Int): Bool do return true
+       fun []=(i, j: Int, k: Bool) do end
+       fun foo=(i, j: Int) do end
+       fun bar=(i, j, k: Int) do end
 end
diff --git a/tests/test_test_nitunit.nit b/tests/test_test_nitunit.nit
new file mode 100644 (file)
index 0000000..71ce971
--- /dev/null
@@ -0,0 +1,45 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Copyright 2004-2008 Jean Privat <jean@pryen.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.
+
+# NitUnit file for test_nitunit module.
+module test_test_nitunit is test_suite
+
+import test_suite
+intrude import test_nitunit
+
+class TestX
+       super TestSuite
+
+       var subject: X is noinit
+
+       redef fun before_test do
+               subject = new X
+       end
+
+       fun test_foo do
+               subject.foo
+       end
+
+       # will fail
+       fun test_foo1 do
+               subject.foo1(10, 20)
+               assert false
+       end
+
+       fun test_foo2 do
+               assert subject.foo2
+       end
+end