tmpscZSVg/0000755000175000017500000000000012777131552012022 5ustar vsevavsevatmpscZSVg/LICENSE.txt0000644000175000017500000000254712777131552013655 0ustar vsevavsevaThis software is distributed under the BSD License. Copyright (c) 2005-2014, Philippe Fremy All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. tmpscZSVg/README.md0000644000175000017500000001556012777131552013310 0ustar vsevavseva## LuaUnit by Philippe Fremy [![Build status](https://ci.appveyor.com/api/projects/status/us6uh4e5q597jj54?svg=true&passingText=Windows%20Build%20passing&failingText=Windows%20Build%20failed)](https://ci.appveyor.com/project/bluebird75/luaunit) [![Build Status](https://travis-ci.org/bluebird75/luaunit.svg?branch=master)](https://travis-ci.org/bluebird75/luaunit) [![Documentation Status](https://readthedocs.org/projects/luaunit/badge/?version=latest)](https://readthedocs.org/projects/luaunit/?badge=latest) LuaUnit is a unit-testing framework for Lua. It allows you to write test functions and test classes with test methods, combined with setup/teardown functionality. A wide range of assertions are supported. LuaUnit supports several output formats, like JUnit or TAP, for easier integration into Continuous Integration platforms (Jenkins, Maven, ...). The integrated command-line options provide a flexible interface to select tests by name or patterns, control output format, set verbosity, ... LuaUnit works with Lua 5.1, LuaJIT 2.0, LuaJIT 2.1 beta, Lua 5.2 and Lua 5.3 . It is tested on Windows Seven, Windows Server 2012 R2 (x64) and Ubuntu 14.04 (see continuous build results on [Travis-CI](https://travis-ci.org/bluebird75/luaunit) and [AppVeyor](https://ci.appveyor.com/project/bluebird75/luaunit) ) and should work on all platforms supported by Lua. It has no other dependency than Lua itself. LuaUnit is packed into a single-file. To make start using it, just add the file to your project. LuaUnit is maintained on github: https://github.com/bluebird75/luaunit For more information on LuaUnit development, please check: [Developing LuaUnit](http://luaunit.readthedocs.org/en/latest/#developing-luaunit) It is released under the BSD license. Documentation is available on [read-the-docs](http://luaunit.readthedocs.org/en/latest/) **Important note when upgrading to version 3.1 and above** : break of backward compatibility, assertions functions are no longer exported directly to the global namespace. See [documentation](http://luaunit.readthedocs.io/en/latest/#luaunit-global-asserts) on how to adjust or restore previous behavior. ##Install The version in development on github is always stable and can be used safely. **github** The simplest way to install LuaUnit is to fetch the github version: git clone git@github.com:bluebird75/luaunit.git Then copy the file luaunit.lua into your project or the Lua libs directory. On Linux, you can also install it into your Lua directories sudo python doit.py install Edit `install()` for Lua version and installation directory if that fails. It uses, by default, Linux paths that depend on the version. **bower** You can also install it with bower : bower install https://github.com/bluebird75/luaunit.git. **LuaRocks** LuaUnit v3.2 and above are available on LuaRocks. ##Contributors * [NiteHawk](https://github.com/n1tehawk) * [AbigailBuccaneer](https://github.com/AbigailBuccaneer) * [Juan Julián Merelo Guervós](https://github.com/JJ) * [Naoyuki Totani](https://github.com/ntotani) * [Jennal](https://github.com/Jennal) * [George Zhao](https://github.com/zhaozg) * kbuschelman * [Victor Seva](https://github.com/linuxmaniac) * [Urs Breu](https://github.com/ubreu) * Jim Anderson ### History #### Version 3.2 - 12. Jul 2016 * distinguish between failures (failed assertion) and errors * add command-line option to stop on first error or failure * support for new versions: Lua 5.3 and LuaJIT (2.0, 2.1 beta) * validation of all lua versions on Travis CI and AppVeyor * added compatibility layer with forked luaunit v2.x * added documentation about development process * improved support for table containing keys of type table * small bug fixes, several internal improvements #### Version 3.1 - 10 Mar. 2015 * luaunit no longer pollutes global namespace, unless defining EXPORT_ASSERT_TO_GLOBALS to true * fixes and validation of JUnit XML generation * strip luaunit internal information from stacktrace * general improvements of test results with duration and other details * improve printing for tables, with an option to always print table id * fix printing of recursive tables **Important note when upgrading to version 3.1** : assertions functions are no longer exported directly to the global namespace. See documentation for upgrade paths. #### Version 3.0 - 9. Oct 2014 Since some people have forked LuaUnit and release some 2.x version, I am jumping the version number. - moved to Github - full documentation available in text, html and pdf at read-the-docs.org - new output format: JUnit - much better table assertions - new assertions for strings, with patterns and case insensitivity: assertStrContains, assertNotStrContains, assertNotStrIContains, assertStrIContains, assertStrMatches - new assertions for floats: assertAlmostEquals, assertNotAlmostEquals - type assertions: assertIsString, assertIsNumber, ... - error assertions: assertErrorMsgEquals, assertErrorMsgContains, assertErrorMsgMatches - improved error messages for several assertions - command-line options to select test, control output type and verbosity #### Version 2.0 Unofficial fork from version 1.3 - lua 5.2 module style, without global namespace pollution - setUp() may be named Setup() or setup() - tearDown() may be named Teardown() or teardown() - wrapFunction() may be called WrapFunctions() or wrap_functions() - run() may also be called Run() - table deep comparision (also available in 1.4) - control verbosity with setVerbosity() SetVerbosity() and set_verbosity() - More assertions: + is, is_, assert and assert_ (e.g. assert( LuaUnit.isString( getString() ) ) + assertNot and assert_not_ #### Version 1.5 - 8. Nov 2012 - compatibility with Lua 5.1 and 5.2 - better object model internally - a lot more of internal tests - several internal bug fixes - make it easy to customize the test output - running test functions no longer requires a wrapper - several level of verbosity #### Version 1.4 - 26. Jul 2012 - table deep comparison - switch from X11 to more popular BSD license - add TAP output format for integration into Jenkins - official repository now on github #### Version 1.3 - 30. Oct 2007 - port to lua 5.1 - iterate over the test classes, methods and functions in the alphabetical order - change the default order of expected, actual in assertEquals (adjustable with USE_EXPECTED_ACTUAL_IN_ASSERT_EQUALS). #### Version 1.2 - 13. Jun 2005 - first public release #### Version 1.1 - move global variables to internal variables - assertion order is configurable between expected/actual or actual/expected - new assertion to check that a function call returns an error - display the calling stack when an error is spotted - two verbosity level, like in python unittest tmpscZSVg/run_functional_tests.lua0000644000175000017500000007733712777131552017016 0ustar vsevavseva#!/usr/bin/env lua require('os') local lu = require('luaunit') local function report( ... ) print('>>>>>>>', string.format(...)) end local function error_fmt( ... ) error(string.format(...), 2) -- (level 2 = report chunk calling error_fmt) end local IS_UNIX = ( package.config:sub(1,1) == '/' ) local LUA='"'..arg[-1]..'"' -- Escape a string so it can safely be used as a Lua pattern without triggering -- special semantics. This means prepending any "magic" character ^$()%.[]*+-? -- with a percent sign. Note: We DON'T expect embedded NUL chars, and thus -- won't escape those (%z) for Lua 5.1. local LUA_MAGIC_CHARS = "[%^%$%(%)%%%.%[%]%*%+%-%?]" local function escape_lua_pattern(s) return s:gsub(LUA_MAGIC_CHARS, "%%%1") -- substitute with '%' + matched char end local function string_sub(s, orig, repl) -- replace occurrence of string orig by string repl -- just like string.gsub, but with no pattern matching return s:gsub( escape_lua_pattern(orig), repl ) end function testStringSub() lu.assertEquals( string_sub('aa a % b cc', 'a % b', 'a + b'), 'aa a + b cc' ) lu.assertEquals( string_sub('aa: ?cc', ': ?', 'xx?'), 'aaxx?cc' ) end local function osExec( ... ) -- execute a command with os.execute and return true if exit code is 0 -- false in any other conditions local cmd = string.format(...) if not(IS_UNIX) and cmd:sub(1, 1) == '"' then -- In case we're running on Windows, and if the command starts with a -- quote: It's reasonable (or even necessary in some cases) to enclose -- the entire command string in another pair of quotes. (This is needed -- to preserve other quotes, due to how os.execute makes use of cmd.exe) -- see e.g. http://lua-users.org/lists/lua-l/2014-06/msg00551.html cmd = '"' .. cmd .. '"' end -- print('osExec('..cmd..')') local exitSuccess, exitReason, exitCode = os.execute( cmd ) -- print('\n', exitSuccess, exitReason, exitCode) if _VERSION == 'Lua 5.1' then -- Lua 5.1 returns only the exit code exitReason = 'exit' if IS_UNIX then -- in C: exitCode = (exitSuccess >> 8) & 0xFF -- poor approximation that works: exitCode = (exitSuccess / 256) else -- Windows, life is simple exitCode = exitSuccess end end -- Use heuristics to determine negative exit codes, -- assuming that those are in the range -8 to -1: if exitCode >= 248 then exitCode = exitCode - 256 end -- Lua 5.2+ has a weird way of dealing with exit code -1, at least on Windows if exitReason == 'No error' then exitReason = 'exit' exitCode = -1 end if exitReason ~= 'exit' or exitCode ~= 0 then -- print('return false '..tostring(exitCode)) return false, exitCode end -- print('return true') return true, exitCode end local function osExpectedCodeExec( refExitCode, ... ) local cmd = string.format(...) local ret, exitCode = osExec( cmd ) if refExitCode and (exitCode ~= refExitCode) then error_fmt('Expected exit code %d, but got %d for: %s', refExitCode, exitCode, cmd) end return ret end local HAS_XMLLINT do local xmllint_output_fname = 'test/has_xmllint.txt' HAS_XMLLINT = osExec('xmllint --version 2> '..xmllint_output_fname) if not HAS_XMLLINT then report('WARNING: xmllint absent, can not validate xml validity') end os.remove(xmllint_output_fname) end local function adjustFile( fileOut, fileIn, pattern, mayBeAbsent, verbose ) --[[ Adjust the content of fileOut by copying lines matching pattern from fileIn fileIn lines are read and the first line matching pattern is analysed. The first pattern capture is memorized. fileOut lines are then read, and the first line matching pattern is modified, by applying the first capture of fileIn. fileOut is then rewritten. ]] local source = nil local idxStart, idxEnd, capture for line in io.lines(fileIn) do idxStart, idxEnd, capture = line:find( pattern ) if idxStart ~= nil then if capture == nil then error_fmt('Must specify a capture for pattern %s in function adjustFile()', pattern) end source = capture break end end if source == nil then if mayBeAbsent then return -- no capture, just return end error_fmt('No line in file %s matching pattern "%s"', fileIn, pattern) end if verbose then print('Captured in source: '.. source ) end local dest, linesOut = nil, {} for line in io.lines(fileOut) do idxStart, idxEnd, capture = line:find( pattern ) if idxStart ~= nil then dest = capture if verbose then print('Modifying line: '..line ) end line = string_sub(line, dest, source) -- line = line:sub(1,idxStart-1)..source..line:sub(idxEnd+1) -- string.gsub( line, dest, source ) if verbose then print('Result: '..line ) end end table.insert( linesOut, line ) end if dest == nil then if mayBeAbsent then return -- capture but nothing to adjust, just return end error_fmt('No line in file %s matching pattern "%s"', fileOut, pattern) end local f = io.open( fileOut, 'w') f:write(table.concat(linesOut, '\n'), '\n') f:close() end local function check_tap_output( fileToRun, options, output, refOutput, refExitCode ) -- remove output osExpectedCodeExec(refExitCode, '%s %s --output TAP %s > %s', LUA, fileToRun, options, output) adjustFile( output, refOutput, '# Started on (.*)') adjustFile( output, refOutput, '# Ran %d+ tests in (%d+.%d*).*') -- For Lua 5.3: stack trace uses "method" instead of "function" adjustFile( output, refOutput, '.*%.lua:%d+: in (%S*) .*', true, false ) if not osExec([[diff -NPw -u -I " *\.[/\\]luaunit.lua:[0123456789]\+:.*" %s %s]], refOutput, output) then error('TAP Output mismatch for file : '..output) end -- report('TAP Output ok: '..output) return 0 end local function check_text_output( fileToRun, options, output, refOutput, refExitCode ) -- remove output osExpectedCodeExec(refExitCode, '%s %s --output text %s > %s', LUA, fileToRun, options, output) if options:find( '--verbose' ) then adjustFile( output, refOutput, 'Started on (.*)') end adjustFile( output, refOutput, 'Ran .* tests in (%d.%d*) seconds' ) -- For Lua 5.3: stack trace uses "method" instead of "function" adjustFile( output, refOutput, '.*%.lua:%d+: in (%S*) .*', true, false ) if not osExec([[diff -NPw -u -I " *\.[/\\]luaunit.lua:[0123456789]\+:.*" %s %s]], refOutput, output) then error('Text Output mismatch for file : '..output) end -- report('Text Output ok: '..output) return 0 end local function check_nil_output( fileToRun, options, output, refOutput, refExitCode ) -- remove output osExpectedCodeExec(refExitCode, '%s %s --output nil %s > %s', LUA, fileToRun, options, output) if not osExec([[diff -NPw -u -I " *\.[/\\]luaunit.lua:[0123456789]\+:.*" %s %s]], refOutput, output) then error('NIL Output mismatch for file : '..output) end -- report('NIL Output ok: '..output) return 0 end local function check_xml_output( fileToRun, options, output, xmlOutput, xmlLintOutput, refOutput, refXmlOutput, refExitCode ) local retcode = 0 -- remove output osExpectedCodeExec(refExitCode, '%s %s %s --output junit --name %s > %s', LUA, fileToRun, options, xmlOutput, output) adjustFile( output, refOutput, '# XML output to (.*)') adjustFile( output, refOutput, '# Started on (.*)') adjustFile( output, refOutput, '# Ran %d+ tests in (%d+.%d*).*') adjustFile( xmlOutput, refXmlOutput, '.*') -- For Lua 5.3: stack trace uses "method" instead of "function" adjustFile( output, refOutput, '.*%.lua:%d+: in (%S*) .*', true, false ) adjustFile( xmlOutput, refXmlOutput, '.*%.lua:%d+: in (%S*) .*', true, false ) if HAS_XMLLINT then -- General xmllint validation if osExec('xmllint --noout %s > %s', xmlOutput, xmlLintOutput) then -- report('XMLLint validation ok: file %s', xmlLintOutput) else error_fmt('XMLLint reported errors : file %s', xmlLintOutput) retcode = retcode + 1 end -- Validation against apache junit schema if osExec('xmllint --noout --schema junitxml/junit-apache-ant.xsd %s 2> %s', xmlOutput, xmlLintOutput) then -- report('XMLLint validation ok: file %s', xmlLintOutput) else error_fmt('XMLLint reported errors against apache schema: file %s', xmlLintOutput) retcode = retcode + 1 end -- Validation against jenkins/hudson schema if osExec('xmllint --noout --schema junitxml/junit-jenkins.xsd %s 2> %s', xmlOutput, xmlLintOutput) then -- report('XMLLint validation ok: file %s', xmlLintOutput) else error_fmt('XMLLint reported errors against jenkins schema: file %s', xmlLintOutput) retcode = retcode + 1 end end -- ignore change in line numbers for luaunit if not osExec([[diff -NPw -u -I " *\.[/\\]luaunit.lua:[0123456789]\+:.*" %s %s]], refXmlOutput, xmlOutput) then error('XML content mismatch for file : '..xmlOutput) retcode = retcode + 1 end if not osExec([[diff -NPw -u -I " *\.[/\\]luaunit.lua:[0123456789]\+:.*" %s %s]], refOutput, output) then error('XML Output mismatch for file : '..output) retcode = retcode + 1 end --[[ if retcode == 0 then report('XML Output ok: '..output) end --]] return retcode end -- check tap output function testTapDefault() lu.assertEquals( 0, check_tap_output('example_with_luaunit.lua', '', 'test/exampleTapDefault.txt', 'test/ref/exampleTapDefault.txt', 12) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '', 'test/errFailPassTapDefault.txt', 'test/ref/errFailPassTapDefault.txt', 10 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '-p Succ', 'test/errFailPassTapDefault-success.txt', 'test/ref/errFailPassTapDefault-success.txt', 0 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '-p Succ -p Fail', 'test/errFailPassTapDefault-failures.txt', 'test/ref/errFailPassTapDefault-failures.txt', 5 ) ) end function testTapVerbose() lu.assertEquals( 0, check_tap_output('example_with_luaunit.lua', '--verbose', 'test/exampleTapVerbose.txt', 'test/ref/exampleTapVerbose.txt', 12 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '--verbose', 'test/errFailPassTapVerbose.txt', 'test/ref/errFailPassTapVerbose.txt', 10 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '--verbose -p Succ', 'test/errFailPassTapVerbose-success.txt', 'test/ref/errFailPassTapVerbose-success.txt', 0 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '--verbose -p Succ -p Fail', 'test/errFailPassTapVerbose-failures.txt', 'test/ref/errFailPassTapVerbose-failures.txt', 5 ) ) end function testTapQuiet() lu.assertEquals( 0, check_tap_output('example_with_luaunit.lua', '--quiet', 'test/exampleTapQuiet.txt', 'test/ref/exampleTapQuiet.txt', 12 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '--quiet', 'test/errFailPassTapQuiet.txt', 'test/ref/errFailPassTapQuiet.txt', 10 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ', 'test/errFailPassTapQuiet-success.txt', 'test/ref/errFailPassTapQuiet-success.txt', 0 ) ) lu.assertEquals( 0, check_tap_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ -p Fail', 'test/errFailPassTapQuiet-failures.txt', 'test/ref/errFailPassTapQuiet-failures.txt', 5 ) ) end -- check text output function testTextDefault() lu.assertEquals( 0, check_text_output('example_with_luaunit.lua', '', 'test/exampleTextDefault.txt', 'test/ref/exampleTextDefault.txt', 12 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '', 'test/errFailPassTextDefault.txt', 'test/ref/errFailPassTextDefault.txt', 10 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '-p Succ', 'test/errFailPassTextDefault-success.txt', 'test/ref/errFailPassTextDefault-success.txt', 0 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '-p Succ -p Fail', 'test/errFailPassTextDefault-failures.txt', 'test/ref/errFailPassTextDefault-failures.txt', 5 ) ) end function testTextVerbose() lu.assertEquals( 0, check_text_output('example_with_luaunit.lua', '--verbose', 'test/exampleTextVerbose.txt', 'test/ref/exampleTextVerbose.txt', 12 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--verbose', 'test/errFailPassTextVerbose.txt', 'test/ref/errFailPassTextVerbose.txt', 10 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--verbose -p Succ', 'test/errFailPassTextVerbose-success.txt', 'test/ref/errFailPassTextVerbose-success.txt', 0 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--verbose -p Succ -p Fail', 'test/errFailPassTextVerbose-failures.txt', 'test/ref/errFailPassTextVerbose-failures.txt', 5 ) ) end function testTextQuiet() lu.assertEquals( 0, check_text_output('example_with_luaunit.lua', '--quiet', 'test/exampleTextQuiet.txt', 'test/ref/exampleTextQuiet.txt', 12 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet', 'test/errFailPassTextQuiet.txt', 'test/ref/errFailPassTextQuiet.txt', 10 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ', 'test/errFailPassTextQuiet-success.txt', 'test/ref/errFailPassTextQuiet-success.txt', 0 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ -p Fail', 'test/errFailPassTextQuiet-failures.txt', 'test/ref/errFailPassTextQuiet-failures.txt', 5 ) ) end -- check nil output function testNilDefault() lu.assertEquals( 0, check_nil_output('example_with_luaunit.lua', '', 'test/exampleNilDefault.txt', 'test/ref/exampleNilDefault.txt', 12 ) ) lu.assertEquals( 0, check_nil_output('test/test_with_err_fail_pass.lua', '', 'test/errFailPassNilDefault.txt', 'test/ref/errFailPassNilDefault.txt', 10 ) ) lu.assertEquals( 0, check_nil_output('test/test_with_err_fail_pass.lua', ' -p Succ', 'test/errFailPassNilDefault-success.txt', 'test/ref/errFailPassNilDefault-success.txt', 0 ) ) lu.assertEquals( 0, check_nil_output('test/test_with_err_fail_pass.lua', ' -p Succ -p Fail', 'test/errFailPassNilDefault-failures.txt', 'test/ref/errFailPassNilDefault-failures.txt', 5 ) ) end -- check xml output function testXmlDefault() lu.assertEquals( 0, check_xml_output('example_with_luaunit.lua', '', 'test/exampleXmlDefault.txt', 'test/exampleXmlDefault.xml', 'test/exampleXmllintDefault.xml', 'test/ref/exampleXmlDefault.txt', 'test/ref/exampleXmlDefault.xml', 12 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '', 'test/errFailPassXmlDefault.txt', 'test/errFailPassXmlDefault.xml', 'test/errFailPassXmllintDefault.xml', 'test/ref/errFailPassXmlDefault.txt', 'test/ref/errFailPassXmlDefault.xml', 10 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '-p Succ', 'test/errFailPassXmlDefault-success.txt', 'test/errFailPassXmlDefault-success.xml', 'test/errFailPassXmllintDefault.xml', 'test/ref/errFailPassXmlDefault-success.txt', 'test/ref/errFailPassXmlDefault-success.xml', 0 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '-p Succ -p Fail', 'test/errFailPassXmlDefault-failures.txt', 'test/errFailPassXmlDefault-failures.xml', 'test/errFailPassXmllintDefault.xml', 'test/ref/errFailPassXmlDefault-failures.txt', 'test/ref/errFailPassXmlDefault-failures.xml', 5 ) ) end function testXmlVerbose() lu.assertEquals( 0, check_xml_output('example_with_luaunit.lua', '--verbose', 'test/exampleXmlVerbose.txt', 'test/exampleXmlVerbose.xml', 'test/exampleXmllintVerbose.xml', 'test/ref/exampleXmlVerbose.txt', 'test/ref/exampleXmlVerbose.xml', 12 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '--verbose ', 'test/errFailPassXmlVerbose.txt', 'test/errFailPassXmlVerbose.xml', 'test/errFailPassXmllintVerbose.xml', 'test/ref/errFailPassXmlVerbose.txt', 'test/ref/errFailPassXmlVerbose.xml', 10 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '--verbose -p Succ', 'test/errFailPassXmlVerbose-success.txt', 'test/errFailPassXmlVerbose-success.xml', 'test/errFailPassXmllintVerbose.xml', 'test/ref/errFailPassXmlVerbose-success.txt', 'test/ref/errFailPassXmlVerbose-success.xml', 0 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '--verbose -p Succ -p Fail', 'test/errFailPassXmlVerbose-failures.txt', 'test/errFailPassXmlVerbose-failures.xml', 'test/errFailPassXmllintVerbose.xml', 'test/ref/errFailPassXmlVerbose-failures.txt', 'test/ref/errFailPassXmlVerbose-failures.xml', 5 ) ) end function testXmlQuiet() lu.assertEquals( 0, check_xml_output('example_with_luaunit.lua', '--quiet', 'test/exampleXmlQuiet.txt', 'test/exampleXmlQuiet.xml', 'test/exampleXmllintQuiet.xml', 'test/ref/exampleXmlQuiet.txt', 'test/ref/exampleXmlQuiet.xml', 12 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '--quiet ', 'test/errFailPassXmlQuiet.txt', 'test/errFailPassXmlQuiet.xml', 'test/errFailPassXmllintQuiet.xml', 'test/ref/errFailPassXmlQuiet.txt', 'test/ref/errFailPassXmlQuiet.xml', 10 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ', 'test/errFailPassXmlQuiet-success.txt', 'test/errFailPassXmlQuiet-success.xml', 'test/errFailPassXmllintQuiet.xml', 'test/ref/errFailPassXmlQuiet-success.txt', 'test/ref/errFailPassXmlQuiet-success.xml', 0 ) ) lu.assertEquals( 0, check_xml_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ -p Fail', 'test/errFailPassXmlQuiet-failures.txt', 'test/errFailPassXmlQuiet-failures.xml', 'test/errFailPassXmllintQuiet.xml', 'test/ref/errFailPassXmlQuiet-failures.txt', 'test/ref/errFailPassXmlQuiet-failures.xml', 5 ) ) end function testTestWithXmlDefault() lu.assertEquals( 0, check_xml_output('test/test_with_xml.lua', '', 'test/testWithXmlDefault.txt', 'test/testWithXmlDefault.xml', 'test/testWithXmlLintDefault.txt', 'test/ref/testWithXmlDefault.txt', 'test/ref/testWithXmlDefault.xml', 2 ) ) end function testTestWithXmlVerbose() lu.assertEquals( 0, check_xml_output('test/test_with_xml.lua', '--verbose', 'test/testWithXmlVerbose.txt', 'test/testWithXmlVerbose.xml', 'test/testWithXmlLintVerbose.txt', 'test/ref/testWithXmlVerbose.txt', 'test/ref/testWithXmlVerbose.xml', 2 ) ) end function testTestWithXmlQuiet() lu.assertEquals( 0, check_xml_output('test/test_with_xml.lua', '--quiet', 'test/testWithXmlQuiet.txt', 'test/testWithXmlQuiet.xml', 'test/testWithXmlLintQuiet.txt', 'test/ref/testWithXmlQuiet.txt', 'test/ref/testWithXmlQuiet.xml', 2 ) ) end function testLegacyLuaunitUsage() -- run test/legacy_example_usage and check exit status (expecting 12 failures) osExpectedCodeExec(12, '%s %s --output text > %s', LUA, "test/legacy_example_with_luaunit.lua", "test/legacyExample.txt") end function testLuaunitV2Usage() osExpectedCodeExec(0, '%s %s --output text 1> %s 2>&1', LUA, "test/compat_luaunit_v2x.lua", "test/compat_luaunit_v2x.txt") end function testBasicLuaunitOptions() osExpectedCodeExec(0, '%s example_with_luaunit.lua --help > test/null.txt', LUA) osExpectedCodeExec(0, '%s example_with_luaunit.lua --version > test/null.txt', LUA) -- test invalid syntax osExpectedCodeExec(-1, '%s example_with_luaunit.lua --foobar > test/null.txt', LUA) -- invalid option osExpectedCodeExec(-1, '%s example_with_luaunit.lua --output foobar > test/null.txt', LUA) -- invalid format osExpectedCodeExec(-1, '%s example_with_luaunit.lua --output junit > test/null.txt', LUA) -- missing output name os.remove('test/null.txt') end function testStopOnError() lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet -p Succ --error --failure', 'test/errFailPassTextStopOnError-1.txt', 'test/ref/errFailPassTextStopOnError-1.txt', 0 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet -p TestSome --error', 'test/errFailPassTextStopOnError-2.txt', 'test/ref/errFailPassTextStopOnError-2.txt', -2 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet -p TestAnoth --failure', 'test/errFailPassTextStopOnError-3.txt', 'test/ref/errFailPassTextStopOnError-3.txt', -2 ) ) lu.assertEquals( 0, check_text_output('test/test_with_err_fail_pass.lua', '--quiet -p TestSome --failure', 'test/errFailPassTextStopOnError-4.txt', 'test/ref/errFailPassTextStopOnError-4.txt', -2 ) ) end local filesToGenerateExampleXml = { { 'example_with_luaunit.lua', '', '--output junit --name test/ref/exampleXmlDefault.xml', 'test/ref/exampleXmlDefault.txt' }, { 'example_with_luaunit.lua', '--quiet', '--output junit --name test/ref/exampleXmlQuiet.xml', 'test/ref/exampleXmlQuiet.txt' }, { 'example_with_luaunit.lua', '--verbose', '--output junit --name test/ref/exampleXmlVerbose.xml', 'test/ref/exampleXmlVerbose.txt' }, } local filesToGenerateExampleTap = { { 'example_with_luaunit.lua', '', '--output tap', 'test/ref/exampleTapDefault.txt' }, { 'example_with_luaunit.lua', '--quiet', '--output tap', 'test/ref/exampleTapQuiet.txt' }, { 'example_with_luaunit.lua', '--verbose', '--output tap', 'test/ref/exampleTapVerbose.txt' }, } local filesToGenerateExampleText = { { 'example_with_luaunit.lua', '', '--output text', 'test/ref/exampleTextDefault.txt' }, { 'example_with_luaunit.lua', '--quiet', '--output text', 'test/ref/exampleTextQuiet.txt' }, { 'example_with_luaunit.lua', '--verbose', '--output text', 'test/ref/exampleTextVerbose.txt' }, } local filesToGenerateExampleNil = { { 'example_with_luaunit.lua', '', '--output nil', 'test/ref/exampleNilDefault.txt' }, } local filesToGenerateErrFailPassXml = { { 'test/test_with_err_fail_pass.lua', '', '--output junit --name test/ref/errFailPassXmlDefault.xml', 'test/ref/errFailPassXmlDefault.txt' }, { 'test/test_with_err_fail_pass.lua', '', '-p Succ --output junit --name test/ref/errFailPassXmlDefault-success.xml', 'test/ref/errFailPassXmlDefault-success.txt' }, { 'test/test_with_err_fail_pass.lua', '', '-p Succ -p Fail --output junit --name test/ref/errFailPassXmlDefault-failures.xml', 'test/ref/errFailPassXmlDefault-failures.txt' }, { 'test/test_with_err_fail_pass.lua', '', '--quiet --output junit --name test/ref/errFailPassXmlQuiet.xml', 'test/ref/errFailPassXmlQuiet.txt' }, { 'test/test_with_err_fail_pass.lua', '', '-p Succ --quiet --output junit --name test/ref/errFailPassXmlQuiet-success.xml', 'test/ref/errFailPassXmlQuiet-success.txt' }, { 'test/test_with_err_fail_pass.lua', '', '-p Succ -p Fail --quiet --output junit --name test/ref/errFailPassXmlQuiet-failures.xml', 'test/ref/errFailPassXmlQuiet-failures.txt' }, { 'test/test_with_err_fail_pass.lua', '', '--verbose --output junit --name test/ref/errFailPassXmlVerbose.xml', 'test/ref/errFailPassXmlVerbose.txt' }, { 'test/test_with_err_fail_pass.lua', '', '-p Succ --verbose --output junit --name test/ref/errFailPassXmlVerbose-success.xml', 'test/ref/errFailPassXmlVerbose-success.txt' }, { 'test/test_with_err_fail_pass.lua', '', '-p Succ -p Fail --verbose --output junit --name test/ref/errFailPassXmlVerbose-failures.xml', 'test/ref/errFailPassXmlVerbose-failures.txt' }, } local filesToGenerateErrFailPassTap = { { 'test/test_with_err_fail_pass.lua', '', '--output tap', 'test/ref/errFailPassTapDefault.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ', '--output tap', 'test/ref/errFailPassTapDefault-success.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ -p Fail', '--output tap', 'test/ref/errFailPassTapDefault-failures.txt' }, { 'test/test_with_err_fail_pass.lua', '--quiet', '--output tap', 'test/ref/errFailPassTapQuiet.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ --quiet', '--output tap', 'test/ref/errFailPassTapQuiet-success.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ -p Fail --quiet', '--output tap', 'test/ref/errFailPassTapQuiet-failures.txt' }, { 'test/test_with_err_fail_pass.lua', '--verbose', '--output tap', 'test/ref/errFailPassTapVerbose.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ --verbose', '--output tap', 'test/ref/errFailPassTapVerbose-success.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ -p Fail --verbose', '--output tap', 'test/ref/errFailPassTapVerbose-failures.txt' }, } local filesToGenerateErrFailPassText = { { 'test/test_with_err_fail_pass.lua', '', '--output text', 'test/ref/errFailPassTextDefault.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ', '--output text', 'test/ref/errFailPassTextDefault-success.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ -p Fail', '--output text', 'test/ref/errFailPassTextDefault-failures.txt' }, { 'test/test_with_err_fail_pass.lua', '--quiet', '--output text', 'test/ref/errFailPassTextQuiet.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ --quiet', '--output text', 'test/ref/errFailPassTextQuiet-success.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ -p Fail --quiet', '--output text', 'test/ref/errFailPassTextQuiet-failures.txt' }, { 'test/test_with_err_fail_pass.lua', '--verbose', '--output text', 'test/ref/errFailPassTextVerbose.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ --verbose', '--output text', 'test/ref/errFailPassTextVerbose-success.txt' }, { 'test/test_with_err_fail_pass.lua', '-p Succ -p Fail --verbose', '--output text', 'test/ref/errFailPassTextVerbose-failures.txt' }, } local filesToGenerateTestXml = { { 'test/test_with_xml.lua', '', '--output junit --name test/ref/testWithXmlDefault.xml', 'test/ref/testWithXmlDefault.txt' }, { 'test/test_with_xml.lua', '--verbose', '--output junit --name test/ref/testWithXmlVerbose.xml', 'test/ref/testWithXmlVerbose.txt' }, { 'test/test_with_xml.lua', '--quiet', '--output junit --name test/ref/testWithXmlQuiet.xml', 'test/ref/testWithXmlQuiet.txt' }, } local filesToGenerateStopOnError = { { 'test/test_with_err_fail_pass.lua', '', '--output text --quiet -p Succ --error --failure', 'test/ref/errFailPassTextStopOnError-1.txt'}, { 'test/test_with_err_fail_pass.lua', '', '--output text --quiet -p TestSome --error', 'test/ref/errFailPassTextStopOnError-2.txt'}, { 'test/test_with_err_fail_pass.lua', '', '--output text --quiet -p TestAnoth --failure', 'test/ref/errFailPassTextStopOnError-3.txt'}, { 'test/test_with_err_fail_pass.lua', '', '--output text --quiet -p TestSome --failure', 'test/ref/errFailPassTextStopOnError-4.txt'}, } local filesSetIndex = { ErrFailPassText=filesToGenerateErrFailPassText, ErrFailPassTap=filesToGenerateErrFailPassTap, ErrFailPassXml=filesToGenerateErrFailPassXml, ExampleNil=filesToGenerateExampleNil, ExampleText=filesToGenerateExampleText, ExampleTap=filesToGenerateExampleTap, ExampleXml=filesToGenerateExampleXml, TestXml=filesToGenerateTestXml, StopOnError=filesToGenerateStopOnError, } local function updateRefFiles( filesToGenerate ) local ret for i,v in ipairs(filesToGenerate) do report('Generating '..v[4]) ret = osExec( '%s %s %s %s > %s', LUA, v[1], v[2], v[3], v[4] ) --[[ -- exitcode != 0 is not an error for us ... if ret == false then error('Error while generating '..prettystr(v) ) os.exit(1) end ]] -- neutralize all testcase time values in ref xml output local refXmlName = string.match(v[3], "--name (test/ref/.*%.xml)$") if refXmlName then adjustFile( refXmlName, refXmlName, '.* element - report duration - add properties describe the environment Done: ============ x add other types of output x assert with matching of the error message x finish user documentation x switch version 3.0 x add assertMatch for strings x document --name x improve junit xml output (one file, choice of filename) x display number of non selected tests x assertIs with all types x mention one file distribution x improve TAP output: pre-calculate test numbers, display test summary as comment x test error messages of assertStrMatches and all error functions x assertNil + assertNotNil x readthedocs integration x add travis-ci badges to README x filter by pattern x support --version x support --help x replace methodInstance with real test name in reports x better error messages for wrong command line option, or wrong output type x control verbosity and output type with command line x display time to run all tests x move all assertions together x better error display of assertIsXXX functions x add assertContains for strings x add assertIsNumber, assertIsXXX x table assertions x sequence asserts x compatibilty tests with several version of lua x add assertNotEquals tmpscZSVg/.travis/0000755000175000017500000000000012777131552013410 5ustar vsevavsevatmpscZSVg/.travis/setup_lua.sh0000644000175000017500000000604712777131552015754 0ustar vsevavseva#! /bin/bash # A script for setting up environment for travis-ci testing. # Sets up Lua and Luarocks. # LUA must be "lua5.1", "lua5.2" or "luajit". # luajit2.0 - master v2.0 # luajit2.1 - master v2.1 set -eufo pipefail LUAJIT_VERSION="2.0.4" LUAJIT_BASE="LuaJIT-$LUAJIT_VERSION" source .travis/platform.sh LUA_HOME_DIR=$TRAVIS_BUILD_DIR/install/lua LR_HOME_DIR=$TRAVIS_BUILD_DIR/install/luarocks mkdir $HOME/.lua LUAJIT="no" if [ "$PLATFORM" == "macosx" ]; then if [ "$LUA" == "luajit" ]; then LUAJIT="yes"; fi if [ "$LUA" == "luajit2.0" ]; then LUAJIT="yes"; fi if [ "$LUA" == "luajit2.1" ]; then LUAJIT="yes"; fi; elif [ "$(expr substr $LUA 1 6)" == "luajit" ]; then LUAJIT="yes"; fi mkdir -p "$LUA_HOME_DIR" if [ "$LUAJIT" == "yes" ]; then if [ "$LUA" == "luajit" ]; then curl --location https://github.com/LuaJIT/LuaJIT/archive/v$LUAJIT_VERSION.tar.gz | tar xz; else git clone https://github.com/LuaJIT/LuaJIT.git $LUAJIT_BASE; fi cd $LUAJIT_BASE if [ "$LUA" == "luajit2.1" ]; then git checkout v2.1; # force the INSTALL_TNAME to be luajit perl -i -pe 's/INSTALL_TNAME=.+/INSTALL_TNAME= luajit/' Makefile fi make && make install PREFIX="$LUA_HOME_DIR" ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/luajit ln -s $LUA_HOME_DIR/bin/luajit $HOME/.lua/lua; else if [ "$LUA" == "lua5.1" ]; then curl http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz cd lua-5.1.5; elif [ "$LUA" == "lua5.2" ]; then curl http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz cd lua-5.2.4; elif [ "$LUA" == "lua5.3" ]; then curl http://www.lua.org/ftp/lua-5.3.2.tar.gz | tar xz cd lua-5.3.2; fi # Build Lua without backwards compatibility for testing perl -i -pe 's/-DLUA_COMPAT_(ALL|5_2)//' src/Makefile make $PLATFORM make INSTALL_TOP="$LUA_HOME_DIR" install; ln -s $LUA_HOME_DIR/bin/lua $HOME/.lua/lua ln -s $LUA_HOME_DIR/bin/luac $HOME/.lua/luac; fi cd $TRAVIS_BUILD_DIR lua -v LUAROCKS_BASE=luarocks-$LUAROCKS curl --location http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz | tar xz cd $LUAROCKS_BASE if [ "$LUA" == "luajit" ]; then ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; elif [ "$LUA" == "luajit2.0" ]; then ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.0" --prefix="$LR_HOME_DIR"; elif [ "$LUA" == "luajit2.1" ]; then ./configure --lua-suffix=jit --with-lua-include="$LUA_HOME_DIR/include/luajit-2.1" --prefix="$LR_HOME_DIR"; else ./configure --with-lua="$LUA_HOME_DIR" --prefix="$LR_HOME_DIR" fi make build && make install ln -s $LR_HOME_DIR/bin/luarocks $HOME/.lua/luarocks cd $TRAVIS_BUILD_DIR luarocks --version rm -rf $LUAROCKS_BASE if [ "$LUAJIT" == "yes" ]; then rm -rf $LUAJIT_BASE; elif [ "$LUA" == "lua5.1" ]; then rm -rf lua-5.1.5; elif [ "$LUA" == "lua5.2" ]; then rm -rf lua-5.2.4; elif [ "$LUA" == "lua5.3" ]; then rm -rf lua-5.3.2; fi tmpscZSVg/.travis/setenv_lua.sh0000644000175000017500000000022612777131552016111 0ustar vsevavsevaexport PATH=${PATH}:$HOME/.lua:$HOME/.local/bin:${TRAVIS_BUILD_DIR}/install/luarocks/bin bash .travis/setup_lua.sh eval `$HOME/.lua/luarocks path` tmpscZSVg/.travis/platform.sh0000644000175000017500000000041012777131552015563 0ustar vsevavsevaif [ -z "${PLATFORM:-}" ]; then PLATFORM=$TRAVIS_OS_NAME; fi if [ "$PLATFORM" == "osx" ]; then PLATFORM="macosx"; fi if [ -z "$PLATFORM" ]; then if [ "$(uname)" == "Linux" ]; then PLATFORM="linux"; else PLATFORM="macosx"; fi; fi tmpscZSVg/.luacheckrc0000644000175000017500000000230012777131552014122 0ustar vsevavseva--[[ Luacheck configuration (see http://luacheck.readthedocs.io/en/stable/config.html) Thanks to Peter Melnichenko for providing an example file for LuaUnit. ]] only = {"1"} -- limit checks to the use of global variables std = "max" files = { ["luaunit.lua"] = { ignore = {"LuaUnit", "EXPORT_ASSERT_TO_GLOBALS"} }, ["example_with_luaunit.lua"] = { ignore = {"LuaUnit", "EXPORT_ASSERT_TO_GLOBALS", "[Tt]est[%w_]+", "assertEquals", "assertNotEquals", "assertTrue", "assertFalse"} }, ["run_functional_tests.lua"] = { ignore = {"test%w+"} }, ["test/compat_luaunit_v2x.lua"] = { ignore = {"EXPORT_ASSERT_TO_GLOBALS", "[Tt]est[%w_]+", "assert[%w_]+"} }, ["test/legacy_example_with_luaunit.lua"] = { ignore = {"LuaUnit", "EXPORT_ASSERT_TO_GLOBALS", "[Tt]est[%w_]+", "assertEquals", "assertNotEquals", "assertTrue", "assertFalse"} }, ["test/test_luaunit.lua"] = { ignore = {"TestMock", "TestLuaUnit%a+", "MyTest%w+"}}, ["test/test_with_err_fail_pass.lua"] = { ignore = {"[Tt]est[%w_]+"} }, ["test/test_with_xml.lua"] = { ignore = {"Test%w+"} } } tmpscZSVg/doc/0000755000175000017500000000000012777131577012576 5ustar vsevavsevatmpscZSVg/doc/conf.py0000644000175000017500000002032712777131552014072 0ustar vsevavseva# -*- coding: utf-8 -*- # # LuaUnit documentation build configuration file, created by # sphinx-quickstart on Thu Aug 21 21:45:55 2014. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'LuaUnit' copyright = u'2014, Philippe Fremy' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = '1.6' # The full version, including alpha/beta/rc tags. release = '1.6' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. #keep_warnings = False # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. #html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'LuaUnitdoc' # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'LuaUnit.tex', u'LuaUnit Documentation', u'Philippe Fremy', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of # the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'luaunit', u'LuaUnit Documentation', [u'Philippe Fremy'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'LuaUnit', u'LuaUnit Documentation', u'Philippe Fremy', 'LuaUnit', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False tmpscZSVg/doc/Makefile0000644000175000017500000001543712777131552014241 0ustar vsevavseva# Makefile for Sphinx documentation # # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext help: @echo "Please use \`make ' where is one of" @echo " html to make standalone HTML files" @echo " dirhtml to make HTML files named index.html in directories" @echo " singlehtml to make a single large HTML file" @echo " pickle to make pickle files" @echo " json to make JSON files" @echo " htmlhelp to make HTML files and a HTML help project" @echo " qthelp to make HTML files and a qthelp project" @echo " devhelp to make HTML files and a Devhelp project" @echo " epub to make an epub" @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" @echo " latexpdf to make LaTeX files and run them through pdflatex" @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" @echo " text to make text files" @echo " man to make manual pages" @echo " texinfo to make Texinfo files" @echo " info to make Texinfo files and run them through makeinfo" @echo " gettext to make PO message catalogs" @echo " changes to make an overview of all changed/added/deprecated items" @echo " xml to make Docutils-native XML files" @echo " pseudoxml to make pseudoxml-XML files for display purposes" @echo " linkcheck to check all external links for integrity" @echo " doctest to run all doctests embedded in the documentation (if enabled)" clean: rm -rf $(BUILDDIR)/* html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." singlehtml: $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml @echo @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." pickle: $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle @echo @echo "Build finished; now you can process the pickle files." json: $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json @echo @echo "Build finished; now you can process the JSON files." htmlhelp: $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp @echo @echo "Build finished; now you can run HTML Help Workshop with the" \ ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp @echo @echo "Build finished; now you can run "qcollectiongenerator" with the" \ ".qhcp project file in $(BUILDDIR)/qthelp, like this:" @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/LuaUnit.qhcp" @echo "To view the help file:" @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/LuaUnit.qhc" devhelp: $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp @echo @echo "Build finished." @echo "To view the help file:" @echo "# mkdir -p $$HOME/.local/share/devhelp/LuaUnit" @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/LuaUnit" @echo "# devhelp" epub: $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub @echo @echo "Build finished. The epub file is in $(BUILDDIR)/epub." latex: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." @echo "Run \`make' in that directory to run these through (pdf)latex" \ "(use \`make latexpdf' here to do that automatically)." latexpdf: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through pdflatex..." $(MAKE) -C $(BUILDDIR)/latex all-pdf @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." latexpdfja: $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex @echo "Running LaTeX files through platex and dvipdfmx..." $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." text: $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text @echo @echo "Build finished. The text files are in $(BUILDDIR)/text." man: $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." texinfo: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." @echo "Run \`make' in that directory to run these through makeinfo" \ "(use \`make info' here to do that automatically)." info: $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo @echo "Running Texinfo files through makeinfo..." make -C $(BUILDDIR)/texinfo info @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." gettext: $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale @echo @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." changes: $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes @echo @echo "The overview file is in $(BUILDDIR)/changes." linkcheck: $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck @echo @echo "Link check complete; look for any errors in the above output " \ "or in $(BUILDDIR)/linkcheck/output.txt." doctest: $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest @echo "Testing of doctests in the sources finished, look at the " \ "results in $(BUILDDIR)/doctest/output.txt." xml: $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml @echo @echo "Build finished. The XML files are in $(BUILDDIR)/xml." pseudoxml: $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml @echo @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." tmpscZSVg/doc/index.rst0000644000175000017500000012700312777131552014433 0ustar vsevavseva.. LuaUnit documentation master file, created by sphinx-quickstart on Thu Aug 21 21:45:55 2014. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Welcome to LuaUnit's documentation! ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, .. toctree:: :maxdepth: 3 .. highlight:: lua Introduction ************ LuaUnit is a unit-testing framework for Lua. It allows you to write test functions and test classes with test methods, combined with setup/teardown functionality. A wide range of assertions are supported. LuaUnit supports several output format, like Junit or TAP, for easier integration into Continuous Integration platforms (Jenkins, Maven, ...) . The integrated command-line options provide a flexible interface to select tests by name or patterns, control output format, set verbosity, ... Platform support ================ LuaUnit works with Lua 5.1, LuaJIT 2.0, LuaJIT 2.1 beta, Lua 5.2 and Lua 5.3 . It is tested on Windows Seven, Windows Server 2012 R2 (x64) and Ubuntu 14.04 (see continuous build results on `Travis-CI`_ and `AppVeyor`_ ) and should work on all platforms supported by Lua. It has no other dependency than Lua itself. .. _Travis-CI: https://travis-ci.org/bluebird75/luaunit .. _AppVeyor: https://ci.appveyor.com/project/bluebird75/luaunit/history LuaUnit is packed into a single-file. To make start using it, just add the file to your project. Other installation methods are described in the `README.md`_ file. .. _README.md: https://github.com/bluebird75/luaunit LuaUnit is maintained on github: https://github.com/bluebird75/luaunit It is released under the BSD license. Upgrade note ================ **Important note when upgrading to version 3.1 and above** : there is a break of backward compatibility in version 3.1, assertions functions are no longer exported directly to the global namespace. See :ref:`luaunit-global-asserts` on how to adjust or restore previous behavior. LuaUnit development =================== See :ref:`developing-luaunit` Version and Changelog ===================== This documentation describes the functionality of LuaUnit v3.2 . New in version 3.2 - 12. Jul 2016 --------------------------------- * Add command-line option to stop on first error or failure * Distinguish between failures (failed assertion) and errors * Support for new versions: Lua 5.3 and LuaJIT (2.0, 2.1 beta) * Validation of all lua versions on Travis CI and AppVeyor * Add compatibility layer with forked luaunit v2.x * Added documentation about development process * Improved support for table containing keys of type table * Small bug fixes, several internal improvements * Available with a Luarock package New in version 3.1 - 10. Mar 2015 --------------------------------- * luaunit no longer pollutes global namespace, unless defining EXPORT_ASSERT_TO_GLOBALS to true * fixes and validation of JUnit XML generation * strip luaunit internal information from stacktrace * general improvements of test results with duration and other details * improve printing for tables, with an option to always print table id * fix printing of recursive tables **Important note when upgrading to version 3.1** : assertions functions are no longer exported directly to the global namespace. See :ref:`luaunit-global-asserts` New in version 3.0 - 9. Oct 2014 -------------------------------- Because LuaUnit was forked and released as some 2.x version, version number is now jumping to 3.0 . * full documentation available in text, html and pdf at read-the-docs.org * new output format: JUnit, compatible with Bamboo and other CI platforms * much better table assertions * new assertions for strings, with patterns and case insensitivity: assertStrContains, assertNotStrContains, assertNotStrIContains, assertStrIContains, assertStrMatches * new assertions for floats: assertAlmostEquals, assertNotAlmostEquals * type assertions: assertIsString, assertIsNumber, ... * error assertions: assertErrorMsgEquals, assertErrorMsgContains, assertErrorMsgMatches * improved error messages for several assertions * command-line options to select test, control output type and verbosity New in version 1.5 - 8. Nov 2012 -------------------------------- * compatibility with Lua 5.1 and 5.2 * better object model internally * a lot more of internal tests * several internal bug fixes * make it easy to customize the test output * running test functions no longer requires a wrapper * several level of verbosity New in version 1.4 - 26. Jul 2012 --------------------------------- * switch from X11 to more popular BSD license * add TAP output format for integration into Jenkins * official repository now on github New in version 1.3 - 30. Oct 2007 --------------------------------- * port to lua 5.1 * iterate over the test classes, methods and functions in the alphabetical order * change the default order of expected, actual in assertEquals (adjustable with USE_EXPECTED_ACTUAL_IN_ASSERT_EQUALS). Version 1.2 - 13. Jun 2005 --------------------------------- * first public release Version 1.1 ------------ * move global variables to internal variables * assertion order is configurable between expected/actual or actual/expected * new assertion to check that a function call returns an error * display the calling stack when an error is spotted * two verbosity level, like in python unittest Getting started *************** Setting up your test script =========================== To get started, create your file *test_something.lua* . The script should import LuaUnit:: luaunit = require('luaunit') The last line executes your script with LuaUnit and exit with the proper error code:: os.exit( luaunit.LuaUnit.run() ) Now, run your file with:: lua test_something.lua It prints something like:: Ran 0 tests in 0 seconds OK Now, your testing framework is in place, you can start writing tests. Writing tests ============= LuaUnit scans all variables that start with *test* or *Test*. If they are functions, or if they are tables that contain functions that start with *test* or *Test*, they are run as part of the test suite. So just write a function whose name starts with test. Inside test functions, use the assertions functions provided by LuaUnit, such as :func:`assertEquals`. Let's see that in practice. Suppose you want to test the following add function:: function add(v1,v2) -- add positive numbers -- return 0 if any of the numbers are 0 -- error if any of the two numbers are negative if v1 < 0 or v2 < 0 then error('Can only add positive or null numbers, received '..v1..' and '..v2) end if v1 == 0 or v2 == 0 then return 0 end return v1+v2 end You write the following tests:: function testAddPositive() luaunit.assertEquals(add(1,1),2) end function testAddZero() luaunit.assertEquals(add(1,0),0) luaunit.assertEquals(add(0,5),0) luaunit.assertEquals(add(0,0),0) end :func:`assertEquals` is the most common used assertion function. It simply verifies that both argument are equals, in the order actual value, expected value. Rerun your test script (-v is to activate a more verbose output) :: lua test_something.lua -v It now prints:: Started on 03/10/15 16:45:41 TestAdd.testAddPositive ... Ok TestAdd.testAddZero ... Ok ========================================================= Ran 2 tests in 0.010 seconds OK You always have: * the date at which the test suite was started * the group to which the function belongs (usually, the name of the function table, and ** for all direct test functions) * the name of the function being executed * a report at the end, with number of executed test, number of non selected tests, number of failures, number of errors (if any) and duration. The difference between failures and errors are: * luaunit assertion functions generate failures * any unexpected error during execution generates an error * failures or errors during setup() or teardown() always generate errors You also want to test that when the function receives negative numbers, it generates an error. Use :func:`assertError` or even better, :func:`assertErrorMsgContains` to also validate the content of the error message. There are other types or error checking functions, see :ref:`assert-error` . Here we use :func:`assertErrorMsgContains` . First argument is the expected message, then the function to call and the optional arguments:: function testAddError() luaunit.assertErrorMsgContains('Can only add positive or null numbers, received 2 and -3', add, 2, -3) end Now, suppose we also have the following function to test:: function adder(v) -- return a function that adds v to its argument using add function closure( x ) return x+v end return closure end We want to test the type of the value returned by adder and its behavior. LuaUnit provides assertion for type testing (see :ref:`assert-type`). In this case, we use :func:`assertIsFunction`:: function testAdder() f = adder(3) luaunit.assertIsFunction( f ) luaunit.assertEquals( f(2), 5 ) end Grouping tests, setup/teardown functionality ===================================================== When the number of tests starts to grow, you usually organise them into separate groups. You can do that with LuaUnit by putting them inside a table (whose name must start with *Test* or *test* ). For example, assume we have a second function to test:: function div(v1,v2) -- divide positive numbers -- return 0 if any of the numbers are 0 -- error if any of the two numbers are negative if v1 < 0 or v2 < 0 then error('Can only divide positive or null numbers, received '..v1..' and '..v2) end if v1 == 0 or v2 == 0 then return 0 end return v1/v2 end We move the tests related to the function add into their own table:: TestAdd = {} function TestAdd:testAddPositive() luaunit.assertEquals(add(1,1),2) end function TestAdd:testAddZero() luaunit.assertEquals(add(1,0),0) luaunit.assertEquals(add(0,5),0) luaunit.assertEquals(add(0,0),0) end function TestAdd:testAddError() luaunit.assertErrorMsgContains('Can only add positive or null numbers, received 2 and -3', add, 2, -3) end function TestAdd:testAdder() f = adder(3) luaunit.assertIsFunction( f ) luaunit.assertEquals( f(2), 5 ) end -- end of table TestAdd Then we create a second set of tests for div:: TestDiv = {} function TestDiv:testDivPositive() luaunit.assertEquals(div(4,2),2) end function TestDiv:testDivZero() luaunit.assertEquals(div(4,0),0) luaunit.assertEquals(div(0,5),0) luaunit.assertEquals(div(0,0),0) end function TestDiv:testDivError() luaunit.assertErrorMsgContains('Can only divide positive or null numbers, received 2 and -3', div, 2, -3) end -- end of table TestDiv Execution of the test suite now looks like this:: Started on 03/10/15 16:47:33 TestAdd.testAddError ... Ok TestAdd.testAddPositive ... Ok TestAdd.testAddZero ... Ok TestAdd.testAdder ... Ok TestDiv.testDivError ... Ok TestDiv.testDivPositive ... Ok TestDiv.testDivZero ... Ok ========================================================= Ran 7 tests in 0.010 seconds OK When tests are defined in tables, you can optionally define two special functions, *setUp()* and *tearDown()*, which will be executed respectively before and after every test. These function may be used to create specific resources for the test being executed and cleanup the test environment. For a practical example, imagine that we have a *log()* function that writes strings to a log file on disk. The file is created upon first usage of the function, and the filename is defined by calling the function *initLog()*. The tests for these functions would take advantage of the *setup/teardown* functionality to prepare a log filename shared by all tests, make sure that all tests start with a non existing log file name, and erase the log filename after every test:: TestLogger = {} function TestLogger:setUp() -- define the fname to use for logging self.fname = 'mytmplog.log' -- make sure the file does not already exists os.remove(self.fname) end function TestLogger:testLoggerCreatesFile() initLog(self.fname) log('toto') -- make sure that our log file was created f = io.open(self.fname, 'r') luaunit.assertNotNil( f ) f:close() end function TestLogger:tearDown() -- cleanup our log file after all tests os.remove(self.fname) end .. Note:: *Errors generated during execution of setUp() or tearDown() functions are considered test failures.* .. Note:: *For compatibility with luaunit v2 and other lua unit-test frameworks, setUp() and tearDown() may also be named setup(), SetUp(), Setup(), teardown(), TearDown(), Teardown().* Using the command-line ====================== You can control the LuaUnit execution from the command-line: **Output format** Choose the test output format with ``-o`` or ``--output``. Available formats are: * text: the default output format * nil: no output at all * TAP: TAP format * junit: output junit xml Example of non-verbose text format:: $ lua doc/test_something.lua ....... Ran 7 tests in 0.002 seconds OK Example of TAP format:: $ lua doc/test_something.lua -o TAP 1..7 # Started on 03/10/15 16:50:09 # Starting class: TestAdd ok 1 TestAdd.testAddError ok 2 TestAdd.testAddPositive ok 3 TestAdd.testAddZero ok 4 TestAdd.testAdder # Starting class: TestDiv ok 5 TestDiv.testDivError ok 6 TestDiv.testDivPositive ok 7 TestDiv.testDivZero # Ran 7 tests in 0.022 seconds, 7 successes, 0 failures **List of tests to run** You can list some test names on the command-line to run only those tests. The name must be the exact match of either the test table, the test function or the test table and the test method. The option may be repeated. Example:: -- Run all TestAdd table tests and one test of TestDiv table. $ lua doc/test_something.lua TestAdd TestDiv.testDivError -v Started on 03/10/15 16:52:20 TestAdd.testAddError ... Ok TestAdd.testAddPositive ... Ok TestAdd.testAddZero ... Ok TestAdd.testAdder ... Ok TestDiv.testDivError ... Ok ========================================================= Ran 5 tests in 0.000 seconds OK **Filtering tests** The most flexible approach for selecting tests to run is to use a pattern. With ``--pattern`` or ``-p``, you can provide a lua pattern and only the tests that contain the pattern will actually be run. Example:: -- Run all tests of zero testing and error testing -- by using the magic character . lua my_test_suite.lua -v -p Err.r -p Z.ro For our test suite, it gives the following output:: Started on 03/10/15 16:48:29 TestAdd.testAddError ... Ok TestAdd.testAddZero ... Ok TestDiv.testDivError ... Ok TestDiv.testDivZero ... Ok ========================================================= Ran 4 tests in 0.010 seconds OK (ignored=3) The number of tests ignored by the selection is printed, along with the test result. The pattern can be any lua pattern. Be sure to exclude all magic characters with % (like -+?*) and protect your pattern from the shell interpretation by putting it in quotes. Conclusion ========== You now know enough of LuaUnit to start writing your test suite. Check the reference documentation for a complete list of assertions, command-line options and specific behavior. .. _reference-documentation: Reference documentation *********************** .. _luaunit-global-asserts: Enabling global or module-level functions ========================================= Versions of LuaUnit before version 3.1 would export all assertions functions to the global namespace. A typical lua test file would look like this: .. code-block:: lua require('luaunit') TestToto = {} --class function TestToto:test1_withFailure() local a = 1 assertEquals( a , 1 ) -- will fail assertEquals( a , 2 ) end [...] However, this is an obsolete practice in Lua. It is now recommended to keep all functions inside the module. Starting from version 3.1 LuaUnit follows this practice and the code should be adapted to look like this: .. code-block:: lua -- the imported module must be stored luaunit = require('luaunit') TestToto = {} --class function TestToto:test1_withFailure() local a = 1 luaunit.assertEquals( a , 1 ) -- will fail luaunit.assertEquals( a , 2 ) end [...] If you prefer the old way, LuaUnit can continue to export assertions functions if you set the following global variable **prior** to importing LuaUnit: .. code-block:: lua -- this works EXPORT_ASSERT_TO_GLOBALS = true require('luaunit') TestToto = {} --class function TestToto:test1_withFailure() local a = 1 assertEquals( a , 1 ) -- will fail assertEquals( a , 2 ) end [...] .. _luaunit-run: LuaUnit.run() function ====================== **Return value** Normally, you should run your test suite with the following line:: os.exit(luaunit.LuaUnit.run()) The *run()* function returns the number of failures of the test suite. This is good for an exit code, 0 meaning success. **Arguments** If no arguments are supplied, it parses the command-line arguments of the script and interpret them. If arguments are supplied to the function, they are parsed instead of the command-line. It uses the same syntax. Example:: -- execute tests matching the 'withXY' pattern os.exit(luaunit.LuaUnit.run('--pattern', 'withXY')) **Choice of tests** If test names were supplied, only those tests are executed. When test names are supplied, they don't have to start with *test*, they are run anyway. If no test names were supplied, a general test collection process starts under the following rules: * all variable starting with *test* or *Test* are scanned. * if the variable is a function it is collected for testing * if the variable is a table: * all keys starting with *test* or *Test* are collected (provided that they are functions) * keys with name *setUp* and *tearDown* are also collected If one or more pattern were supplied, the test are then filtered according the pattern(s). Only the test that match the pattern(s) are actually executed. **setup and teardown** The function *setUp()* is executed before each test if it exists in the table. The function *tearDown()* is executed after every test if it exists in the table. .. Note:: *tearDown()* is always executed if it exists, even if there was a failure in the test or in the *setUp()* function. Failures in *setUp()* or *tearDown()* are considered as a general test failures. LuaUnit.runSuite() function ============================== If you want to keep the flexibility of the command-line parsing, but want to force some parameters, like the output format, you must use a slightly different syntax:: lu = luaunit.LuaUnit.new() lu:setOutputType("tap") os.exit( lu:runSuite() ) *runSuite()* behaves like *run()* except that it must be started with a LuaUnit instance as first argument, and it will use the LuaUnit instance settings. .. _command-line: Command-line options ==================== Usage: lua [options] [testname1 [testname2] **Test names** When no test names are supplied, all tests are collected. The syntax for supplying test names can be either: name of the function, name of the table or name of the table + '.' + name of the function. Only the supplied tests will be executed. **Selecting output format** Choose the output format with the syntax ``-o FORMAT`` or ``--output FORMAT``. Formats available: * ``text``: the default output format of LuaUnit * ``nil``: no output at all * ``tap``: output compatible with the `Test Anything Protocol`_ * ``junit``: output compatible with the *JUnit xml* format (used by many CI platforms) .. _Test Anything Protocol: http://testanything.org/ .. Warning:: In the JUnit format, a destination filename must be supplied with ``--name`` or ``-n`` **Destination filename** When using the JUnit format, the test suites writes an XML file with the test results. The file name is mandatory and must be supplied with: ``--name FILENAME`` or ``-n FILENAME`` **Selecting tests with patterns** You select a subset of tests by specifying one or more filter patterns, with ``-p PATTERN`` or ``--pattern PATTERN``. The pattern is looked for on the full test name *TestTable.testMethod* . Only the tests that actually match the pattern are selected. When specifying more than one pattern, they are tried one by one until the name matches (OR combination). Make sure you esape magic chars like ``+?-*`` with ``%`` . **Stopping on first error or failure** If --failure or -f is passed as an option, LuaUnit will stop on the first failure or error and display the test results. If --error or -e is passed as an option, LuaUnit will stop on the first error (but continue on failures). **Other Options:** * ``-h``, ``--help``: display the command-line help. * ``--version``: display the version information * ``-v``, ``--verbose``: Increase the output verbosity. The exact effect depends on the output format. May be specified multiple times. * ``-q``, ``--quiet``: Set verbosity to minimum. The exact effect depends on the output format. .. _assertions-label: Assertions functions ===================== You will now find the list of all assertion functions. For all functions, When an assertion fails, the failure message tries to be as informative as possible, by displaying the expectation and value that caused the failure. .. Note:: see :ref:`table-printing` and :ref:`comparing-table-keys-table` for more dealing with recursive tables and tables containing keys of type table. .. _assert-equality: Equality assertions ---------------------- All equality assertions functions take two arguments, in the order *actual value* then *expected value*. Some people are more familiar with the order *expected value* then *actual value*. It is possible to configure LuaUnit to use the opposite order for all equality assertions, by setting up a module variable: .. code-block:: lua luaunit.ORDER_ACTUAL_EXPECTED=false The order only matters for the message that is displayed in case of failures. It does not influence the test itself. .. function:: assertEquals(actual, expected) **Alias**: *assert_equals()* Assert that two values are equal. For tables, the comparison is a deep comparison : * number of elements must be the same * tables must contain the same keys * each key must contain the same values. The values are also compared recursively with deep comparison. LuaUnit provides other table-related assertions, see :ref:`assert-table` .. function:: assertNotEquals(actual, expected) **Alias**: *assert_not_equals()* Assert that two values are different. The assertion fails if the two values are identical. It also uses table deep comparison. .. function:: assertAlmostEquals( actual, expected, margin ) **Alias**: *assert_almost_equals()* Assert that two floating point numbers are almost equal. When comparing floating point numbers, strict equality does not work. Computer arithmetic is so that an operation that mathematically yields 1.00000000 might yield 0.999999999999 in lua . That's why you need an *almost equals* comparison, where you specify the error margin. .. function:: assertNotAlmostEquals( actual, expected, margin ) **Alias**: *assert_not_almost_equals()* Assert that two floating point numbers are not almost equal. .. _assert-value: Value assertions ---------------------- .. function:: assertTrue(value) **Alias**: *assert_true()* Assert that a given value compares to true. Lua coercion rules are applied so that values like ``0``, ``""``, ``1.17`` all compare to *true*. .. function:: assertFalse(value) **Alias**: *assert_false()* Assert that a given value compares to false. Lua coercion rules are applied so that only *nil* and *false* all compare to *false*. .. function:: assertNil(value) **Aliases**: *assert_nil()*, *assertIsNil()*, *assert_is_nil()* Assert that a given value is *nil* . .. function:: assertNotNil(value) **Aliases**: *assert_not_nil()*, *assertNotIsNil()*, *assert_not_is_nil()* Assert that a given value is not *nil* . Lua coercion rules are applied so that values like ``0``, ``""``, ``false`` all validate the assertion. .. function:: assertIs(actual, expected) **Alias**: *assert_is()* Assert that two variables are identical. For string, numbers, boolean and for nil, this gives the same result as :func:`assertEquals` . For the other types, identity means that the two variables refer to the same object. **Example :** .. code-block:: lua s1='toto' s2='to'..'to' t1={1,2} t2={1,2} luaunit.assertIs(s1,s1) -- ok luaunit.assertIs(s1,s2) -- ok luaunit.assertIs(t1,t1) -- ok luaunit.assertIs(t1,t2) -- fail .. function:: assertNotIs(actual, expected) **Alias**: *assert_not_is()* Assert that two variables are not identical, in the sense that they do not refer to the same value. See :func:`assertIs` for more details. .. _assert-string: String assertions -------------------------- Assertions related to string and patterns. .. function:: assertStrContains( str, sub [, useRe] ) **Alias**: *assert_str_contains()* Assert that a string contains the given substring or pattern. By default, substring is searched in the string. If *useRe* is provided and is true, *sub* is treated as a pattern which is searched inside the string *str* . .. function:: assertStrIContains( str, sub ) **Alias**: *assert_str_icontains()* Assert that a string contains the given substring, irrespective of the case. Not that unlike :func:`assertStrcontains`, you can not search for a pattern. .. function:: assertNotStrContains( str, sub, useRe ) **Alias**: *assert_not_str_contains()* Assert that a string does not contain a given substring or pattern. By default, substring is searched in the string. If *useRe* is provided and is true, *sub* is treated as a pattern which is searched inside the string *str* . .. function:: assertNotStrIContains( str, sub ) **Alias**: *assert_not_str_icontains()* Assert that a string does not contain the given substring, irrespective of the case. Not that unlike :func:`assertNotStrcontains`, you can not search for a pattern. .. function:: assertStrMatches( str, pattern [, start [, final] ] ) **Alias**: *assert_str_matches()* Assert that a string matches the full pattern *pattern*. If *start* and *final* are not provided or are *nil*, the pattern must match the full string, from start to end. The functions allows to specify the expected start and end position of the pattern in the string. .. _assert-error: Error assertions -------------------------- Error related assertions, to verify error generation and error messages. .. function:: assertError( func, ...) **Alias**: *assert_error()* Assert that calling functions *func* with the arguments yields an error. If the function does not yield an error, the assertion fails. Note that the error message itself is not checked, which means that this function does not distinguish between the legitimate error that you expect and another error that might be triggered by mistake. The next functions provide a better approach to error testing, by checking explicitly the error message content. .. Note:: When testing LuaUnit, switching from *assertError()* to *assertErrorMsgEquals()* revealed quite a few bugs! .. function:: assertErrorMsgEquals( expectedMsg, func, ... ) **Alias**: *assert_error_msg_equals()* Assert that calling function *func* will generate exactly the given error message. If the function does not yield an error, or if the error message is not identical, the assertion fails. Be careful when using this function that error messages usually contain the file name and line number information of where the error was generated. This is usually inconvenient. To ignore the filename and line number information, you can either use a pattern with :func:`assertErrorMsgMatches` or simply check for the message containt with :func:`assertErrorMsgContains` . .. function:: assertErrorMsgContains( partialMsg, func, ... ) **Alias**: *assert_error_msg_contains()* Assert that calling function *func* will generate an error message containing *partialMsg* . If the function does not yield an error, or if the expected message is not contained in the error message, the assertion fails. .. function:: assertErrorMsgMatches( expectedPattern, func, ... ) **Alias**: *assert_error_msg_matches()* Assert that calling function *func* will generate an error message matching *expectedPattern* . If the function does not yield an error, or if the error message does not match the provided patternm the assertion fails. Note that matching is done from the start to the end of the error message. Be sure to escape magic all magic characters with ``%`` (like ``-+.?*``) . .. _assert-type: Type assertions -------------------------- The following functions all perform type checking on their argument. If the received value is not of the right type, the failure message will contain the expected type, the received type and the received value to help you identify better the problem. .. function:: assertIsNumber(value) **Aliases**: *assertNumber()*, *assert_is_number()*, *assert_number()* Assert that the argument is a number (integer or float) .. function:: assertIsString(value) **Aliases**: *assertString()*, *assert_is_string()*, *assert_string()* Assert that the argument is a string. .. function:: assertIsTable(value) **Aliases**: *assertTable()*, *assert_is_table()*, *assert_table()* Assert that the argument is a table. .. function:: assertIsBoolean(value) **Aliases**: *assertBoolean()*, *assert_is_boolean()*, *assert_boolean()* Assert that the argument is a boolean. .. function:: assertIsNil(value) **Aliases**: *assertNil()*, *assert_is_nil()*, *assert_nil()* Assert that the argument is a nil. .. function:: assertIsFunction(value) **Aliases**: *assertFunction()*, *assert_is_function()*, *assert_function()* Assert that the argument is a function. .. function:: assertIsUserdata(value) **Aliases**: *assertUserdata()*, *assert_is_userdata()*, *assert_userdata()* Assert that the argument is a userdata. .. function:: assertIsCoroutine(value) **Aliases**: *assertCoroutine()*, *assert_is_coroutine()*, *assert_coroutine()*, *assertIsThread()*, *assertThread()*, *assert_is_thread()*, *assert_thread()* Assert that the argument is a coroutine (an object with type *thread* ). .. _assert-table: Table assertions -------------------------- .. function:: assertItemsEquals(actual, expected) **Alias**: *assert_items_equals()* Assert that two tables contain the same items, irrespective of their keys. This function is practical for example if you want to compare two lists but where items are not in the same order: .. code-block:: lua luaunit.assertItemsEquals( {1,2,3}, {3,2,1} ) -- assertion succeeds .. The comparison is not recursive on the items: if any of the items are tables, they are compared using table equality (like as in :func:`assertEquals` ), where the key matters. .. code-block:: lua luaunit.assertItemsEquals( {1,{2,3},4}, {4,{3,2,},1} ) -- assertion fails because {2,3} ~= {3,2} .. _table-printing: More on table printing =========================== When asserting tables equality, by default, the table content is printed in case of failures. LuaUnit tries to print tables in a readable format. It is possible to always display the table id along with the content, by setting a module parameter PRINT_TABLE_REF_IN_ERROR_MSG . This helps identifying tables: .. code-block:: lua local lu = require('luaunit') local t1 = {1,2,3} -- normally, t1 is dispalyed as: "{1,2,3}" -- if setting this: lu.PRINT_TABLE_REF_IN_ERROR_MSG = true -- display of table t1 becomes: " {1,2,3}" .. Note :: table loops When displaying table content, it is possible to encounter loops, if for example two table references eachother. In such cases, LuaUnit display the full table content once, along with the table id, and displays only the table id for the looping reference. **Example:** displaying a table with reference loop .. code-block:: lua local t1 = {} local t2 = {} t1.t2 = t2 t1.a = {1,2,3} t2.t1 = t1 -- when displaying table t1: -- table t1 inside t2 is only displayed by its id because t1 is already being displayed -- table t2 is displayed along with its id because it is part of a loop. -- t1: " { a={1,2,3}, t2= {t1=} }" .. _comparing-table-keys-table: Comparing tables with keys of type table =========================================== This is a very uncommon scenario but there are a few programs out there which use tables as keys for other tables. LuaUnit has been adjusted to deal intelligently with this scenario. A small code block is worth a thousand pictures : .. code-block:: lua local lu = require('luaunit') -- let's define two tables t1 = { 1, 2 } t2 = { 1, 2 } lu.assertEquals( t1, t2 ) -- succeeds -- let's define three tables, with the two above tables as keys t3 = { t1='a' } t4 = { t2='a' } t5 = { t2='a' } There are two ways to treat comparison of tables t3 and t4: **Method 1: table keys are compared by content** * t3 contain one key: t1 * t4 contain one key: t2, which has exactly the same content as t1 * the two keys compare equally with assertEquals, so assertEquals( t3, t4 ) succeeds **Method 2: table keys are compared by reference** * t3 contain one key: t1 * t4 contain one key: t2, which is not the same table as t1, its reference is different * the two keys are different because t1 is a different object than t2 so assertEquals( t3, t4 ) fails Whether method 1 or method 2 is more appropriate is up for debate. LuaUnit has been adjusted to support both scenarios, with the config variable: *TABLE_EQUALS_KEYBYCONTENT* * TABLE_EQUALS_KEYBYCONTENT = true (default): method 1 - table keys compared by content * TABLE_EQUALS_KEYBYCONTENT = false: method 2 - table keys compared by reference In any case, assertEquals( t4, t5 ) always succeeds. To adjust the config, change it into the luaunit table before running any tests: .. code-block:: lua local lu = require('luaunit') -- define all your tests -- ... lu.TABLE_EQUALS_KEYBYCONTENT = false -- run your tests: os.exit( lu.LuaUnit.run() ) .. _developing-luaunit: Developing LuaUnit ****************** Development ecosystem ====================== LuaUnit is developed on `Github`_. .. _Github: https://github.com/bluebird75/luaunit Bugs or feature requests should be reported using `GitHub issues`_. .. _Github issues: https://github.com/bluebird75/luaunit/issues Usage and development may be discussed on `LuaUnit mailing-list`_ . If you are using LuaUnit for your project, please drop us an note. .. _LuaUnit mailing-list: http://lists.freehackers.org/list/luaunit%40freehackers.org/ It is released under the BSD license. This documentation is available at `Read-the-docs`_. .. _Read-the-docs: http://luaunit.readthedocs.org/en/latest/ Contributing ============= You may contribute to LuaUnit by reporting bugs, fixing reported bugs or developing new features. Some issues on github are marked with label *enhancement*. Feel free to pick up such tasks and implement them. Changes should be proposed as *Pull Requests* on github. Unit-tests ------------------- All proposed changes should pass all unit-tests and if needed, add more unit-tests to cover the bug or the new functionality. Usage is pretty simple: .. code-block:: shell $ lua run_unit_tests.lua ................................................................................ ............................... Ran 111 tests in 0.120 seconds OK Functional tests ------------------- Functional tests also exist to validate LuaUnit. Their management is slightly more complicated. The main goal of functional tests is to validate that LuaUnit output has not been altered. Since LuaUnit supports some standard compliant output (TAP, junitxml), this is very important (and it has been broken in the past) Functional tests perform the following actions: * Run the 2 suites: example_with_luaunit.lua, test_with_err_fail_pass.lua (with various options to have successe, failure and/or errors) * Run every suite with all output format, all verbosity * Validate the XML output with jenkins/hudson and junit schema * Compare the results with the previous output ( archived in test/ref ), with some tricks to make the comparison possible : * adjustment of the file separator to use the same output on Windows and Unix * date and test duration is zeroed so that it does not impact the comparison * adjust the stack trace format which has changed between Lua 5.1, 5.2 and 5.3 * Run some legacy suites or tricky output to manage and verify output: test_with_xml.lua, , compat_luaunit_v2x.lua, legacy_example_with_luaunit.lua For functional tests to run, *diff* must be available on the command line. *xmllint* is needed to perform the xml validation but this step is skipped if *xmllint* can not be found. When functional tests work well, it looks like this: .. code-block:: shell $ lua run_functional_tests.lua ............... Ran 15 tests in 9.676 seconds OK When functional test fail, a diff of the comparison between the reference output and the current output is displayed (it can be quite long). The list of faulty files is summed-up at the end. Modifying reference files for functional tests ----------------------------------------------- The script run_functional_tests.lua supports a --update option, with an optional argument. * *--update* without argument **overwrites all reference output** with the current output. Use only if you know what you are doing, this is usually a very bad idea! * The following argument overwrite a specific subset of reference files, select the one that fits your change: * TestXml: XML output of test_with_xml * ExampleXml: XML output of example_with_luaunit * ExampleTap: TAP output of example_with_luaunit * ExampleText: text output of example_with_luaunit * ExampleNil: nil output of example_with_luaunit * ErrFailPassText: text output of test_with_err_fail_pass * ErrFailPassTap: TAP output of test_with_err_fail_pass * ErrFailPassXml: XML output of test_with_err_fail_pass * StopOnError: errFailPassTextStopOnError-1.txt, -2.txt, -3.txt, -4.txt For example to record a change in the test_with_err_fail_pass output .. code-block:: shell $ lua run_functional_tests.lua --update ErrFailPassXml ErrFailPassTap ErrFailPassText >>>>>>> Generating test/ref/errFailPassXmlDefault.txt >>>>>>> Generating test/ref/errFailPassXmlDefault-success.txt >>>>>>> Generating test/ref/errFailPassXmlDefault-failures.txt >>>>>>> Generating test/ref/errFailPassXmlQuiet.txt >>>>>>> Generating test/ref/errFailPassXmlQuiet-success.txt >>>>>>> Generating test/ref/errFailPassXmlQuiet-failures.txt >>>>>>> Generating test/ref/errFailPassXmlVerbose.txt >>>>>>> Generating test/ref/errFailPassXmlVerbose-success.txt >>>>>>> Generating test/ref/errFailPassXmlVerbose-failures.txt >>>>>>> Generating test/ref/errFailPassTapDefault.txt >>>>>>> Generating test/ref/errFailPassTapDefault-success.txt >>>>>>> Generating test/ref/errFailPassTapDefault-failures.txt >>>>>>> Generating test/ref/errFailPassTapQuiet.txt >>>>>>> Generating test/ref/errFailPassTapQuiet-success.txt >>>>>>> Generating test/ref/errFailPassTapQuiet-failures.txt >>>>>>> Generating test/ref/errFailPassTapVerbose.txt >>>>>>> Generating test/ref/errFailPassTapVerbose-success.txt >>>>>>> Generating test/ref/errFailPassTapVerbose-failures.txt >>>>>>> Generating test/ref/errFailPassTextDefault.txt >>>>>>> Generating test/ref/errFailPassTextDefault-success.txt >>>>>>> Generating test/ref/errFailPassTextDefault-failures.txt >>>>>>> Generating test/ref/errFailPassTextQuiet.txt >>>>>>> Generating test/ref/errFailPassTextQuiet-success.txt >>>>>>> Generating test/ref/errFailPassTextQuiet-failures.txt >>>>>>> Generating test/ref/errFailPassTextVerbose.txt >>>>>>> Generating test/ref/errFailPassTextVerbose-success.txt >>>>>>> Generating test/ref/errFailPassTextVerbose-failures.txt $ You can then commit the new files into git. .. Note :: how to commit updated reference outputs When committing those changes into git, please use if possible an intelligent git committing tool to commit only the interesting changes. With SourceTree for example, in case of XML changes, I can select only the lines relevant to the change and avoid committing all the updates to test duration and test datestamp. Typical failures for functional tests --------------------------------------- Functional tests may start failing when: 1. Increasing LuaUnit version 2. Improving or breaking LuaUnit output Index and Search page ********************** * :ref:`genindex` * :ref:`search` tmpscZSVg/doc/make.bat0000755000175000017500000001505712777131552014207 0ustar vsevavseva@ECHO OFF REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set BUILDDIR=_build set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . set I18NSPHINXOPTS=%SPHINXOPTS% . if NOT "%PAPER%" == "" ( set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% ) if "%1" == "" goto help if "%1" == "help" ( :help echo.Please use `make ^` where ^ is one of echo. html to make standalone HTML files echo. dirhtml to make HTML files named index.html in directories echo. singlehtml to make a single large HTML file echo. pickle to make pickle files echo. json to make JSON files echo. htmlhelp to make HTML files and a HTML help project echo. qthelp to make HTML files and a qthelp project echo. devhelp to make HTML files and a Devhelp project echo. epub to make an epub echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter echo. text to make text files echo. man to make manual pages echo. texinfo to make Texinfo files echo. gettext to make PO message catalogs echo. changes to make an overview over all changed/added/deprecated items echo. xml to make Docutils-native XML files echo. pseudoxml to make pseudoxml-XML files for display purposes echo. linkcheck to check all external links for integrity echo. doctest to run all doctests embedded in the documentation if enabled goto end ) if "%1" == "clean" ( for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i del /q /s %BUILDDIR%\* goto end ) %SPHINXBUILD% 2> nul if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) if "%1" == "html" ( %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/html. goto end ) if "%1" == "dirhtml" ( %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. goto end ) if "%1" == "singlehtml" ( %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml if errorlevel 1 exit /b 1 echo. echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. goto end ) if "%1" == "pickle" ( %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the pickle files. goto end ) if "%1" == "json" ( %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can process the JSON files. goto end ) if "%1" == "htmlhelp" ( %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %BUILDDIR%/htmlhelp. goto end ) if "%1" == "qthelp" ( %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp if errorlevel 1 exit /b 1 echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: echo.^> qcollectiongenerator %BUILDDIR%\qthelp\LuaUnit.qhcp echo.To view the help file: echo.^> assistant -collectionFile %BUILDDIR%\qthelp\LuaUnit.ghc goto end ) if "%1" == "devhelp" ( %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp if errorlevel 1 exit /b 1 echo. echo.Build finished. goto end ) if "%1" == "epub" ( %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub if errorlevel 1 exit /b 1 echo. echo.Build finished. The epub file is in %BUILDDIR%/epub. goto end ) if "%1" == "latex" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex if errorlevel 1 exit /b 1 echo. echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdf" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "latexpdfja" ( %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex cd %BUILDDIR%/latex make all-pdf-ja cd %BUILDDIR%/.. echo. echo.Build finished; the PDF files are in %BUILDDIR%/latex. goto end ) if "%1" == "text" ( %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text if errorlevel 1 exit /b 1 echo. echo.Build finished. The text files are in %BUILDDIR%/text. goto end ) if "%1" == "man" ( %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man if errorlevel 1 exit /b 1 echo. echo.Build finished. The manual pages are in %BUILDDIR%/man. goto end ) if "%1" == "texinfo" ( %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo if errorlevel 1 exit /b 1 echo. echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. goto end ) if "%1" == "gettext" ( %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale if errorlevel 1 exit /b 1 echo. echo.Build finished. The message catalogs are in %BUILDDIR%/locale. goto end ) if "%1" == "changes" ( %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes if errorlevel 1 exit /b 1 echo. echo.The overview file is in %BUILDDIR%/changes. goto end ) if "%1" == "linkcheck" ( %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck if errorlevel 1 exit /b 1 echo. echo.Link check complete; look for any errors in the above output ^ or in %BUILDDIR%/linkcheck/output.txt. goto end ) if "%1" == "doctest" ( %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest if errorlevel 1 exit /b 1 echo. echo.Testing of doctests in the sources finished, look at the ^ results in %BUILDDIR%/doctest/output.txt. goto end ) if "%1" == "xml" ( %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml if errorlevel 1 exit /b 1 echo. echo.Build finished. The XML files are in %BUILDDIR%/xml. goto end ) if "%1" == "pseudoxml" ( %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml if errorlevel 1 exit /b 1 echo. echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. goto end ) :end tmpscZSVg/doc/test_something.lua0000644000175000017500000000510212777131552016324 0ustar vsevavseva luaunit = require('luaunit') function add(v1,v2) -- add positive numbers -- return 0 if any of the numbers are 0 -- error if any of the two numbers are negative if v1 < 0 or v2 < 0 then error('Can only add positive or null numbers, received '..v1..' and '..v2) end if v1 == 0 or v2 == 0 then return 0 end return v1+v2 end function adder(v) -- return a function that adds v to its argument using add function closure( x ) return x+v end return closure end function div(v1,v2) -- divide positive numbers -- return 0 if any of the numbers are 0 -- error if any of the two numbers are negative if v1 < 0 or v2 < 0 then error('Can only divide positive or null numbers, received '..v1..' and '..v2) end if v1 == 0 or v2 == 0 then return 0 end return v1/v2 end TestAdd = {} function TestAdd:testAddPositive() luaunit.assertEquals(add(1,1),2) end function TestAdd:testAddZero() luaunit.assertEquals(add(1,0),0) luaunit.assertEquals(add(0,5),0) luaunit.assertEquals(add(0,0),0) end function TestAdd:testAddError() luaunit.assertErrorMsgContains('Can only add positive or null numbers, received 2 and -3', add, 2, -3) end function TestAdd:testAdder() f = adder(3) luaunit.assertIsFunction( f ) luaunit.assertEquals( f(2), 5 ) end -- end of table TestAdd TestDiv = {} function TestDiv:testDivPositive() luaunit.assertEquals(div(4,2),2) end function TestDiv:testDivZero() luaunit.assertEquals(div(4,0),0) luaunit.assertEquals(div(0,5),0) luaunit.assertEquals(div(0,0),0) end function TestDiv:testDivError() luaunit.assertErrorMsgContains('Can only divide positive or null numbers, received 2 and -3', div, 2, -3) end --[[ TestLogger = {} function TestLogger:setUp() -- define the fname to use for logging self.fname = 'mytmplog.log' -- make sure the file does not already exists os.remove(self.fname) end function TestLogger:testLoggerCreatesFile() initLog(self.fname) log('toto') f = io.open(self.fname, 'r') luaunit.assertNotNil( f ) f:close() end function TestLogger:tearDown() self.fname = 'mytmplog.log' -- cleanup our log file after all tests os.remove(self.fname) end -- end of table TestDiv ]] os.exit(luaunit.LuaUnit.run())tmpscZSVg/appveyor.yml0000644000175000017500000000111012777131552014403 0ustar vsevavsevaos: MinGW shallow_clone: true # create a build matrix to use various Lua and LuaJIT versions environment: matrix: - LUAENV: cinst - LUAENV: lua51 - LUAENV: lua52 - LUAENV: lua53 - LUAENV: luajit20 - LUAENV: luajit21 # cinst occasionally has problems, allow it to fail matrix: allow_failures: - LUAENV: cinst # install required binaries via batch file (also sets %LUA% path) install: - cmd: .appveyor\install-lua.cmd build: off test_script: - cmd: >- %LUA% -v run_unit_tests.lua %LUA% run_functional_tests.lua tmpscZSVg/junitxml/0000755000175000017500000000000012777131552013674 5ustar vsevavsevatmpscZSVg/junitxml/example-bamboo-2.xml0000644000175000017500000000720412777131552017450 0ustar vsevavseva tmpscZSVg/junitxml/Makefile0000644000175000017500000000103112777131552015327 0ustar vsevavseva# # junitxml/Makefile # XMLLINT ?= xmllint TEST_APACHE = --noout --schema junit-apache-ant.xsd TEST_JENKINS = --noout --schema junit-jenkins.xsd validate-examples: validate-apache validate-jenkins # This example file is the only one that satisfies the Apache schema validate-apache: example-apache-ant.xml $(XMLLINT) $(TEST_APACHE) $< # The Jenkins schema is more relaxed, and should apply to all .xml files validate-jenkins: $(wildcard *.xml) for file in $^; do $(XMLLINT) $(TEST_JENKINS) $$file || exit 1; done tmpscZSVg/junitxml/example-apache-ant.xml0000644000175000017500000000223312777131552020050 0ustar vsevavseva Detailed failure content Detailed error content bla bla output bla bla bla bla error bla bla tmpscZSVg/junitxml/example-bamboo-1.xml0000644000175000017500000001255412777131552017453 0ustar vsevavseva junit.framework.AssertionFailedError: Should not have any errors. [Perforce client error:, Connect to server failed; check $P4PORT., TCP connect to keg failed., keg: host unknown.] expected:<0> but was:<4> at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.failNotEquals(Assert.java:282) at junit.framework.Assert.assertEquals(Assert.java:64) at junit.framework.Assert.assertEquals(Assert.java:201) at com.atlassian.bamboo.repository.perforce.PerforceSyncCommandTest.testUsingPerforceWhenNoFilesHaveChanged(PerforceSyncCommandTest.java:60) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at sun.reflect.GeneratedMethodAccessor17.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.battery.JUnitBattery.executeJUnit(JUnitBattery.java:242) at org.apache.maven.surefire.battery.JUnitBattery.execute(JUnitBattery.java:216) at org.apache.maven.surefire.Surefire.executeBattery(Surefire.java:215) at org.apache.maven.surefire.Surefire.run(Surefire.java:163) at org.apache.maven.surefire.Surefire.run(Surefire.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.SurefireBooter.runTestsInProcess(SurefireBooter.java:313) at org.apache.maven.surefire.SurefireBooter.run(SurefireBooter.java:221) at org.apache.maven.test.SurefirePlugin.execute(SurefirePlugin.java:371) at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:412) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115) at org.apache.maven.cli.MavenCli.main(MavenCli.java:256) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) at org.codehaus.classworlds.Launcher.launch(Launcher.java:255) at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) at org.codehaus.classworlds.Launcher.main(Launcher.java:375) PerforceSyncCommand.command: /usr/local/bin/p4 tmpscZSVg/junitxml/example-jenkins.xml0000644000175000017500000000226312777131552017513 0ustar vsevavseva bla bla Detailed failure content Detailed error content bla bla output bla bla bla bla error bla bla tmpscZSVg/junitxml/junit-jenkins.xsd0000644000175000017500000001021712777131552017205 0ustar vsevavseva tmpscZSVg/junitxml/notes-junit-compatibility.txt0000644000175000017500000000070012777131552021560 0ustar vsevavsevaAnt xml schema is much more restrictive than jenkins. Non allowed fields in ant, allowed in jenkins: testsuites: - apache ant forbids all attributes. testsuite: - apache ant forbids attributes: disabled, skipped - apache ant allows elements system-out and system-err, that are in testcase for jenkins testcase: - apache ant forbids attributes: assertions, status - apache ant forbids elements: skipped, system-out, system-err tmpscZSVg/junitxml/XMLJUnitResultFormatter.java.txt0000644000175000017500000002322412777131552022055 0ustar vsevavseva/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. * */ package org.apache.tools.ant.taskdefs.optional.junit; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.util.Enumeration; import java.util.Hashtable; import java.util.Properties; import java.util.Date; import java.net.InetAddress; import java.net.UnknownHostException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import junit.framework.AssertionFailedError; import junit.framework.Test; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.util.DOMElementWriter; import org.apache.tools.ant.util.DateUtils; import org.apache.tools.ant.util.FileUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; /** * Prints XML output of the test to a specified Writer. * * @see FormatterElement */ public class XMLJUnitResultFormatter implements JUnitResultFormatter, XMLConstants { private static final double ONE_SECOND = 1000.0; /** constant for unnnamed testsuites/cases */ private static final String UNKNOWN = "unknown"; private static DocumentBuilder getDocumentBuilder() { try { return DocumentBuilderFactory.newInstance().newDocumentBuilder(); } catch (Exception exc) { throw new ExceptionInInitializerError(exc); } } /** * The XML document. */ private Document doc; /** * The wrapper for the whole testsuite. */ private Element rootElement; /** * Element for the current test. */ private Hashtable testElements = new Hashtable(); /** * tests that failed. */ private Hashtable failedTests = new Hashtable(); /** * Timing helper. */ private Hashtable testStarts = new Hashtable(); /** * Where to write the log to. */ private OutputStream out; /** No arg constructor. */ public XMLJUnitResultFormatter() { } /** {@inheritDoc}. */ public void setOutput(OutputStream out) { this.out = out; } /** {@inheritDoc}. */ public void setSystemOutput(String out) { formatOutput(SYSTEM_OUT, out); } /** {@inheritDoc}. */ public void setSystemError(String out) { formatOutput(SYSTEM_ERR, out); } /** * The whole testsuite started. * @param suite the testsuite. */ public void startTestSuite(JUnitTest suite) { doc = getDocumentBuilder().newDocument(); rootElement = doc.createElement(TESTSUITE); String n = suite.getName(); rootElement.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n); //add the timestamp final String timestamp = DateUtils.format(new Date(), DateUtils.ISO8601_DATETIME_PATTERN); rootElement.setAttribute(TIMESTAMP, timestamp); //and the hostname. rootElement.setAttribute(HOSTNAME, getHostname()); // Output properties Element propsElement = doc.createElement(PROPERTIES); rootElement.appendChild(propsElement); Properties props = suite.getProperties(); if (props != null) { Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); Element propElement = doc.createElement(PROPERTY); propElement.setAttribute(ATTR_NAME, name); propElement.setAttribute(ATTR_VALUE, props.getProperty(name)); propsElement.appendChild(propElement); } } } /** * get the local hostname * @return the name of the local host, or "localhost" if we cannot work it out */ private String getHostname() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { return "localhost"; } } /** * The whole testsuite ended. * @param suite the testsuite. * @throws BuildException on error. */ public void endTestSuite(JUnitTest suite) throws BuildException { rootElement.setAttribute(ATTR_TESTS, "" + suite.runCount()); rootElement.setAttribute(ATTR_FAILURES, "" + suite.failureCount()); rootElement.setAttribute(ATTR_ERRORS, "" + suite.errorCount()); rootElement.setAttribute( ATTR_TIME, "" + (suite.getRunTime() / ONE_SECOND)); if (out != null) { Writer wri = null; try { wri = new BufferedWriter(new OutputStreamWriter(out, "UTF8")); wri.write("\n"); (new DOMElementWriter()).write(rootElement, wri, 0, " "); } catch (IOException exc) { throw new BuildException("Unable to write log file", exc); } finally { if (wri != null) { try { wri.flush(); } catch (IOException ex) { // ignore } } if (out != System.out && out != System.err) { FileUtils.close(wri); } } } } /** * Interface TestListener. * *

A new Test is started. * @param t the test. */ public void startTest(Test t) { testStarts.put(t, new Long(System.currentTimeMillis())); } /** * Interface TestListener. * *

A Test is finished. * @param test the test. */ public void endTest(Test test) { // Fix for bug #5637 - if a junit.extensions.TestSetup is // used and throws an exception during setUp then startTest // would never have been called if (!testStarts.containsKey(test)) { startTest(test); } Element currentTest = null; if (!failedTests.containsKey(test)) { currentTest = doc.createElement(TESTCASE); String n = JUnitVersionHelper.getTestCaseName(test); currentTest.setAttribute(ATTR_NAME, n == null ? UNKNOWN : n); // a TestSuite can contain Tests from multiple classes, // even tests with the same name - disambiguate them. currentTest.setAttribute(ATTR_CLASSNAME, JUnitVersionHelper.getTestCaseClassName(test)); rootElement.appendChild(currentTest); testElements.put(test, currentTest); } else { currentTest = (Element) testElements.get(test); } Long l = (Long) testStarts.get(test); currentTest.setAttribute(ATTR_TIME, "" + ((System.currentTimeMillis() - l.longValue()) / ONE_SECOND)); } /** * Interface TestListener for JUnit <= 3.4. * *

A Test failed. * @param test the test. * @param t the exception. */ public void addFailure(Test test, Throwable t) { formatError(FAILURE, test, t); } /** * Interface TestListener for JUnit > 3.4. * *

A Test failed. * @param test the test. * @param t the assertion. */ public void addFailure(Test test, AssertionFailedError t) { addFailure(test, (Throwable) t); } /** * Interface TestListener. * *

An error occurred while running the test. * @param test the test. * @param t the error. */ public void addError(Test test, Throwable t) { formatError(ERROR, test, t); } private void formatError(String type, Test test, Throwable t) { if (test != null) { endTest(test); failedTests.put(test, test); } Element nested = doc.createElement(type); Element currentTest = null; if (test != null) { currentTest = (Element) testElements.get(test); } else { currentTest = rootElement; } currentTest.appendChild(nested); String message = t.getMessage(); if (message != null && message.length() > 0) { nested.setAttribute(ATTR_MESSAGE, t.getMessage()); } nested.setAttribute(ATTR_TYPE, t.getClass().getName()); String strace = JUnitTestRunner.getFilteredTrace(t); Text trace = doc.createTextNode(strace); nested.appendChild(trace); } private void formatOutput(String type, String output) { Element nested = doc.createElement(type); rootElement.appendChild(nested); nested.appendChild(doc.createCDATASection(output)); } } // XMLJUnitResultFormatter tmpscZSVg/junitxml/junit-apache-ant.xsd0000644000175000017500000002211112777131552017541 0ustar vsevavseva JUnit test result schema for the Apache Ant JUnit and JUnitReport tasks Copyright © 2011, Windy Road Technology Pty. Limited The Apache Ant JUnit XML Schema is distributed under the terms of the GNU Lesser General Public License (LGPL) http://www.gnu.org/licenses/lgpl.html Permission to waive conditions of this license may be requested from Windy Road Support (http://windyroad.org/support). Contains an aggregation of testsuite results Derived from testsuite/@name in the non-aggregated documents Starts at '0' for the first testsuite and is incremented by 1 for each following testsuite Contains the results of exexuting a testsuite Properties (e.g., environment settings) set during test execution Indicates that the test errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Contains as a text node relevant data for the error, e.g., a stack trace The error message. e.g., if a java exception is thrown, the return value of getMessage() The type of error that occured. e.g., if a java execption is thrown the full class name of the exception. Indicates that the test failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals. Contains as a text node relevant data for the failure, e.g., a stack trace The message specified in the assert The type of the assert. Name of the test method Full class name for the class the test method is in. Time taken (in seconds) to execute the test Data that was written to standard out while the test was executed Data that was written to standard error while the test was executed Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents when the test was executed. Timezone may not be specified. Host on which the tests were executed. 'localhost' should be used if the hostname cannot be determined. The total number of tests in the suite The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals The total number of tests in the suite that errorrd. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test. Time taken (in seconds) to execute the tests in the suite tmpscZSVg/run_unit_tests.lua0000644000175000017500000000021412777131552015607 0ustar vsevavseva#!/usr/bin/env lua require('test.test_luaunit') local lu = require('luaunit') lu.LuaUnit.verbosity = 2 os.exit( lu.LuaUnit.run() ) tmpscZSVg/.appveyor/0000755000175000017500000000000012777131552013745 5ustar vsevavsevatmpscZSVg/.appveyor/install-lua.cmd0000755000175000017500000000317612777131552016671 0ustar vsevavsevaREM This is a batch file to help with setting up the desired Lua environment. REM It is intended to be run as "install" step from within AppVeyor. REM version numbers and file names for binaries from http://sf.net/p/luabinaries/ set VER_51=5.1.5 set VER_52=5.2.4 set VER_53=5.3.2 set ZIP_51=lua-%VER_51%_Win32_bin.zip set ZIP_52=lua-%VER_52%_Win32_bin.zip set ZIP_53=lua-%VER_53%_Win32_bin.zip :cinst if NOT "%LUAENV%"=="cinst" goto lua51 echo Chocolatey install of Lua ... @echo on cinst lua set LUA="C:\Program Files (x86)\Lua\5.1\lua.exe" @echo off goto :EOF :lua51 if NOT "%LUAENV%"=="lua51" goto lua52 echo Setting up Lua 5.1 ... @echo on curl -fLsS -o %ZIP_51% http://sourceforge.net/projects/luabinaries/files/%VER_51%/Tools%%20Executables/%ZIP_51%/download unzip %ZIP_51% set LUA=lua5.1.exe @echo off goto :EOF :lua52 if NOT "%LUAENV%"=="lua52" goto lua53 echo Setting up Lua 5.2 ... @echo on curl -fLsS -o %ZIP_52% http://sourceforge.net/projects/luabinaries/files/%VER_52%/Tools%%20Executables/%ZIP_52%/download unzip %ZIP_52% set LUA=lua52.exe @echo off goto :EOF :lua53 if NOT "%LUAENV%"=="lua53" goto luajit echo Setting up Lua 5.3 ... @echo on curl -fLsS -o %ZIP_53% http://sourceforge.net/projects/luabinaries/files/%VER_53%/Tools%%20Executables/%ZIP_53%/download unzip %ZIP_53% set LUA=lua53.exe @echo off goto :EOF :luajit if NOT "%LUAENV%"=="luajit20" goto luajit21 echo Setting up LuaJIT 2.0 ... call %~dp0install-luajit.cmd LuaJIT-2.0.4 set LUA=luajit.exe goto :EOF :luajit21 echo Setting up LuaJIT 2.1 ... call %~dp0install-luajit.cmd LuaJIT-2.1.0-beta2 set LUA=luajit.exe tmpscZSVg/.appveyor/install-luajit.cmd0000755000175000017500000000106312777131552017371 0ustar vsevavsevaREM Do a minimalistic build of LuaJIT using the MinGW compiler set PATH=C:\MinGW\bin;%PATH% REM retrieve and unpack source curl -fLsS -o %1.zip http://luajit.org/download/%1.zip unzip -q %1 REM tweak Makefile for a static LuaJIT build (Windows defaults to "dynamic" otherwise) sed -i "s/BUILDMODE=.*mixed/BUILDMODE=static/" %1\src\Makefile mingw32-make TARGET_SYS=Windows -C %1\src REM copy luajit.exe to project dir copy %1\src\luajit.exe %APPVEYOR_BUILD_FOLDER% REM clean up (remove source folders and archive) rm -rf %1/* rm -f %1.zip tmpscZSVg/example_with_luaunit.lua0000644000175000017500000000654012777131552016761 0ustar vsevavseva#!/usr/bin/env lua EXPORT_ASSERT_TO_GLOBALS = true require('luaunit') TestToto = {} --class function TestToto:setUp() -- set up tests self.a = 1 self.s = 'hop' self.t1 = {1,2,3} self.t2 = {one=1,two=2,three=3} self.t3 = {1,2,three=3} end function TestToto:test1_withFailure() -- print( "some stuff test 1" ) assertEquals( self.a , 1 ) -- will fail assertEquals( self.a , 2 ) assertEquals( self.a , 2 ) end function TestToto:test2_withFailure() -- print( "some stuff test 2" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) -- will fail assertEquals( self.s , 'bof' ) assertEquals( self.s , 'bof' ) end function TestToto:test3() -- print( "some stuff test 3" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) assertEquals( type(self.a), 'number' ) end function TestToto:test4() -- print( "some stuff test 4" ) assertNotEquals( self.a , 1 ) end function TestToto:test5() -- print( "some stuff test 5" ) assertTrue( self.a ) assertFalse( self.a ) end function TestToto:test6() -- print( "some stuff test 6" ) assertTrue( false ) end function TestToto:test7() -- assertEquals( {1,2}, self.t1 ) -- assertEquals( {1,2}, self.t2 ) assertEquals( {1,2}, self.t3 ) end function TestToto:test8a() -- failure occurs in a submethod self:funcWithError() end function TestToto:test8b() -- failure occurs in a submethod self:funcWithFuncWithError() end function TestToto:funcWithFuncWithError() self:funcWithError() end function TestToto:funcWithError() error('Bouhouhoum error!') end -- class TestToto TestTiti = {} --class function TestTiti:setUp() -- set up tests self.a = 1 self.s = 'hop' -- print( 'TestTiti:setUp' ) end function TestTiti:tearDown() -- some tearDown() code if necessary -- print( 'TestTiti:tearDown' ) end function TestTiti:test1_withFailure() -- print( "some stuff test 1" ) assertEquals( self.a , 1 ) -- will fail assertEquals( self.a , 2 ) assertEquals( self.a , 2 ) end function TestTiti:test2_withFailure() -- print( "some stuff test 2" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) -- will fail assertEquals( self.s , 'bof' ) assertEquals( self.s , 'bof' ) end function TestTiti:test3() -- print( "some stuff test 3" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) end -- class TestTiti -- simple test functions that were written previously can be integrated -- in luaunit too function test1_withFailure() assert( 1 == 1) -- will fail assert( 1 == 2) end function test2_withFailure() assert( 'a' == 'a') -- will fail assert( 'a' == 'b') end function test3() assert( 1 == 1) assert( 'a' == 'a') end local lu = LuaUnit.new() lu:setOutputType("tap") os.exit( lu:runSuite() ) tmpscZSVg/test/0000755000175000017500000000000012777131567013007 5ustar vsevavsevatmpscZSVg/test/errFailPassTextStopOnError-3.txt0000644000175000017500000000071012777131567021143 0ustar vsevavseva..E ERROR during LuaUnit test execution: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' Ran 3 tests in 0.000 seconds, 2 successes, 1 error, 9 non-selected LuaUnit ABORTED (as requested by --error or --failure option) tmpscZSVg/test/errFailPassTapDefault-success.txt0000644000175000017500000000056212777131570021400 0ustar vsevavseva1..5 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 # Starting class: TestSomething ok 3 TestSomething.test1_Success1 ok 4 TestSomething.test1_Success2 ok 5 testFuncSuccess1 # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/0000755000175000017500000000000012777131552013555 5ustar vsevavsevatmpscZSVg/test/ref/errFailPassTextStopOnError-3.txt0000644000175000017500000000071012777131552021711 0ustar vsevavseva..E ERROR during LuaUnit test execution: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' Ran 3 tests in 0.000 seconds, 2 successes, 1 error, 9 non-selected LuaUnit ABORTED (as requested by --error or --failure option) tmpscZSVg/test/ref/errFailPassTapDefault-success.txt0000644000175000017500000000056212777131552022154 0ustar vsevavseva1..5 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 # Starting class: TestSomething ok 3 TestSomething.test1_Success1 ok 4 TestSomething.test1_Success2 ok 5 testFuncSuccess1 # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/errPassFailTapQuiet.txt0000644000175000017500000000131212777131552020203 0ustar vsevavseva1..15 # Started on 03/22/16 21:54:40 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 not ok 4 TestAnotherThing.test2_Err2 not ok 5 TestAnotherThing.test3_Fail1 not ok 6 TestAnotherThing.test3_Fail2 # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 not ok 10 TestSomething.test2_Fail2 not ok 11 TestSomething.test3_Err1 not ok 12 TestSomething.test3_Err2 not ok 13 testFuncErr1 not ok 14 testFuncFail1 ok 15 testFuncSuccess1 # Ran 15 tests in 0.000 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassTextStopOnError-4.txt0000644000175000017500000000071512777131552021717 0ustar vsevavseva..F Failure during LuaUnit test execution: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 Failed tests: ------------- 1) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' Ran 3 tests in 0.000 seconds, 2 successes, 1 failure, 9 non-selected LuaUnit ABORTED (as requested by --error or --failure option) tmpscZSVg/test/ref/errFailPassXmlVerbose-failures.txt0000644000175000017500000000201712777131552022350 0ustar vsevavseva# XML output to test/ref/errFailPassXmlVerbose-failures.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassXmlQuiet-failures.xml0000644000175000017500000000523212777131552022015 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassTapVerbose.txt0000644000175000017500000000434112777131552020526 0ustar vsevavseva1..15 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 4 TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 5 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' not ok 6 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' not ok 10 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' not ok 11 TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 12 TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 13 testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 14 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' ok 15 testFuncSuccess1 # Ran 15 tests in 0.000 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassTextDefault.txt0000644000175000017500000000350012777131552020701 0ustar vsevavseva..EEFF..FFEEEF. Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 2) TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 3) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 4) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 5) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 6) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 7) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 8) TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 9) testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 10) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassXmlVerbose.txt0000644000175000017500000000324712777131552020546 0ustar vsevavseva# XML output to test/ref/errFailPassXmlVerbose.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test2_Err1 # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test2_Err2 # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: TestSomething.test3_Err1 # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value # Starting test: TestSomething.test3_Err2 # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value # Starting test: testFuncErr1 # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 15 tests in 0.004 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/exampleTapDefault.txt0000644000175000017500000000246112777131552017726 0ustar vsevavseva1..15 # Started on 01/30/16 22:19:36 # Starting class: TestTiti not ok 1 TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 not ok 2 TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" ok 3 TestTiti.test3 # Starting class: TestToto not ok 4 TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 not ok 5 TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" ok 6 TestToto.test3 not ok 7 TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 not ok 8 TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 not ok 9 TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false not ok 10 TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} not ok 11 TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! not ok 12 TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! not ok 13 test1_withFailure example_with_luaunit.lua:126: assertion failed! not ok 14 test2_withFailure example_with_luaunit.lua:132: assertion failed! ok 15 test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/exampleTextDefault.txt0000644000175000017500000000435312777131552020130 0ustar vsevavsevaFF.FF.FFFFEEEE. Failed tests: ------------- 1) TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 5) TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' 6) TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' 7) TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' 8) TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' 9) TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' 10) TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' 11) test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' 12) test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/errFailPassTextStopOnError-1.txt0000644000175000017500000000012312777131552021705 0ustar vsevavseva..... Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/ref/exampleTapQuiet.txt0000644000175000017500000000111712777131552017426 0ustar vsevavseva1..15 # Started on 01/30/16 22:19:36 # Starting class: TestTiti not ok 1 TestTiti.test1_withFailure not ok 2 TestTiti.test2_withFailure ok 3 TestTiti.test3 # Starting class: TestToto not ok 4 TestToto.test1_withFailure not ok 5 TestToto.test2_withFailure ok 6 TestToto.test3 not ok 7 TestToto.test4 not ok 8 TestToto.test5 not ok 9 TestToto.test6 not ok 10 TestToto.test7 not ok 11 TestToto.test8a not ok 12 TestToto.test8b not ok 13 test1_withFailure not ok 14 test2_withFailure ok 15 test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/exampleXmlVerbose.xml0000644000175000017500000001106012777131552017737 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassXmlDefault-failures.txt0000644000175000017500000000201712777131552022327 0ustar vsevavseva# XML output to test/ref/errFailPassXmlDefault-failures.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 10 tests in 0.003 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassTapDefault-failures.txt0000644000175000017500000000154712777131552022322 0ustar vsevavseva1..10 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 not ok 4 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething ok 5 TestSomething.test1_Success1 ok 6 TestSomething.test1_Success2 not ok 7 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 not ok 8 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 not ok 9 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 ok 10 testFuncSuccess1 # Ran 10 tests in 0.000 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassTextVerbose.txt0000644000175000017500000000625512777131552020734 0ustar vsevavsevaStarted on 03/22/16 21:29:18 TestAnotherThing.test1_Success1 ... Ok TestAnotherThing.test1_Success2 ... Ok TestAnotherThing.test2_Err1 ... ERROR test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value TestAnotherThing.test2_Err2 ... ERROR test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value TestAnotherThing.test3_Fail1 ... FAIL test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 TestAnotherThing.test3_Fail2 ... FAIL test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 TestSomething.test1_Success1 ... Ok TestSomething.test1_Success2 ... Ok TestSomething.test2_Fail1 ... FAIL test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 TestSomething.test2_Fail2 ... FAIL test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 TestSomething.test3_Err1 ... ERROR test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value TestSomething.test3_Err2 ... ERROR test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value testFuncErr1 ... ERROR test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value testFuncFail1 ... FAIL test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 testFuncSuccess1 ... Ok ========================================================= Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 2) TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 3) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 4) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 5) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 6) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 7) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 8) TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 9) testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 10) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 15 tests in 0.001 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassNilDefault-failures.txt0000644000175000017500000000000012777131552022277 0ustar vsevavsevatmpscZSVg/test/ref/exampleTextQuiet.txt0000644000175000017500000000435312777131552017633 0ustar vsevavsevaFF.FF.FFFFEEEE. Failed tests: ------------- 1) TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 5) TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' 6) TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' 7) TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' 8) TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' 9) TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' 10) TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' 11) test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' 12) test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' Ran 15 tests in 0.012 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/errFailPassXmlVerbose-success.xml0000644000175000017500000000200312777131552022162 0ustar vsevavseva tmpscZSVg/test/ref/exampleXmlDefault.xml0000644000175000017500000001106012777131552017716 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassNilDefault.txt0000644000175000017500000000000012777131552020467 0ustar vsevavsevatmpscZSVg/test/ref/exampleTapVerbose.txt0000644000175000017500000000507212777131552017750 0ustar vsevavseva1..15 # Started on 01/30/16 22:19:36 # Starting class: TestTiti not ok 1 TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' not ok 2 TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' ok 3 TestTiti.test3 # Starting class: TestToto not ok 4 TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' not ok 5 TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' ok 6 TestToto.test3 not ok 7 TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' not ok 8 TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' not ok 9 TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' not ok 10 TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' not ok 11 TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' not ok 12 TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' not ok 13 test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' not ok 14 test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' ok 15 test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/testWithXmlDefault.txt0000644000175000017500000000102112777131552020111 0ustar vsevavseva# XML output to test/ref/testWithXmlDefault.xml # Started on 01/01/16 22:13:02 # Starting class: TestFailuresWithXml # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml # Failure: test/test_with_xml.lua:13: expected: "got it" actual: "cdata does not like ]]>" # Starting test: TestFailuresWithXml.test_failure_with_simple_xml # Failure: test/test_with_xml.lua:9: expected: "got it" actual: 'ti"ti' # Starting test: TestThatLastsALongTime # Ran 3 tests in 1.101 seconds, 1 success, 2 failures tmpscZSVg/test/ref/errFailPassTextVerbose-failures.txt0000644000175000017500000000344312777131552022540 0ustar vsevavsevaStarted on 03/22/16 21:29:18 TestAnotherThing.test1_Success1 ... Ok TestAnotherThing.test1_Success2 ... Ok TestAnotherThing.test3_Fail1 ... FAIL test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 TestAnotherThing.test3_Fail2 ... FAIL test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 TestSomething.test1_Success1 ... Ok TestSomething.test1_Success2 ... Ok TestSomething.test2_Fail1 ... FAIL test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 TestSomething.test2_Fail2 ... FAIL test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 testFuncFail1 ... FAIL test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 testFuncSuccess1 ... Ok ========================================================= Failed tests: ------------- 1) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 2) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 3) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 4) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 5) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassTextQuiet.txt0000644000175000017500000000350012777131552020404 0ustar vsevavseva..EEFF..FFEEEF. Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 2) TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 3) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 4) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 5) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 6) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 7) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 8) TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 9) testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 10) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/exampleXmlVerbose.txt0000644000175000017500000000301412777131552017756 0ustar vsevavseva# XML output to test/ref/exampleXmlVerbose.xml # Started on 01/30/16 22:19:37 # Starting class: TestTiti # Starting test: TestTiti.test1_withFailure # Failure: example_with_luaunit.lua:101: expected: 2, actual: 1 # Starting test: TestTiti.test2_withFailure # Failure: example_with_luaunit.lua:110: expected: "bof" actual: "hop" # Starting test: TestTiti.test3 # Starting class: TestToto # Starting test: TestToto.test1_withFailure # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 # Starting test: TestToto.test2_withFailure # Failure: example_with_luaunit.lua:30: expected: "bof" actual: "hop" # Starting test: TestToto.test3 # Starting test: TestToto.test4 # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 # Starting test: TestToto.test5 # Failure: example_with_luaunit.lua:49: expected: false, actual: 1 # Starting test: TestToto.test6 # Failure: example_with_luaunit.lua:54: expected: true, actual: false # Starting test: TestToto.test7 # Failure: example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} # Starting test: TestToto.test8a # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: TestToto.test8b # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: test1_withFailure # Error: example_with_luaunit.lua:126: assertion failed! # Starting test: test2_withFailure # Error: example_with_luaunit.lua:132: assertion failed! # Starting test: test3 # Ran 15 tests in 0.015 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/errFailPassXmlDefault.txt0000644000175000017500000000324712777131552020525 0ustar vsevavseva# XML output to test/ref/errFailPassXmlDefault.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test2_Err1 # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test2_Err2 # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: TestSomething.test3_Err1 # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value # Starting test: TestSomething.test3_Err2 # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value # Starting test: testFuncErr1 # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 15 tests in 0.004 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/exampleXmlDefault.txt0000644000175000017500000000301412777131552017735 0ustar vsevavseva# XML output to test/ref/exampleXmlDefault.xml # Started on 01/30/16 22:19:37 # Starting class: TestTiti # Starting test: TestTiti.test1_withFailure # Failure: example_with_luaunit.lua:101: expected: 2, actual: 1 # Starting test: TestTiti.test2_withFailure # Failure: example_with_luaunit.lua:110: expected: "bof" actual: "hop" # Starting test: TestTiti.test3 # Starting class: TestToto # Starting test: TestToto.test1_withFailure # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 # Starting test: TestToto.test2_withFailure # Failure: example_with_luaunit.lua:30: expected: "bof" actual: "hop" # Starting test: TestToto.test3 # Starting test: TestToto.test4 # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 # Starting test: TestToto.test5 # Failure: example_with_luaunit.lua:49: expected: false, actual: 1 # Starting test: TestToto.test6 # Failure: example_with_luaunit.lua:54: expected: true, actual: false # Starting test: TestToto.test7 # Failure: example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} # Starting test: TestToto.test8a # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: TestToto.test8b # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: test1_withFailure # Error: example_with_luaunit.lua:126: assertion failed! # Starting test: test2_withFailure # Error: example_with_luaunit.lua:132: assertion failed! # Starting test: test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/exampleXmlQuiet.txt0000644000175000017500000000301212777131552017436 0ustar vsevavseva# XML output to test/ref/exampleXmlQuiet.xml # Started on 01/30/16 22:19:37 # Starting class: TestTiti # Starting test: TestTiti.test1_withFailure # Failure: example_with_luaunit.lua:101: expected: 2, actual: 1 # Starting test: TestTiti.test2_withFailure # Failure: example_with_luaunit.lua:110: expected: "bof" actual: "hop" # Starting test: TestTiti.test3 # Starting class: TestToto # Starting test: TestToto.test1_withFailure # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 # Starting test: TestToto.test2_withFailure # Failure: example_with_luaunit.lua:30: expected: "bof" actual: "hop" # Starting test: TestToto.test3 # Starting test: TestToto.test4 # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 # Starting test: TestToto.test5 # Failure: example_with_luaunit.lua:49: expected: false, actual: 1 # Starting test: TestToto.test6 # Failure: example_with_luaunit.lua:54: expected: true, actual: false # Starting test: TestToto.test7 # Failure: example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} # Starting test: TestToto.test8a # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: TestToto.test8b # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: test1_withFailure # Error: example_with_luaunit.lua:126: assertion failed! # Starting test: test2_withFailure # Error: example_with_luaunit.lua:132: assertion failed! # Starting test: test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/errFailPassXmlDefault-success.xml0000644000175000017500000000200312777131552022141 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassTextStopOnError-2.txt0000644000175000017500000000151712777131552021716 0ustar vsevavseva..FFE ERROR during LuaUnit test execution: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value Failed tests: ------------- 1) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 2) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 3) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' Ran 5 tests in 0.000 seconds, 2 successes, 2 failures, 1 error, 9 non-selected LuaUnit ABORTED (as requested by --error or --failure option) tmpscZSVg/test/ref/errFailPassXmlVerbose-success.txt0000644000175000017500000000072012777131552022205 0ustar vsevavseva# XML output to test/ref/errFailPassXmlVerbose-success.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: testFuncSuccess1 # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/errFailPassXmlQuiet.xml0000644000175000017500000001022612777131552020204 0ustar vsevavseva tmpscZSVg/test/ref/testWithXmlDefault.xml0000644000175000017500000000260212777131552020100 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassTextQuiet-success.txt0000644000175000017500000000012312777131552022050 0ustar vsevavseva..... Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/ref/errFailPassTapQuiet-failures.txt0000644000175000017500000000104212777131552022013 0ustar vsevavseva1..10 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test3_Fail1 not ok 4 TestAnotherThing.test3_Fail2 # Starting class: TestSomething ok 5 TestSomething.test1_Success1 ok 6 TestSomething.test1_Success2 not ok 7 TestSomething.test2_Fail1 not ok 8 TestSomething.test2_Fail2 not ok 9 testFuncFail1 ok 10 testFuncSuccess1 # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassTapVerbose-success.txt0000644000175000017500000000056212777131552022175 0ustar vsevavseva1..5 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 # Starting class: TestSomething ok 3 TestSomething.test1_Success1 ok 4 TestSomething.test1_Success2 ok 5 testFuncSuccess1 # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/errFailPassTapVerbose-failures.txt0000644000175000017500000000255612777131552022344 0ustar vsevavseva1..10 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' not ok 4 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' # Starting class: TestSomething ok 5 TestSomething.test1_Success1 ok 6 TestSomething.test1_Success2 not ok 7 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' not ok 8 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' not ok 9 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' ok 10 testFuncSuccess1 # Ran 10 tests in 0.000 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassXmlDefault.xml0000644000175000017500000001022612777131552020501 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassXmlQuiet-failures.txt0000644000175000017500000000201512777131552022030 0ustar vsevavseva# XML output to test/ref/errFailPassXmlQuiet-failures.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassTapQuiet-success.txt0000644000175000017500000000056212777131552021657 0ustar vsevavseva1..5 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 # Starting class: TestSomething ok 3 TestSomething.test1_Success1 ok 4 TestSomething.test1_Success2 ok 5 testFuncSuccess1 # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/testWithXmlVerbose.xml0000644000175000017500000000260212777131552020121 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassXmlVerbose-failures.xml0000644000175000017500000000523212777131552022333 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassTextDefault-failures.txt0000644000175000017500000000203412777131552022512 0ustar vsevavseva..FF..FFF. Failed tests: ------------- 1) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 2) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 3) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 4) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 5) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassTapDefault.txt0000644000175000017500000000271412777131552020507 0ustar vsevavseva1..15 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value not ok 4 TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value not ok 5 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 not ok 6 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 not ok 10 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 not ok 11 TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value not ok 12 TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value not ok 13 testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value not ok 14 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 ok 15 testFuncSuccess1 # Ran 15 tests in 0.003 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassXmlVerbose.xml0000644000175000017500000001022612777131552020522 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassXmlDefault-failures.xml0000644000175000017500000000523212777131552022312 0ustar vsevavseva tmpscZSVg/test/ref/testWithXmlVerbose.txt0000644000175000017500000000102112777131552020132 0ustar vsevavseva# XML output to test/ref/testWithXmlVerbose.xml # Started on 01/01/16 22:13:03 # Starting class: TestFailuresWithXml # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml # Failure: test/test_with_xml.lua:13: expected: "got it" actual: "cdata does not like ]]>" # Starting test: TestFailuresWithXml.test_failure_with_simple_xml # Failure: test/test_with_xml.lua:9: expected: "got it" actual: 'ti"ti' # Starting test: TestThatLastsALongTime # Ran 3 tests in 1.102 seconds, 1 success, 2 failures tmpscZSVg/test/ref/errFailPassXmlDefault-success.txt0000644000175000017500000000072012777131552022164 0ustar vsevavseva# XML output to test/ref/errFailPassXmlDefault-success.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: testFuncSuccess1 # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/exampleXmlQuiet.xml0000644000175000017500000001106012777131552017421 0ustar vsevavseva tmpscZSVg/test/ref/testWithXmlQuiet.txt0000644000175000017500000000101712777131552017621 0ustar vsevavseva# XML output to test/ref/testWithXmlQuiet.xml # Started on 01/01/16 22:13:04 # Starting class: TestFailuresWithXml # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml # Failure: test/test_with_xml.lua:13: expected: "got it" actual: "cdata does not like ]]>" # Starting test: TestFailuresWithXml.test_failure_with_simple_xml # Failure: test/test_with_xml.lua:9: expected: "got it" actual: 'ti"ti' # Starting test: TestThatLastsALongTime # Ran 3 tests in 1.102 seconds, 1 success, 2 failures tmpscZSVg/test/ref/errFailPassTextDefault-success.txt0000644000175000017500000000012312777131552022345 0ustar vsevavseva..... Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/ref/testWithXmlQuiet.xml0000644000175000017500000000260212777131552017603 0ustar vsevavseva tmpscZSVg/test/ref/exampleTextVerbose.txt0000644000175000017500000000667112777131552020156 0ustar vsevavsevaStarted on 01/27/16 21:35:20 TestTiti.test1_withFailure ... FAIL example_with_luaunit.lua:101: expected: 2, actual: 1 TestTiti.test2_withFailure ... FAIL example_with_luaunit.lua:110: expected: "bof" actual: "hop" TestTiti.test3 ... Ok TestToto.test1_withFailure ... FAIL example_with_luaunit.lua:21: expected: 2, actual: 1 TestToto.test2_withFailure ... FAIL example_with_luaunit.lua:30: expected: "bof" actual: "hop" TestToto.test3 ... Ok TestToto.test4 ... FAIL example_with_luaunit.lua:43: Received the not expected value: 1 TestToto.test5 ... FAIL example_with_luaunit.lua:49: expected: false, actual: 1 TestToto.test6 ... FAIL example_with_luaunit.lua:54: expected: true, actual: false TestToto.test7 ... FAIL example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} TestToto.test8a ... ERROR example_with_luaunit.lua:78: Bouhouhoum error! TestToto.test8b ... ERROR example_with_luaunit.lua:78: Bouhouhoum error! test1_withFailure ... ERROR example_with_luaunit.lua:126: assertion failed! test2_withFailure ... ERROR example_with_luaunit.lua:132: assertion failed! test3 ... Ok ========================================================= Failed tests: ------------- 1) TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 5) TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' 6) TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' 7) TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' 8) TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' 9) TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' 10) TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' 11) test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' 12) test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' Ran 15 tests in 0.004 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/ref/errFailPassTextQuiet-failures.txt0000644000175000017500000000203412777131552022215 0ustar vsevavseva..FF..FFF. Failed tests: ------------- 1) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 2) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 3) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 4) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 5) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/ref/errFailPassXmlQuiet-success.xml0000644000175000017500000000200312777131552021644 0ustar vsevavseva tmpscZSVg/test/ref/errFailPassXmlQuiet-success.txt0000644000175000017500000000071612777131552021674 0ustar vsevavseva# XML output to test/ref/errFailPassXmlQuiet-success.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: testFuncSuccess1 # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/ref/exampleNilDefault.txt0000644000175000017500000000000012777131552017707 0ustar vsevavsevatmpscZSVg/test/ref/errFailPassXmlQuiet.txt0000644000175000017500000000324512777131552020226 0ustar vsevavseva# XML output to test/ref/errFailPassXmlQuiet.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test2_Err1 # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test2_Err2 # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: TestSomething.test3_Err1 # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value # Starting test: TestSomething.test3_Err2 # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value # Starting test: testFuncErr1 # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 15 tests in 0.003 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassTapQuiet.txt0000644000175000017500000000131212777131552020203 0ustar vsevavseva1..15 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 not ok 4 TestAnotherThing.test2_Err2 not ok 5 TestAnotherThing.test3_Fail1 not ok 6 TestAnotherThing.test3_Fail2 # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 not ok 10 TestSomething.test2_Fail2 not ok 11 TestSomething.test3_Err1 not ok 12 TestSomething.test3_Err2 not ok 13 testFuncErr1 not ok 14 testFuncFail1 ok 15 testFuncSuccess1 # Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/ref/errFailPassNilDefault-success.txt0000644000175000017500000000000012777131552022135 0ustar vsevavsevatmpscZSVg/test/ref/errFailPassTextVerbose-success.txt0000644000175000017500000000055412777131552022376 0ustar vsevavsevaStarted on 03/22/16 21:29:18 TestAnotherThing.test1_Success1 ... Ok TestAnotherThing.test1_Success2 ... Ok TestSomething.test1_Success1 ... Ok TestSomething.test1_Success2 ... Ok testFuncSuccess1 ... Ok ========================================================= Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/errFailPassTextStopOnError-4.txt0000644000175000017500000000071512777131570021143 0ustar vsevavseva..F Failure during LuaUnit test execution: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 Failed tests: ------------- 1) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' Ran 3 tests in 0.000 seconds, 2 successes, 1 failure, 9 non-selected LuaUnit ABORTED (as requested by --error or --failure option) tmpscZSVg/test/errFailPassXmlVerbose-failures.txt0000644000175000017500000000201712777131575021601 0ustar vsevavseva# XML output to test/ref/errFailPassXmlVerbose-failures.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassXmlQuiet-failures.xml0000644000175000017500000000523212777131575021246 0ustar vsevavseva tmpscZSVg/test/errFailPassTapVerbose.txt0000644000175000017500000000434112777131570017752 0ustar vsevavseva1..15 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 4 TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 5 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' not ok 6 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' not ok 10 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' not ok 11 TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 12 TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 13 testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' not ok 14 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' ok 15 testFuncSuccess1 # Ran 15 tests in 0.000 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/legacy_example_with_luaunit.lua0000644000175000017500000000645112777131552021265 0ustar vsevavsevaEXPORT_ASSERT_TO_GLOBALS = true require('luaunit') TestToto = {} --class function TestToto:setUp() -- set up tests self.a = 1 self.s = 'hop' self.t1 = {1,2,3} self.t2 = {one=1,two=2,three=3} self.t3 = {1,2,three=3} end function TestToto:test1_withFailure() print( "some stuff test 1" ) assertEquals( self.a , 1 ) -- will fail assertEquals( self.a , 2 ) assertEquals( self.a , 2 ) end function TestToto:test2_withFailure() print( "some stuff test 2" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) -- will fail assertEquals( self.s , 'bof' ) assertEquals( self.s , 'bof' ) end function TestToto:test3() print( "some stuff test 3" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) assertEquals( type(self.a), 'number' ) end function TestToto:test4() print( "some stuff test 4" ) assertNotEquals( self.a , 1 ) end function TestToto:test5() print( "some stuff test 5" ) assertTrue( self.a ) assertFalse( self.a ) end function TestToto:test6() print( "some stuff test 6" ) assertTrue( false ) end function TestToto:test7() -- assertEquals( {1,2}, self.t1 ) -- assertEquals( {1,2}, self.t2 ) assertEquals( {1,2}, self.t3 ) end function TestToto:test8a() -- failure occurs in a submethod self:funcWithError() end function TestToto:test8b() -- failure occurs in a submethod self:funcWithFuncWithError() end function TestToto:funcWithFuncWithError() self:funcWithError() end function TestToto:funcWithError() error('Bouhouhoum error!') end -- class TestToto TestTiti = {} --class function TestTiti:setUp() -- set up tests self.a = 1 self.s = 'hop' print( 'TestTiti:setUp' ) end function TestTiti:tearDown() -- some tearDown() code if necessary print( 'TestTiti:tearDown' ) end function TestTiti:test1_withFailure() print( "some stuff test 1" ) assertEquals( self.a , 1 ) -- will fail assertEquals( self.a , 2 ) assertEquals( self.a , 2 ) end function TestTiti:test2_withFailure() print( "some stuff test 2" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) -- will fail assertEquals( self.s , 'bof' ) assertEquals( self.s , 'bof' ) end function TestTiti:test3() print( "some stuff test 3" ) assertEquals( self.a , 1 ) assertEquals( self.s , 'hop' ) end -- class TestTiti -- simple test functions that were written previously can be integrated -- in luaunit too function test1_withFailure() assert( 1 == 1) -- will fail assert( 1 == 2) end function test2_withFailure() assert( 'a' == 'a') -- will fail assert( 'a' == 'b') end function test3() assert( 1 == 1) assert( 'a' == 'a') end local lu = LuaUnit.new() lu:setOutputType("tap") os.exit( lu:runSuite() ) tmpscZSVg/test/errFailPassTextDefault.txt0000644000175000017500000000350012777131574020131 0ustar vsevavseva..EEFF..FFEEEF. Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 2) TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 3) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 4) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 5) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 6) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 7) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 8) TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 9) testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 10) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/errFailPassXmlVerbose.txt0000644000175000017500000000324712777131575017777 0ustar vsevavseva# XML output to test/ref/errFailPassXmlVerbose.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test2_Err1 # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test2_Err2 # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: TestSomething.test3_Err1 # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value # Starting test: TestSomething.test3_Err2 # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value # Starting test: testFuncErr1 # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 15 tests in 0.004 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/exampleTapDefault.txt0000644000175000017500000000246112777131570017152 0ustar vsevavseva1..15 # Started on 01/30/16 22:19:36 # Starting class: TestTiti not ok 1 TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 not ok 2 TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" ok 3 TestTiti.test3 # Starting class: TestToto not ok 4 TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 not ok 5 TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" ok 6 TestToto.test3 not ok 7 TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 not ok 8 TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 not ok 9 TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false not ok 10 TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} not ok 11 TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! not ok 12 TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! not ok 13 test1_withFailure example_with_luaunit.lua:126: assertion failed! not ok 14 test2_withFailure example_with_luaunit.lua:132: assertion failed! ok 15 test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/exampleTextDefault.txt0000644000175000017500000000435312777131574017360 0ustar vsevavsevaFF.FF.FFFFEEEE. Failed tests: ------------- 1) TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 5) TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' 6) TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' 7) TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' 8) TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' 9) TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' 10) TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' 11) test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' 12) test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/errFailPassTextStopOnError-1.txt0000644000175000017500000000012312777131567021137 0ustar vsevavseva..... Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/exampleTapQuiet.txt0000644000175000017500000000111712777131570016652 0ustar vsevavseva1..15 # Started on 01/30/16 22:19:36 # Starting class: TestTiti not ok 1 TestTiti.test1_withFailure not ok 2 TestTiti.test2_withFailure ok 3 TestTiti.test3 # Starting class: TestToto not ok 4 TestToto.test1_withFailure not ok 5 TestToto.test2_withFailure ok 6 TestToto.test3 not ok 7 TestToto.test4 not ok 8 TestToto.test5 not ok 9 TestToto.test6 not ok 10 TestToto.test7 not ok 11 TestToto.test8a not ok 12 TestToto.test8b not ok 13 test1_withFailure not ok 14 test2_withFailure ok 15 test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/exampleXmlVerbose.xml0000644000175000017500000001106012777131575017170 0ustar vsevavseva tmpscZSVg/test/errFailPassXmlDefault-failures.txt0000644000175000017500000000201712777131575021560 0ustar vsevavseva# XML output to test/ref/errFailPassXmlDefault-failures.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 10 tests in 0.003 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassTapDefault-failures.txt0000644000175000017500000000154712777131570021546 0ustar vsevavseva1..10 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 not ok 4 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething ok 5 TestSomething.test1_Success1 ok 6 TestSomething.test1_Success2 not ok 7 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 not ok 8 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 not ok 9 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 ok 10 testFuncSuccess1 # Ran 10 tests in 0.000 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassTextVerbose.txt0000644000175000017500000000625512777131574020164 0ustar vsevavsevaStarted on 03/22/16 21:29:18 TestAnotherThing.test1_Success1 ... Ok TestAnotherThing.test1_Success2 ... Ok TestAnotherThing.test2_Err1 ... ERROR test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value TestAnotherThing.test2_Err2 ... ERROR test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value TestAnotherThing.test3_Fail1 ... FAIL test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 TestAnotherThing.test3_Fail2 ... FAIL test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 TestSomething.test1_Success1 ... Ok TestSomething.test1_Success2 ... Ok TestSomething.test2_Fail1 ... FAIL test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 TestSomething.test2_Fail2 ... FAIL test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 TestSomething.test3_Err1 ... ERROR test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value TestSomething.test3_Err2 ... ERROR test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value testFuncErr1 ... ERROR test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value testFuncFail1 ... FAIL test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 testFuncSuccess1 ... Ok ========================================================= Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 2) TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 3) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 4) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 5) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 6) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 7) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 8) TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 9) testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 10) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 15 tests in 0.001 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/errFailPassNilDefault-failures.txt0000644000175000017500000000000012777131567021531 0ustar vsevavsevatmpscZSVg/test/exampleTextQuiet.txt0000644000175000017500000000435312777131574017063 0ustar vsevavsevaFF.FF.FFFFEEEE. Failed tests: ------------- 1) TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 5) TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' 6) TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' 7) TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' 8) TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' 9) TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' 10) TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' 11) test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' 12) test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' Ran 15 tests in 0.012 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/errFailPassXmlVerbose-success.xml0000644000175000017500000000200312777131575021413 0ustar vsevavseva tmpscZSVg/test/exampleXmlDefault.xml0000644000175000017500000001106012777131574017146 0ustar vsevavseva tmpscZSVg/test/errFailPassNilDefault.txt0000644000175000017500000000000012777131567017721 0ustar vsevavsevatmpscZSVg/test/exampleTapVerbose.txt0000644000175000017500000000507212777131570017174 0ustar vsevavseva1..15 # Started on 01/30/16 22:19:36 # Starting class: TestTiti not ok 1 TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' not ok 2 TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' ok 3 TestTiti.test3 # Starting class: TestToto not ok 4 TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' not ok 5 TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' ok 6 TestToto.test3 not ok 7 TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' not ok 8 TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' not ok 9 TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' not ok 10 TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' not ok 11 TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' not ok 12 TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' not ok 13 test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' not ok 14 test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' ok 15 test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/testWithXmlDefault.txt0000644000175000017500000000102112777131571017336 0ustar vsevavseva# XML output to test/ref/testWithXmlDefault.xml # Started on 01/01/16 22:13:02 # Starting class: TestFailuresWithXml # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml # Failure: test/test_with_xml.lua:13: expected: "got it" actual: "cdata does not like ]]>" # Starting test: TestFailuresWithXml.test_failure_with_simple_xml # Failure: test/test_with_xml.lua:9: expected: "got it" actual: 'ti"ti' # Starting test: TestThatLastsALongTime # Ran 3 tests in 1.101 seconds, 1 success, 2 failures tmpscZSVg/test/errFailPassTextVerbose-failures.txt0000644000175000017500000000344312777131574021770 0ustar vsevavsevaStarted on 03/22/16 21:29:18 TestAnotherThing.test1_Success1 ... Ok TestAnotherThing.test1_Success2 ... Ok TestAnotherThing.test3_Fail1 ... FAIL test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 TestAnotherThing.test3_Fail2 ... FAIL test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 TestSomething.test1_Success1 ... Ok TestSomething.test1_Success2 ... Ok TestSomething.test2_Fail1 ... FAIL test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 TestSomething.test2_Fail2 ... FAIL test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 testFuncFail1 ... FAIL test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 testFuncSuccess1 ... Ok ========================================================= Failed tests: ------------- 1) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 2) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 3) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 4) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 5) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/test_with_err_fail_pass.lua0000644000175000017500000000271612777131552020415 0ustar vsevavsevalocal lu = require('luaunit') --[[ Test used by functional tests ]] TestSomething = {} --class function TestSomething:test1_Success1() lu.assertEquals( 1+1, 2 ) end function TestSomething:test1_Success2() lu.assertEquals( 1+2, 3 ) end function TestSomething:test2_Fail1() lu.assertEquals( 1+1, 0 ) end function TestSomething:test2_Fail2() lu.assertEquals( 1+2, 0 ) end function TestSomething:test3_Err1() local v = 1 + { 1,2 } end function TestSomething:test3_Err2() local v = 1 + { 1,2 } end TestAnotherThing = {} --class function TestAnotherThing:test1_Success1() lu.assertEquals( 1+1, 2 ) end function TestAnotherThing:test1_Success2() lu.assertEquals( 1+2, 3 ) end function TestAnotherThing:test2_Err1() local v = 1 + { 1,2 } end function TestAnotherThing:test2_Err2() local v = 1 + { 1,2 } end function TestAnotherThing:test3_Fail1() lu.assertEquals( 1+1, 0 ) end function TestAnotherThing:test3_Fail2() lu.assertEquals( 1+2, 0 ) end function testFuncSuccess1() lu.assertEquals( 1+1, 2 ) end function testFuncFail1() lu.assertEquals( 1+2, 0 ) end function testFuncErr1() local v = 1 + { 1,2 } end local runner = lu.LuaUnit.new() runner:setOutputType("text") os.exit( runner:runSuite() ) tmpscZSVg/test/errFailPassTextQuiet.txt0000644000175000017500000000350012777131574017634 0ustar vsevavseva..EEFF..FFEEEF. Failed tests: ------------- 1) TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 2) TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 3) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 4) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 5) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 6) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 7) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 8) TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 9) testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' 10) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/exampleXmlVerbose.txt0000644000175000017500000000301412777131575017207 0ustar vsevavseva# XML output to test/ref/exampleXmlVerbose.xml # Started on 01/30/16 22:19:37 # Starting class: TestTiti # Starting test: TestTiti.test1_withFailure # Failure: example_with_luaunit.lua:101: expected: 2, actual: 1 # Starting test: TestTiti.test2_withFailure # Failure: example_with_luaunit.lua:110: expected: "bof" actual: "hop" # Starting test: TestTiti.test3 # Starting class: TestToto # Starting test: TestToto.test1_withFailure # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 # Starting test: TestToto.test2_withFailure # Failure: example_with_luaunit.lua:30: expected: "bof" actual: "hop" # Starting test: TestToto.test3 # Starting test: TestToto.test4 # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 # Starting test: TestToto.test5 # Failure: example_with_luaunit.lua:49: expected: false, actual: 1 # Starting test: TestToto.test6 # Failure: example_with_luaunit.lua:54: expected: true, actual: false # Starting test: TestToto.test7 # Failure: example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} # Starting test: TestToto.test8a # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: TestToto.test8b # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: test1_withFailure # Error: example_with_luaunit.lua:126: assertion failed! # Starting test: test2_withFailure # Error: example_with_luaunit.lua:132: assertion failed! # Starting test: test3 # Ran 15 tests in 0.015 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/compat_luaunit_v2x.txt0000644000175000017500000000034612777131567017376 0ustar vsevavseva.............. Ran 14 tests in 0.000 seconds, 14 successes, 0 failures OK Use of WrapFunctions() is no longer needed. Just prefix your test function names with "test" or "Test" and they will be picked up and run by LuaUnit. tmpscZSVg/test/errFailPassXmlDefault.txt0000644000175000017500000000324712777131574017755 0ustar vsevavseva# XML output to test/ref/errFailPassXmlDefault.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test2_Err1 # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test2_Err2 # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: TestSomething.test3_Err1 # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value # Starting test: TestSomething.test3_Err2 # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value # Starting test: testFuncErr1 # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 15 tests in 0.004 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/exampleXmlDefault.txt0000644000175000017500000000301412777131574017165 0ustar vsevavseva# XML output to test/ref/exampleXmlDefault.xml # Started on 01/30/16 22:19:37 # Starting class: TestTiti # Starting test: TestTiti.test1_withFailure # Failure: example_with_luaunit.lua:101: expected: 2, actual: 1 # Starting test: TestTiti.test2_withFailure # Failure: example_with_luaunit.lua:110: expected: "bof" actual: "hop" # Starting test: TestTiti.test3 # Starting class: TestToto # Starting test: TestToto.test1_withFailure # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 # Starting test: TestToto.test2_withFailure # Failure: example_with_luaunit.lua:30: expected: "bof" actual: "hop" # Starting test: TestToto.test3 # Starting test: TestToto.test4 # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 # Starting test: TestToto.test5 # Failure: example_with_luaunit.lua:49: expected: false, actual: 1 # Starting test: TestToto.test6 # Failure: example_with_luaunit.lua:54: expected: true, actual: false # Starting test: TestToto.test7 # Failure: example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} # Starting test: TestToto.test8a # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: TestToto.test8b # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: test1_withFailure # Error: example_with_luaunit.lua:126: assertion failed! # Starting test: test2_withFailure # Error: example_with_luaunit.lua:132: assertion failed! # Starting test: test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/exampleXmlQuiet.txt0000644000175000017500000000301212777131575016667 0ustar vsevavseva# XML output to test/ref/exampleXmlQuiet.xml # Started on 01/30/16 22:19:37 # Starting class: TestTiti # Starting test: TestTiti.test1_withFailure # Failure: example_with_luaunit.lua:101: expected: 2, actual: 1 # Starting test: TestTiti.test2_withFailure # Failure: example_with_luaunit.lua:110: expected: "bof" actual: "hop" # Starting test: TestTiti.test3 # Starting class: TestToto # Starting test: TestToto.test1_withFailure # Failure: example_with_luaunit.lua:21: expected: 2, actual: 1 # Starting test: TestToto.test2_withFailure # Failure: example_with_luaunit.lua:30: expected: "bof" actual: "hop" # Starting test: TestToto.test3 # Starting test: TestToto.test4 # Failure: example_with_luaunit.lua:43: Received the not expected value: 1 # Starting test: TestToto.test5 # Failure: example_with_luaunit.lua:49: expected: false, actual: 1 # Starting test: TestToto.test6 # Failure: example_with_luaunit.lua:54: expected: true, actual: false # Starting test: TestToto.test7 # Failure: example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} # Starting test: TestToto.test8a # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: TestToto.test8b # Error: example_with_luaunit.lua:78: Bouhouhoum error! # Starting test: test1_withFailure # Error: example_with_luaunit.lua:126: assertion failed! # Starting test: test2_withFailure # Error: example_with_luaunit.lua:132: assertion failed! # Starting test: test3 # Ran 15 tests in 0.000 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/test_luaunit.lua0000644000175000017500000034762712777131552016247 0ustar vsevavseva--[[ Author: Philippe Fremy License: BSD License, see LICENSE.txt ]]-- -- Return a function that appends its arguments to the `callInfo` table local function callRecorder( callInfo ) return function( ... ) for i, v in pairs({...}) do table.insert( callInfo, v ) end end end -- This is a bit tricky since the test uses the features that it tests. local lu = require('luaunit') local Mock = { __class__ = 'Mock' } function Mock.new(runner) local t = lu.genericOutput.new(runner) t.calls = {} local t_MT = { __index = function( t, key ) local callInfo = { key } table.insert( t.calls, callInfo ) return callRecorder( callInfo ) end } return setmetatable( t, t_MT ) end TestMock = {} function TestMock:testMock() local m = Mock.new() m.titi( 42 ) m.toto( 33, "abc", { 21} ) lu.assertEquals( m.calls[1][1], 'titi' ) lu.assertEquals( m.calls[1][2], 42 ) lu.assertEquals( #m.calls[1], 2 ) lu.assertEquals( m.calls[2][1], 'toto' ) lu.assertEquals( m.calls[2][2], 33 ) lu.assertEquals( m.calls[2][3], 'abc' ) lu.assertEquals( m.calls[2][4][1], 21 ) lu.assertEquals( #m.calls[2], 4 ) lu.assertEquals( #m.calls, 2 ) end ------------------------------------------------------------------ -- -- Utility Tests -- ------------------------------------------------------------------ TestLuaUnitUtilities = { __class__ = 'TestLuaUnitUtilities' } function TestLuaUnitUtilities:test_genSortedIndex() lu.assertEquals( lu.private.__genSortedIndex( { 2, 5, 7} ), {1,2,3} ) lu.assertEquals( lu.private.__genSortedIndex( { a='1', h='2', c='3' } ), {'a', 'c', 'h'} ) lu.assertEquals( lu.private.__genSortedIndex( { 1, 'z', a='1', h='2', c='3' } ), { 1, 2, 'a', 'c', 'h' } ) lu.assertEquals( lu.private.__genSortedIndex( { b=4, a=3, true, foo="bar", nil, bar=false, 42, c=5 } ), { 1, 3, 'a', 'b', 'bar', 'c', 'foo' } ) end function TestLuaUnitUtilities:test_sortedNextWorks() local t1 = {} t1['aaa'] = 'abc' t1['ccc'] = 'def' t1['bbb'] = 'cba' -- mimic semantics of "generic for" loop local sortedNext, state = lu.private.sortedPairs(t1) local k, v = sortedNext( state, nil ) lu.assertEquals( k, 'aaa' ) lu.assertEquals( v, 'abc' ) k, v = sortedNext( state, k ) lu.assertEquals( k, 'bbb' ) lu.assertEquals( v, 'cba' ) k, v = sortedNext( state, k ) lu.assertEquals( k, 'ccc' ) lu.assertEquals( v, 'def' ) k, v = sortedNext( state, k ) lu.assertEquals( k, nil ) lu.assertEquals( v, nil ) -- check if starting the iteration a second time works k, v = sortedNext( state, nil ) lu.assertEquals( k, 'aaa' ) lu.assertEquals( v, 'abc' ) -- run a generic for loop (internally using a separate state) local tested = {} for k, v in lu.private.sortedPairs(t1) do table.insert(tested, v) end lu.assertEquals( tested, {'abc', 'cba', 'def'} ) -- test bisection algorithm by searching for non-existing key values k, v = sortedNext( state, '' ) -- '' would come before any of the keys lu.assertNil( k ) lu.assertNil( v ) k, v = sortedNext( state, 'xyz' ) -- 'xyz' would be after any other key lu.assertNil( k ) lu.assertNil( v ) -- finally let's see if we successfully find an "out of sequence" key k, v = sortedNext( state, 'bbb' ) lu.assertEquals( k, 'ccc' ) lu.assertEquals( v, 'def' ) end function TestLuaUnitUtilities:test_sortedNextWorksOnTwoTables() local t1 = { aaa = 'abc', ccc = 'def' } local t2 = { ['3'] = '33', ['1'] = '11' } local sortedNext, state1, state2 sortedNext, state1 = lu.private.sortedPairs(t1) sortedNext, state2 = lu.private.sortedPairs(t2) local k, v = sortedNext( state1, nil ) lu.assertEquals( k, 'aaa' ) lu.assertEquals( v, 'abc' ) k, v = sortedNext( state2, nil ) lu.assertEquals( k, '1' ) lu.assertEquals( v, '11' ) k, v = sortedNext( state1, 'aaa' ) lu.assertEquals( k, 'ccc' ) lu.assertEquals( v, 'def' ) k, v = sortedNext( state2, '1' ) lu.assertEquals( k, '3' ) lu.assertEquals( v, '33' ) end function TestLuaUnitUtilities:test_strSplitOneCharDelim() local t = lu.private.strsplit( '\n', '1\n22\n333\n' ) lu.assertEquals( t[1], '1') lu.assertEquals( t[2], '22') lu.assertEquals( t[3], '333') lu.assertEquals( t[4], '') lu.assertEquals( #t, 4 ) -- test invalid (empty) delimiter lu.assertErrorMsgContains('delimiter matches empty string!', lu.private.strsplit, '', '1\n22\n333\n') end function TestLuaUnitUtilities:test_strSplit3CharDelim() local t = lu.private.strsplit( '2\n3', '1\n22\n332\n3' ) lu.assertEquals( t[1], '1\n2') lu.assertEquals( t[2], '3') lu.assertEquals( t[3], '') lu.assertEquals( #t, 3 ) end function TestLuaUnitUtilities:test_protectedCall() local function boom() error("Something went wrong.") end local err = lu.LuaUnit:protectedCall(nil, boom, "kaboom") -- check that err received the expected fields lu.assertEquals(err.status, "ERROR") lu.assertStrContains(err.msg, "Something went wrong.") lu.assertStrMatches(err.trace, "^stack traceback:.*in %a+ 'kaboom'.*") end function TestLuaUnitUtilities:test_prefixString() lu.assertEquals( lu.private.prefixString( '12 ', 'ab\ncd\nde'), '12 ab\n12 cd\n12 de' ) end function TestLuaUnitUtilities:test_is_table_equals() -- Make sure that _is_table_equals() doesn't fall for these traps -- (See https://github.com/bluebird75/luaunit/issues/48) local A, B, C = {}, {}, {} A.self = A B.self = B lu.assertNotEquals(A, B) lu.assertEquals(A, A) A, B = {}, {} A.circular = C B.circular = A C.circular = B lu.assertNotEquals(A, B) lu.assertEquals(C, C) end function TestLuaUnitUtilities:test_table_keytostring() lu.assertEquals( lu.private._table_keytostring( 'a' ), 'a' ) lu.assertEquals( lu.private._table_keytostring( 'a0' ), 'a0' ) lu.assertEquals( lu.private._table_keytostring( 'a0!' ), '"a0!"' ) end function TestLuaUnitUtilities:test_prettystr() lu.assertEquals( lu.prettystr( 1 ), "1" ) lu.assertEquals( lu.prettystr( 1.1 ), "1.1" ) lu.assertEquals( lu.prettystr( 'abc' ), '"abc"' ) lu.assertEquals( lu.prettystr( 'ab\ncd' ), '"ab\ncd"' ) lu.assertEquals( lu.prettystr( 'ab\ncd', true ), '"ab\\ncd"' ) lu.assertEquals( lu.prettystr( 'ab"cd' ), "'ab\"cd'" ) lu.assertEquals( lu.prettystr( "ab'cd" ), '"ab\'cd"' ) lu.assertEquals( lu.prettystr( {1,2,3} ), "{1, 2, 3}" ) lu.assertEquals( lu.prettystr( {a=1,bb=2,ab=3} ), '{a=1, ab=3, bb=2}' ) lu.assertEquals( lu.prettystr( { [{}] = 1 }), '{{}=1}' ) lu.assertEquals( lu.prettystr( { 1, [{}] = 1, 2 }), '{1, 2, {}=1}' ) lu.assertEquals( lu.prettystr( { 1, [{one=1}] = 1, 2, "test", false }), '{1, 2, "test", false, {one=1}=1}' ) end function TestLuaUnitUtilities:test_prettystr_adv_tables() local t1 = {1,2,3,4,5,6} lu.assertEquals(lu.prettystr(t1), "{1, 2, 3, 4, 5, 6}" ) local t2 = {'aaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbb', 'ccccccccccccccccc', 'ddddddddddddd', 'eeeeeeeeeeeeeeeeee', 'ffffffffffffffff', 'ggggggggggg', 'hhhhhhhhhhhhhh'} lu.assertEquals(lu.prettystr(t2), table.concat( { '{', ' "aaaaaaaaaaaaaaaaa",', ' "bbbbbbbbbbbbbbbbbbbb",', ' "ccccccccccccccccc",', ' "ddddddddddddd",', ' "eeeeeeeeeeeeeeeeee",', ' "ffffffffffffffff",', ' "ggggggggggg",', ' "hhhhhhhhhhhhhh"', '}', } , '\n' ) ) local t2bis = { 1,2,3,'12345678901234567890123456789012345678901234567890123456789012345678901234567890', 4,5,6 } lu.assertEquals(lu.prettystr(t2bis), [[{ 1, 2, 3, "12345678901234567890123456789012345678901234567890123456789012345678901234567890", 4, 5, 6 }]] ) local t3 = { l1a = { l2a = { l3a='012345678901234567890123456789012345678901234567890123456789' }, l2b='bbb' }, l1b = 4} lu.assertEquals(lu.prettystr(t3), [[{ l1a={ l2a={l3a="012345678901234567890123456789012345678901234567890123456789"}, l2b="bbb" }, l1b=4 }]] ) local t4 = { a=1, b=2, c=3 } lu.assertEquals(lu.prettystr(t4), '{a=1, b=2, c=3}' ) local t5 = { t1, t2, t3 } lu.assertEquals( lu.prettystr(t5), [[{ {1, 2, 3, 4, 5, 6}, { "aaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbb", "ccccccccccccccccc", "ddddddddddddd", "eeeeeeeeeeeeeeeeee", "ffffffffffffffff", "ggggggggggg", "hhhhhhhhhhhhhh" }, { l1a={ l2a={l3a="012345678901234567890123456789012345678901234567890123456789"}, l2b="bbb" }, l1b=4 } }]] ) local t6 = { t1=t1, t2=t2, t3=t3, t4=t4 } lu.assertEquals(lu.prettystr(t6),[[{ t1={1, 2, 3, 4, 5, 6}, t2={ "aaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbb", "ccccccccccccccccc", "ddddddddddddd", "eeeeeeeeeeeeeeeeee", "ffffffffffffffff", "ggggggggggg", "hhhhhhhhhhhhhh" }, t3={ l1a={ l2a={l3a="012345678901234567890123456789012345678901234567890123456789"}, l2b="bbb" }, l1b=4 }, t4={a=1, b=2, c=3} }]]) end function TestLuaUnitUtilities:test_prettystrTableRecursion() local t = {} t.__index = t lu.assertStrMatches(lu.prettystr(t), " {__index=}") local t1 = {} local t2 = {} t1.t2 = t2 t2.t1 = t1 local t3 = { t1 = t1, t2 = t2 } lu.assertStrMatches(lu.prettystr(t1), " {t2= {t1=}}") lu.assertStrMatches(lu.prettystr(t3), [[ { t1= {t2= {t1=}}, t2= }]]) local t4 = {1,2} local t5 = {3,4,t4} t4[3] = t5 lu.assertStrMatches(lu.prettystr(t5), " {3, 4, {1, 2, }}") end function TestLuaUnitUtilities:test_prettystrPadded() local foo, bar, str1, str2 -- test all combinations of: foo = nil, "foo", "fo\no" (embedded -- newline); and bar = nil, "bar", "bar\n" (trailing newline) str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, "nil") lu.assertEquals(str2, "nil") str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, "nil_B") lu.assertEquals(str2, "nil") bar = "bar" str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, "nil") lu.assertEquals(str2, '"bar"') str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, "nil_B") lu.assertEquals(str2, '"bar"') bar = "bar\n" str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, "\nnil") lu.assertEquals(str2, '\n"bar\n"') str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, "\nnil_A") lu.assertEquals(str2, '\n"bar\n"') foo = "foo" bar = nil str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, '"foo"') lu.assertEquals(str2, "nil") str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, '"foo"_B') lu.assertEquals(str2, "nil") bar = "bar" str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, '"foo"') lu.assertEquals(str2, '"bar"') str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, '"foo"_B') lu.assertEquals(str2, '"bar"') bar = "bar\n" str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, '\n"foo"') lu.assertEquals(str2, '\n"bar\n"') str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, '\n"foo"_A') lu.assertEquals(str2, '\n"bar\n"') foo = "fo\no" bar = nil str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, '\n"fo\no"') lu.assertEquals(str2, "\nnil") str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, '\n"fo\no"_A') lu.assertEquals(str2, "\nnil") bar = "bar" str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, '\n"fo\no"') lu.assertEquals(str2, '\n"bar"') str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, '\n"fo\no"_A') lu.assertEquals(str2, '\n"bar"') bar = "bar\n" str1, str2 = lu.private.prettystrPadded(foo, bar) lu.assertEquals(str1, '\n"fo\no"') lu.assertEquals(str2, '\n"bar\n"') str1, str2 = lu.private.prettystrPadded(foo, bar, "_A", "_B") lu.assertEquals(str1, '\n"fo\no"_A') lu.assertEquals(str2, '\n"bar\n"') end function TestLuaUnitUtilities:test_FailFmt() -- raise failure from within nested functions local function bar(level) lu.private.fail_fmt(level, "hex=%X", 123) end local function foo(level) bar(level) end local _, err = pcall(foo) -- default level 1 = error position in bar() local line1, prefix = err:match("test[\\/]test_luaunit%.lua:(%d+): (.*)hex=7B$") lu.assertEquals(prefix, lu.FAILURE_PREFIX) lu.assertNotNil(line1) _, err = pcall(foo, 2) -- level 2 = error position within foo() local line2, prefix = err:match("test[\\/]test_luaunit%.lua:(%d+): (.*)hex=7B$") lu.assertEquals(prefix, lu.FAILURE_PREFIX) lu.assertNotNil(line2) -- make sure that "line2" position is exactly 3 lines after "line1" lu.assertEquals(tonumber(line2), tonumber(line1) + 3) end function TestLuaUnitUtilities:test_IsFunction() -- previous LuaUnit.isFunction was superseded by LuaUnit.asFunction -- (which can also serve as a boolean expression) lu.assertNotNil( lu.LuaUnit.asFunction( function (a,b) end ) ) lu.assertNil( lu.LuaUnit.asFunction( nil ) ) lu.assertNil( lu.LuaUnit.asFunction( "not a function" ) ) end function TestLuaUnitUtilities:test_IsClassMethod() lu.assertEquals( lu.LuaUnit.isClassMethod( 'toto' ), false ) lu.assertEquals( lu.LuaUnit.isClassMethod( 'toto.titi' ), true ) end function TestLuaUnitUtilities:test_splitClassMethod() lu.assertEquals( lu.LuaUnit.splitClassMethod( 'toto' ), nil ) local v1, v2 = lu.LuaUnit.splitClassMethod( 'toto.titi' ) lu.assertEquals( {v1, v2}, {'toto', 'titi'} ) end function TestLuaUnitUtilities:test_isTestName() lu.assertEquals( lu.LuaUnit.isTestName( 'testToto' ), true ) lu.assertEquals( lu.LuaUnit.isTestName( 'TestToto' ), true ) lu.assertEquals( lu.LuaUnit.isTestName( 'TESTToto' ), true ) lu.assertEquals( lu.LuaUnit.isTestName( 'xTESTToto' ), false ) lu.assertEquals( lu.LuaUnit.isTestName( '' ), false ) end function TestLuaUnitUtilities:test_parseCmdLine() --test names lu.assertEquals( lu.LuaUnit.parseCmdLine(), {} ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { 'someTest' } ), { testNames={'someTest'} } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { 'someTest', 'someOtherTest' } ), { testNames={'someTest', 'someOtherTest'} } ) -- verbosity lu.assertEquals( lu.LuaUnit.parseCmdLine( { '--verbose' } ), { verbosity=lu.VERBOSITY_VERBOSE } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-v' } ), { verbosity=lu.VERBOSITY_VERBOSE } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '--quiet' } ), { verbosity=lu.VERBOSITY_QUIET } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-q' } ), { verbosity=lu.VERBOSITY_QUIET } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-v', '-q' } ), { verbosity=lu.VERBOSITY_QUIET } ) --output lu.assertEquals( lu.LuaUnit.parseCmdLine( { '--output', 'toto' } ), { output='toto'} ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-o', 'toto' } ), { output='toto'} ) lu.assertErrorMsgContains( 'Missing argument after -o', lu.LuaUnit.parseCmdLine, { '-o', } ) --name lu.assertEquals( lu.LuaUnit.parseCmdLine( { '--name', 'toto' } ), { fname='toto'} ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-n', 'toto' } ), { fname='toto'} ) lu.assertErrorMsgContains( 'Missing argument after -n', lu.LuaUnit.parseCmdLine, { '-n', } ) --patterns lu.assertEquals( lu.LuaUnit.parseCmdLine( { '--pattern', 'toto' } ), { pattern={'toto'} } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-p', 'toto' } ), { pattern={'toto'} } ) lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-p', 'titi', '-p', 'toto' } ), { pattern={'titi', 'toto'} } ) lu.assertErrorMsgContains( 'Missing argument after -p', lu.LuaUnit.parseCmdLine, { '-p', } ) --megamix lu.assertEquals( lu.LuaUnit.parseCmdLine( { '-p', 'toto', 'titi', '-v', 'tata', '-o', 'tintin', '-p', 'tutu', 'prout', '-n', 'toto.xml' } ), { pattern={'toto', 'tutu'}, verbosity=lu.VERBOSITY_VERBOSE, output='tintin', testNames={'titi', 'tata', 'prout'}, fname='toto.xml' } ) lu.assertErrorMsgContains( 'option: -x', lu.LuaUnit.parseCmdLine, { '-x', } ) end function TestLuaUnitUtilities:test_includePattern() lu.assertEquals( lu.LuaUnit.patternInclude( nil, 'toto'), true ) lu.assertEquals( lu.LuaUnit.patternInclude( {}, 'toto'), false ) lu.assertEquals( lu.LuaUnit.patternInclude( {'toto'}, 'toto'), true ) lu.assertEquals( lu.LuaUnit.patternInclude( {'toto'}, 'yyytotoxxx'), true ) lu.assertEquals( lu.LuaUnit.patternInclude( {'titi', 'toto'}, 'yyytotoxxx'), true ) lu.assertEquals( lu.LuaUnit.patternInclude( {'titi', 'to..'}, 'yyytoxxx'), true ) end function TestLuaUnitUtilities:test_applyPatternFilter() local myTestToto1Value = { 'MyTestToto1.test1', MyTestToto1 } local included, excluded = lu.LuaUnit.applyPatternFilter( nil, { myTestToto1Value } ) lu.assertEquals( excluded, {} ) lu.assertEquals( included, { myTestToto1Value } ) included, excluded = lu.LuaUnit.applyPatternFilter( {'T.to'}, { myTestToto1Value } ) lu.assertEquals( excluded, {} ) lu.assertEquals( included, { myTestToto1Value } ) included, excluded = lu.LuaUnit.applyPatternFilter( {'T.ti'}, { myTestToto1Value } ) lu.assertEquals( excluded, { myTestToto1Value } ) lu.assertEquals( included, {} ) end function TestLuaUnitUtilities:test_strMatch() lu.assertEquals( lu.private.strMatch('toto', 't.t.'), true ) lu.assertEquals( lu.private.strMatch('toto', 't.t.', 1, 4), true ) lu.assertEquals( lu.private.strMatch('toto', 't.t.', 2, 5), false ) lu.assertEquals( lu.private.strMatch('toto', '.t.t.'), false ) lu.assertEquals( lu.private.strMatch('ototo', 't.t.'), false ) lu.assertEquals( lu.private.strMatch('totot', 't.t.'), false ) lu.assertEquals( lu.private.strMatch('ototot', 't.t.'), false ) lu.assertEquals( lu.private.strMatch('ototot', 't.t.',2,3), false ) lu.assertEquals( lu.private.strMatch('ototot', 't.t.',2,5), true ) lu.assertEquals( lu.private.strMatch('ototot', 't.t.',2,6), false ) end function TestLuaUnitUtilities:test_expandOneClass() local result = {} lu.LuaUnit.expandOneClass( result, 'titi', {} ) lu.assertEquals( result, {} ) result = {} lu.LuaUnit.expandOneClass( result, 'MyTestToto1', MyTestToto1 ) lu.assertEquals( result, { {'MyTestToto1.test1', MyTestToto1 }, {'MyTestToto1.test2', MyTestToto1 }, {'MyTestToto1.test3', MyTestToto1 }, {'MyTestToto1.testa', MyTestToto1 }, {'MyTestToto1.testb', MyTestToto1 }, } ) end function TestLuaUnitUtilities:test_expandClasses() local result = {} result = lu.LuaUnit.expandClasses( {} ) lu.assertEquals( result, {} ) result = lu.LuaUnit.expandClasses( { { 'MyTestFunction', MyTestFunction } } ) lu.assertEquals( result, { { 'MyTestFunction', MyTestFunction } } ) result = lu.LuaUnit.expandClasses( { { 'MyTestToto1.test1', MyTestToto1 } } ) lu.assertEquals( result, { { 'MyTestToto1.test1', MyTestToto1 } } ) result = lu.LuaUnit.expandClasses( { { 'MyTestToto1', MyTestToto1 } } ) lu.assertEquals( result, { {'MyTestToto1.test1', MyTestToto1 }, {'MyTestToto1.test2', MyTestToto1 }, {'MyTestToto1.test3', MyTestToto1 }, {'MyTestToto1.testa', MyTestToto1 }, {'MyTestToto1.testb', MyTestToto1 }, } ) end function TestLuaUnitUtilities:test_xmlEscape() lu.assertEquals( lu.private.xmlEscape( 'abc' ), 'abc' ) lu.assertEquals( lu.private.xmlEscape( 'a"bc' ), 'a"bc' ) lu.assertEquals( lu.private.xmlEscape( "a'bc" ), 'a'bc' ) lu.assertEquals( lu.private.xmlEscape( "a" ), 'a<b&c>' ) end function TestLuaUnitUtilities:test_xmlCDataEscape() lu.assertEquals( lu.private.xmlCDataEscape( 'abc' ), 'abc' ) lu.assertEquals( lu.private.xmlCDataEscape( 'a"bc' ), 'a"bc' ) lu.assertEquals( lu.private.xmlCDataEscape( "a'bc" ), "a'bc" ) lu.assertEquals( lu.private.xmlCDataEscape( "a" ), 'a' ) lu.assertEquals( lu.private.xmlCDataEscape( "a--" ), 'a [C]: in function 'xpcall' ./luaunit.lua:1449: in function 'protectedCall' ./luaunit.lua:1508: in function 'execOneFunction' ./luaunit.lua:1596: in function 'runSuiteByInstances' ./luaunit.lua:1660: in function 'runSuiteByNames' ./luaunit.lua:1736: in function 'runSuite' example_with_luaunit.lua:140: in main chunk [C]: in ?]] local realStackTrace2=[[stack traceback: ./luaunit.lua:545: in function 'lu.assertEquals' example_with_luaunit.lua:58: in function 'TestToto.test7' ./luaunit.lua:1517: in function <./luaunit.lua:1517> [C]: in function 'xpcall' ./luaunit.lua:1517: in function 'protectedCall' ./luaunit.lua:1578: in function 'execOneFunction' ./luaunit.lua:1677: in function 'runSuiteByInstances' ./luaunit.lua:1730: in function 'runSuiteByNames' ./luaunit.lua:1806: in function 'runSuite' example_with_luaunit.lua:140: in main chunk [C]: in ?]] local realStackTrace3 = [[stack traceback: luaunit2/example_with_luaunit.lua:124: in function 'test1_withFailure' luaunit2/luaunit.lua:1532: in function [C]: in function 'xpcall' luaunit2/luaunit.lua:1532: in function 'protectedCall' luaunit2/luaunit.lua:1591: in function 'execOneFunction' luaunit2/luaunit.lua:1679: in function 'runSuiteByInstances' luaunit2/luaunit.lua:1743: in function 'runSuiteByNames' luaunit2/luaunit.lua:1819: in function 'runSuite' luaunit2/example_with_luaunit.lua:140: in main chunk [C]: in ?]] local strippedStackTrace=lu.private.stripLuaunitTrace( realStackTrace ) -- print( strippedStackTrace ) local expectedStackTrace=[[stack traceback: example_with_luaunit.lua:130: in function 'test2_withFailure']] lu.assertEquals( strippedStackTrace, expectedStackTrace ) strippedStackTrace=lu.private.stripLuaunitTrace( realStackTrace2 ) expectedStackTrace=[[stack traceback: example_with_luaunit.lua:58: in function 'TestToto.test7']] lu.assertEquals( strippedStackTrace, expectedStackTrace ) strippedStackTrace=lu.private.stripLuaunitTrace( realStackTrace3 ) expectedStackTrace=[[stack traceback: luaunit2/example_with_luaunit.lua:124: in function 'test1_withFailure']] lu.assertEquals( strippedStackTrace, expectedStackTrace ) end ------------------------------------------------------------------ -- -- Assertion Tests -- ------------------------------------------------------------------ local function assertFailure( ... ) -- ensure that execution generates a failure type error lu.assertErrorMsgMatches(lu.FAILURE_PREFIX .. ".*", ...) end local function assertBadFindArgTable( ... ) lu.assertErrorMsgMatches( ".* bad argument .* to 'find' %(string expected, got table%)", ...) end local function assertBadFindArgNil( ... ) lu.assertErrorMsgMatches( ".* bad argument .* to 'find' %(string expected, got nil%)", ...) end local function assertBadIndexNumber( ... ) lu.assertErrorMsgMatches( ".* attempt to index .*a number value.*", ... ) end local function assertBadIndexNil( ... ) lu.assertErrorMsgMatches( ".* attempt to index .*a nil value.*", ... ) end local function assertBadMethodNil( ... ) lu.assertErrorMsgMatches( ".* attempt to call .*a nil value.*", ... ) end TestLuaUnitAssertions = { __class__ = 'TestLuaUnitAssertions' } function TestLuaUnitAssertions:test_assertEquals() local f = function() return true end local g = function() return true end lu.assertEquals( 1, 1 ) lu.assertEquals( "abc", "abc" ) lu.assertEquals( nil, nil ) lu.assertEquals( true, true ) lu.assertEquals( f, f) lu.assertEquals( {1,2,3}, {1,2,3}) lu.assertEquals( {one=1,two=2,three=3}, {one=1,two=2,three=3}) lu.assertEquals( {one=1,two=2,three=3}, {two=2,three=3,one=1}) lu.assertEquals( {one=1,two={1,2},three=3}, {two={1,2},three=3,one=1}) lu.assertEquals( {one=1,two={1,{2,nil}},three=3}, {two={1,{2,nil}},three=3,one=1}) lu.assertEquals( {nil}, {nil} ) local config_saved = lu.TABLE_EQUALS_KEYBYCONTENT lu.TABLE_EQUALS_KEYBYCONTENT = false assertFailure( lu.assertEquals, {[{}] = 1}, { [{}] = 1}) assertFailure( lu.assertEquals, {[{one=1, two=2}] = 1}, { [{two=2, one=1}] = 1}) lu.TABLE_EQUALS_KEYBYCONTENT = true lu.assertEquals( {[{}] = 1}, { [{}] = 1}) lu.assertEquals( {[{one=1, two=2}] = 1}, { [{two=2, one=1}] = 1}) assertFailure( lu.assertEquals, 1, 2) assertFailure( lu.assertEquals, 1, "abc" ) assertFailure( lu.assertEquals, 0, nil ) assertFailure( lu.assertEquals, false, nil ) assertFailure( lu.assertEquals, true, 1 ) assertFailure( lu.assertEquals, f, 1 ) assertFailure( lu.assertEquals, f, g ) assertFailure( lu.assertEquals, {1,2,3}, {2,1,3} ) assertFailure( lu.assertEquals, {1,2,3}, nil ) assertFailure( lu.assertEquals, {1,2,3}, 1 ) assertFailure( lu.assertEquals, {1,2,3}, true ) assertFailure( lu.assertEquals, {1,2,3}, {one=1,two=2,three=3} ) assertFailure( lu.assertEquals, {1,2,3}, {one=1,two=2,three=3,four=4} ) assertFailure( lu.assertEquals, {one=1,two=2,three=3}, {2,1,3} ) assertFailure( lu.assertEquals, {one=1,two=2,three=3}, nil ) assertFailure( lu.assertEquals, {one=1,two=2,three=3}, 1 ) assertFailure( lu.assertEquals, {one=1,two=2,three=3}, true ) assertFailure( lu.assertEquals, {one=1,two=2,three=3}, {1,2,3} ) assertFailure( lu.assertEquals, {one=1,two={1,2},three=3}, {two={2,1},three=3,one=1}) lu.TABLE_EQUALS_KEYBYCONTENT = true -- without it, these tests won't pass anyway assertFailure( lu.assertEquals, {[{}] = 1}, {[{}] = 2}) assertFailure( lu.assertEquals, {[{}] = 1}, {[{one=1}] = 2}) assertFailure( lu.assertEquals, {[{}] = 1}, {[{}] = 1, 2}) assertFailure( lu.assertEquals, {[{}] = 1}, {[{}] = 1, [{}] = 1}) lu.TABLE_EQUALS_KEYBYCONTENT = config_saved end function TestLuaUnitAssertions:test_assertAlmostEquals() lu.assertAlmostEquals( 1, 1, 0.1 ) lu.assertAlmostEquals( 1, 1, 0 ) -- zero margin lu.assertAlmostEquals( 1, 1.1, 0.2 ) lu.assertAlmostEquals( -1, -1.1, 0.2 ) lu.assertAlmostEquals( 0.1, -0.1, 0.3 ) lu.assertAlmostEquals( 1, 1.1, 0.1 ) lu.assertAlmostEquals( -1, -1.1, 0.1 ) lu.assertAlmostEquals( 0.1, -0.1, 0.2 ) assertFailure( lu.assertAlmostEquals, 1, 1.11, 0.1 ) assertFailure( lu.assertAlmostEquals, -1, -1.11, 0.1 ) lu.assertErrorMsgContains( "must supply only number arguments", lu.assertAlmostEquals, -1, 1, nil ) lu.assertErrorMsgContains( "must supply only number arguments", lu.assertAlmostEquals, -1, nil, 0 ) lu.assertErrorMsgContains( "must supply only number arguments", lu.assertAlmostEquals, nil, 1, 0 ) lu.assertErrorMsgContains( "margin must not be negative", lu.assertAlmostEquals, 1, 1.1, -0.1 ) end function TestLuaUnitAssertions:test_assertNotEquals() local f = function() return true end local g = function() return true end lu.assertNotEquals( 1, 2 ) lu.assertNotEquals( "abc", 2 ) lu.assertNotEquals( "abc", "def" ) lu.assertNotEquals( 1, 2) lu.assertNotEquals( 1, "abc" ) lu.assertNotEquals( 0, nil ) lu.assertNotEquals( false, nil ) lu.assertNotEquals( true, 1 ) lu.assertNotEquals( f, 1 ) lu.assertNotEquals( f, g ) lu.assertNotEquals( {one=1,two=2,three=3}, true ) lu.assertNotEquals( {one=1,two={1,2},three=3}, {two={2,1},three=3,one=1} ) assertFailure( lu.assertNotEquals, 1, 1) assertFailure( lu.assertNotEquals, "abc", "abc" ) assertFailure( lu.assertNotEquals, nil, nil ) assertFailure( lu.assertNotEquals, true, true ) assertFailure( lu.assertNotEquals, f, f) assertFailure( lu.assertNotEquals, {one=1,two={1,{2,nil}},three=3}, {two={1,{2,nil}},three=3,one=1}) end function TestLuaUnitAssertions:test_assertNotAlmostEquals() lu.assertNotAlmostEquals( 1, 1.2, 0.1 ) lu.assertNotAlmostEquals( 1, 1.01, 0 ) -- zero margin lu.assertNotAlmostEquals( 1, 1.3, 0.2 ) lu.assertNotAlmostEquals( -1, -1.3, 0.2 ) lu.assertNotAlmostEquals( 0.1, -0.1, 0.1 ) lu.assertNotAlmostEquals( 1, 1.1, 0.09 ) lu.assertNotAlmostEquals( -1, -1.1, 0.09 ) lu.assertNotAlmostEquals( 0.1, -0.1, 0.11 ) assertFailure( lu.assertNotAlmostEquals, 1, 1.11, 0.2 ) assertFailure( lu.assertNotAlmostEquals, -1, -1.11, 0.2 ) lu.assertErrorMsgContains( "must supply only number arguments", lu.assertNotAlmostEquals, -1, 1, nil ) lu.assertErrorMsgContains( "must supply only number arguments", lu.assertNotAlmostEquals, -1, nil, 0 ) lu.assertErrorMsgContains( "must supply only number arguments", lu.assertNotAlmostEquals, nil, 1, 0 ) lu.assertErrorMsgContains( "margin must not be negative", lu.assertNotAlmostEquals, 1, 1.1, -0.1 ) end function TestLuaUnitAssertions:test_assertNotEqualsDifferentTypes2() lu.assertNotEquals( 2, "abc" ) end function TestLuaUnitAssertions:test_assertTrue() lu.assertTrue(true) assertFailure( lu.assertTrue, false) lu.assertTrue(0) lu.assertTrue(1) lu.assertTrue("") lu.assertTrue("abc") assertFailure( lu.assertTrue, nil ) lu.assertTrue( function() return true end ) lu.assertTrue( {} ) lu.assertTrue( { 1 } ) end function TestLuaUnitAssertions:test_assertFalse() lu.assertFalse(false) assertFailure( lu.assertFalse, true) lu.assertFalse( nil ) assertFailure( lu.assertFalse, 0 ) assertFailure( lu.assertFalse, 1 ) assertFailure( lu.assertFalse, "" ) assertFailure( lu.assertFalse, "abc" ) assertFailure( lu.assertFalse, function() return true end ) assertFailure( lu.assertFalse, {} ) assertFailure( lu.assertFalse, { 1 } ) end function TestLuaUnitAssertions:test_assertNil() lu.assertNil(nil) assertFailure( lu.assertTrue, false) assertFailure( lu.assertNil, 0) assertFailure( lu.assertNil, "") assertFailure( lu.assertNil, "abc") assertFailure( lu.assertNil, function() return true end ) assertFailure( lu.assertNil, {} ) assertFailure( lu.assertNil, { 1 } ) end function TestLuaUnitAssertions:test_assertNotNil() assertFailure( lu.assertNotNil, nil) lu.assertNotNil( false ) lu.assertNotNil( 0 ) lu.assertNotNil( "" ) lu.assertNotNil( "abc" ) lu.assertNotNil( function() return true end ) lu.assertNotNil( {} ) lu.assertNotNil( { 1 } ) end function TestLuaUnitAssertions:test_assertStrContains() lu.assertStrContains( 'abcdef', 'abc' ) lu.assertStrContains( 'abcdef', 'bcd' ) lu.assertStrContains( 'abcdef', 'abcdef' ) lu.assertStrContains( 'abc0', 0 ) assertFailure( lu.assertStrContains, 'ABCDEF', 'abc' ) assertFailure( lu.assertStrContains, '', 'abc' ) lu.assertStrContains( 'abcdef', '' ) assertFailure( lu.assertStrContains, 'abcdef', 'abcx' ) assertFailure( lu.assertStrContains, 'abcdef', 'abcdefg' ) assertFailure( lu.assertStrContains, 'abcdef', 0 ) assertBadFindArgTable( lu.assertStrContains, 'abcdef', {} ) assertBadFindArgNil( lu.assertStrContains, 'abcdef', nil ) lu.assertStrContains( 'abcdef', 'abc', false ) lu.assertStrContains( 'abcdef', 'abc', true ) lu.assertStrContains( 'abcdef', 'a.c', true ) assertFailure( lu.assertStrContains, 'abcdef', '.abc', true ) end function TestLuaUnitAssertions:test_assertStrIContains() lu.assertStrIContains( 'ABcdEF', 'aBc' ) lu.assertStrIContains( 'abCDef', 'bcd' ) lu.assertStrIContains( 'abcdef', 'abcDef' ) assertFailure( lu.assertStrIContains, '', 'aBc' ) lu.assertStrIContains( 'abcDef', '' ) assertFailure( lu.assertStrIContains, 'abcdef', 'abcx' ) assertFailure( lu.assertStrIContains, 'abcdef', 'abcdefg' ) end function TestLuaUnitAssertions:test_assertNotStrContains() assertFailure( lu.assertNotStrContains, 'abcdef', 'abc' ) assertFailure( lu.assertNotStrContains, 'abcdef', 'bcd' ) assertFailure( lu.assertNotStrContains, 'abcdef', 'abcdef' ) lu.assertNotStrContains( '', 'abc' ) assertFailure( lu.assertNotStrContains, 'abcdef', '' ) assertFailure( lu.assertNotStrContains, 'abc0', 0 ) lu.assertNotStrContains( 'abcdef', 'abcx' ) lu.assertNotStrContains( 'abcdef', 'abcdefg' ) assertBadFindArgTable( lu.assertNotStrContains, 'abcdef', {} ) assertBadFindArgNil( lu.assertNotStrContains, 'abcdef', nil ) assertFailure( lu.assertNotStrContains, 'abcdef', 'abc', false ) assertFailure( lu.assertNotStrContains, 'abcdef', 'a.c', true ) lu.assertNotStrContains( 'abcdef', 'a.cx', true ) end function TestLuaUnitAssertions:test_assertNotStrIContains() assertFailure( lu.assertNotStrIContains, 'aBcdef', 'abc' ) assertFailure( lu.assertNotStrIContains, 'abcdef', 'aBc' ) assertFailure( lu.assertNotStrIContains, 'abcdef', 'bcd' ) assertFailure( lu.assertNotStrIContains, 'abcdef', 'abcdef' ) lu.assertNotStrIContains( '', 'abc' ) assertFailure( lu.assertNotStrIContains, 'abcdef', '' ) assertBadIndexNumber( lu.assertNotStrIContains, 'abc0', 0 ) lu.assertNotStrIContains( 'abcdef', 'abcx' ) lu.assertNotStrIContains( 'abcdef', 'abcdefg' ) assertBadMethodNil( lu.assertNotStrIContains, 'abcdef', {} ) assertBadIndexNil( lu.assertNotStrIContains, 'abcdef', nil ) end function TestLuaUnitAssertions:test_assertStrMatches() lu.assertStrMatches( 'abcdef', 'abcdef' ) lu.assertStrMatches( 'abcdef', '..cde.' ) assertFailure( lu.assertStrMatches, 'abcdef', '..def') assertFailure( lu.assertStrMatches, 'abCDEf', '..cde.') lu.assertStrMatches( 'abcdef', 'bcdef', 2 ) lu.assertStrMatches( 'abcdef', 'bcde', 2, 5 ) lu.assertStrMatches( 'abcdef', 'b..e', 2, 5 ) lu.assertStrMatches( 'abcdef', 'ab..e', nil, 5 ) assertFailure( lu.assertStrMatches, 'abcdef', '' ) assertFailure( lu.assertStrMatches, '', 'abcdef' ) assertFailure( lu.assertStrMatches, 'abcdef', 0 ) assertBadFindArgTable( lu.assertStrMatches, 'abcdef', {} ) assertBadFindArgNil( lu.assertStrMatches, 'abcdef', nil ) end function TestLuaUnitAssertions:test_assertItemsEquals() lu.assertItemsEquals(nil, nil) lu.assertItemsEquals({},{}) lu.assertItemsEquals({1,2,3}, {3,1,2}) lu.assertItemsEquals({nil},{nil}) lu.assertItemsEquals({one=1,two=2,three=3}, {two=2,one=1,three=3}) lu.assertItemsEquals({one=1,two=2,three=3}, {a=1,b=2,c=3}) lu.assertItemsEquals({1,2,three=3}, {3,1,two=2}) assertFailure(lu.assertItemsEquals, {1}, {}) assertFailure(lu.assertItemsEquals, nil, {1,2,3}) assertFailure(lu.assertItemsEquals, {1,2,3}, nil) assertFailure(lu.assertItemsEquals, {1,2,3,4}, {3,1,2}) assertFailure(lu.assertItemsEquals, {1,2,3}, {3,1,2,4}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3,four=4}, {a=1,b=2,c=3}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3}, {a=1,b=2,c=3,d=4}) assertFailure(lu.assertItemsEquals, {1,2,three=3}, {3,4,a=1,b=2}) assertFailure(lu.assertItemsEquals, {1,2,three=3,four=4}, {3,a=1,b=2}) lu.assertItemsEquals({one=1,two={1,2},three=3}, {one={1,2},two=1,three=3}) lu.assertItemsEquals({one=1, two={1,{3,2,one=1}}, three=3}, {two={1,{3,2,one=1}}, one=1, three=3}) -- itemsEquals is not recursive: assertFailure( lu.assertItemsEquals,{1,{2,1},3}, {3,1,{1,2}}) assertFailure( lu.assertItemsEquals,{one=1,two={1,2},three=3}, {one={2,1},two=1,three=3}) assertFailure( lu.assertItemsEquals,{one=1,two={1,{3,2,one=1}},three=3}, {two={{3,one=1,2},1},one=1,three=3}) assertFailure( lu.assertItemsEquals,{one=1,two={1,{3,2,one=1}},three=3}, {two={{3,2,one=1},1},one=1,three=3}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3}, {two=2,one=1,three=2}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3}, {two=2,one=1,four=4}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3}, {two=2,one=1,'three'}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3}, {two=2,one=1,nil}) assertFailure(lu.assertItemsEquals, {one=1,two=2,three=3}, {two=2,one=1}) end function TestLuaUnitAssertions:test_assertIsNumber() lu.assertIsNumber(1) lu.assertIsNumber(1.4) assertFailure(lu.assertIsNumber, "hi there!") assertFailure(lu.assertIsNumber, nil) assertFailure(lu.assertIsNumber, {}) assertFailure(lu.assertIsNumber, {1,2,3}) assertFailure(lu.assertIsNumber, {1}) assertFailure(lu.assertIsNumber, coroutine.create( function(v) local y=v+1 end ) ) assertFailure(lu.assertIsNumber, true) end function TestLuaUnitAssertions:test_assertIsString() assertFailure(lu.assertIsString, 1) assertFailure(lu.assertIsString, 1.4) lu.assertIsString("hi there!") assertFailure(lu.assertIsString, nil) assertFailure(lu.assertIsString, {}) assertFailure(lu.assertIsString, {1,2,3}) assertFailure(lu.assertIsString, {1}) assertFailure(lu.assertIsString, coroutine.create( function(v) local y=v+1 end ) ) assertFailure(lu.assertIsString, true) end function TestLuaUnitAssertions:test_assertIsTable() assertFailure(lu.assertIsTable, 1) assertFailure(lu.assertIsTable, 1.4) assertFailure(lu.assertIsTable, "hi there!") assertFailure(lu.assertIsTable, nil) lu.assertIsTable({}) lu.assertIsTable({1,2,3}) lu.assertIsTable({1}) assertFailure(lu.assertIsTable, true) assertFailure(lu.assertIsTable, coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertIsBoolean() assertFailure(lu.assertIsBoolean, 1) assertFailure(lu.assertIsBoolean, 1.4) assertFailure(lu.assertIsBoolean, "hi there!") assertFailure(lu.assertIsBoolean, nil) assertFailure(lu.assertIsBoolean, {}) assertFailure(lu.assertIsBoolean, {1,2,3}) assertFailure(lu.assertIsBoolean, {1}) assertFailure(lu.assertIsBoolean, coroutine.create( function(v) local y=v+1 end ) ) lu.assertIsBoolean(true) lu.assertIsBoolean(false) end function TestLuaUnitAssertions:test_assertIsNil() assertFailure(lu.assertIsNil, 1) assertFailure(lu.assertIsNil, 1.4) assertFailure(lu.assertIsNil, "hi there!") lu.assertIsNil(nil) assertFailure(lu.assertIsNil, {}) assertFailure(lu.assertIsNil, {1,2,3}) assertFailure(lu.assertIsNil, {1}) assertFailure(lu.assertIsNil, false) assertFailure(lu.assertIsNil, coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertIsFunction() local f = function() return true end assertFailure(lu.assertIsFunction, 1) assertFailure(lu.assertIsFunction, 1.4) assertFailure(lu.assertIsFunction, "hi there!") assertFailure(lu.assertIsFunction, nil) assertFailure(lu.assertIsFunction, {}) assertFailure(lu.assertIsFunction, {1,2,3}) assertFailure(lu.assertIsFunction, {1}) assertFailure(lu.assertIsFunction, false) assertFailure(lu.assertIsFunction, coroutine.create( function(v) local y=v+1 end ) ) lu.assertIsFunction(f) end function TestLuaUnitAssertions:test_assertIsThread() assertFailure(lu.assertIsThread, 1) assertFailure(lu.assertIsThread, 1.4) assertFailure(lu.assertIsThread, "hi there!") assertFailure(lu.assertIsThread, nil) assertFailure(lu.assertIsThread, {}) assertFailure(lu.assertIsThread, {1,2,3}) assertFailure(lu.assertIsThread, {1}) assertFailure(lu.assertIsThread, false) assertFailure(lu.assertIsThread, function(v) local y=v+1 end ) lu.assertIsThread(coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertIsUserdata() assertFailure(lu.assertIsUserdata, 1) assertFailure(lu.assertIsUserdata, 1.4) assertFailure(lu.assertIsUserdata, "hi there!") assertFailure(lu.assertIsUserdata, nil) assertFailure(lu.assertIsUserdata, {}) assertFailure(lu.assertIsUserdata, {1,2,3}) assertFailure(lu.assertIsUserdata, {1}) assertFailure(lu.assertIsUserdata, false) assertFailure(lu.assertIsUserdata, function(v) local y=v+1 end ) assertFailure(lu.assertIsUserdata, coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertNotIsNumber() assertFailure(lu.assertNotIsNumber, 1 ) assertFailure(lu.assertNotIsNumber, 1.4 ) lu.assertNotIsNumber( "hi there!") lu.assertNotIsNumber( nil) lu.assertNotIsNumber( {}) lu.assertNotIsNumber( {1,2,3}) lu.assertNotIsNumber( {1}) lu.assertNotIsNumber( coroutine.create( function(v) local y=v+1 end ) ) lu.assertNotIsNumber( true) end function TestLuaUnitAssertions:test_assertNotIsString() lu.assertNotIsString( 1) lu.assertNotIsString( 1.4) assertFailure( lu.assertNotIsString, "hi there!") lu.assertNotIsString( nil) lu.assertNotIsString( {}) lu.assertNotIsString( {1,2,3}) lu.assertNotIsString( {1}) lu.assertNotIsString( coroutine.create( function(v) local y=v+1 end ) ) lu.assertNotIsString( true) end function TestLuaUnitAssertions:test_assertNotIsTable() lu.assertNotIsTable( 1) lu.assertNotIsTable( 1.4) lu.assertNotIsTable( "hi there!") lu.assertNotIsTable( nil) assertFailure( lu.assertNotIsTable, {}) assertFailure( lu.assertNotIsTable, {1,2,3}) assertFailure( lu.assertNotIsTable, {1}) lu.assertNotIsTable( true) lu.assertNotIsTable( coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertNotIsBoolean() lu.assertNotIsBoolean( 1) lu.assertNotIsBoolean( 1.4) lu.assertNotIsBoolean( "hi there!") lu.assertNotIsBoolean( nil) lu.assertNotIsBoolean( {}) lu.assertNotIsBoolean( {1,2,3}) lu.assertNotIsBoolean( {1}) lu.assertNotIsBoolean( coroutine.create( function(v) local y=v+1 end ) ) assertFailure( lu.assertNotIsBoolean, true) assertFailure( lu.assertNotIsBoolean, false) end function TestLuaUnitAssertions:test_assertNotIsNil() lu.assertNotIsNil( 1) lu.assertNotIsNil( 1.4) lu.assertNotIsNil( "hi there!") assertFailure( lu.assertNotIsNil, nil) lu.assertNotIsNil( {}) lu.assertNotIsNil( {1,2,3}) lu.assertNotIsNil( {1}) lu.assertNotIsNil( false) lu.assertNotIsNil( coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertNotIsFunction() local f = function() return true end lu.assertNotIsFunction( 1) lu.assertNotIsFunction( 1.4) lu.assertNotIsFunction( "hi there!") lu.assertNotIsFunction( nil) lu.assertNotIsFunction( {}) lu.assertNotIsFunction( {1,2,3}) lu.assertNotIsFunction( {1}) lu.assertNotIsFunction( false) lu.assertNotIsFunction( coroutine.create( function(v) local y=v+1 end ) ) assertFailure( lu.assertNotIsFunction, f) end function TestLuaUnitAssertions:test_assertNotIsThread() lu.assertNotIsThread( 1) lu.assertNotIsThread( 1.4) lu.assertNotIsThread( "hi there!") lu.assertNotIsThread( nil) lu.assertNotIsThread( {}) lu.assertNotIsThread( {1,2,3}) lu.assertNotIsThread( {1}) lu.assertNotIsThread( false) lu.assertNotIsThread( function(v) local y=v+1 end ) assertFailure( lu.assertNotIsThread, coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertNotIsUserdata() lu.assertNotIsUserdata( 1) lu.assertNotIsUserdata( 1.4) lu.assertNotIsUserdata( "hi there!") lu.assertNotIsUserdata( nil) lu.assertNotIsUserdata( {}) lu.assertNotIsUserdata( {1,2,3}) lu.assertNotIsUserdata( {1}) lu.assertNotIsUserdata( false) lu.assertNotIsUserdata( function(v) local y=v+1 end ) lu.assertNotIsUserdata( coroutine.create( function(v) local y=v+1 end ) ) end function TestLuaUnitAssertions:test_assertIs() local f = function() return true end local g = function() return true end local t1= {} local t2={1,2} local t3={1,2} local t4= {a=1,{1,2},day="today"} local s1='toto' local s2='toto' local s3='to'..'to' lu.assertIs(1,1) lu.assertIs(f,f) lu.assertIs('toto', 'toto') lu.assertIs(s1, s2) lu.assertIs(s1, s3) lu.assertIs(t1,t1) lu.assertIs(t4,t4) assertFailure(lu.assertIs, 1, 2) assertFailure(lu.assertIs, 1.4, 1) assertFailure(lu.assertIs, "hi there!", "hola") assertFailure(lu.assertIs, nil, 1) assertFailure(lu.assertIs, {}, {}) assertFailure(lu.assertIs, {1,2,3}, f) assertFailure(lu.assertIs, f, g) assertFailure(lu.assertIs, t2,t3 ) end function TestLuaUnitAssertions:test_assertNotIs() local f = function() return true end local g = function() return true end local t1= {} local t2={1,2} local t3={1,2} local t4= {a=1,{1,2},day="today"} local s1='toto' local s2='toto' assertFailure( lu.assertNotIs, 1,1 ) assertFailure( lu.assertNotIs, f,f ) assertFailure( lu.assertNotIs, t1,t1 ) assertFailure( lu.assertNotIs, t4,t4) assertFailure( lu.assertNotIs, s1,s2 ) assertFailure( lu.assertNotIs, 'toto', 'toto' ) lu.assertNotIs(1, 2) lu.assertNotIs(1.4, 1) lu.assertNotIs("hi there!", "hola") lu.assertNotIs(nil, 1) lu.assertNotIs({}, {}) lu.assertNotIs({1,2,3}, f) lu.assertNotIs(f, g) lu.assertNotIs(t2,t3) end function TestLuaUnitAssertions:test_assertTableNum() lu.assertEquals( 3, 3 ) lu.assertNotEquals( 3, 4 ) lu.assertEquals( {3}, {3} ) lu.assertNotEquals( {3}, 3 ) lu.assertNotEquals( {3}, {4} ) lu.assertEquals( {x=1}, {x=1} ) lu.assertNotEquals( {x=1}, {x=2} ) lu.assertNotEquals( {x=1}, {y=1} ) end function TestLuaUnitAssertions:test_assertTableStr() lu.assertEquals( '3', '3' ) lu.assertNotEquals( '3', '4' ) lu.assertEquals( {'3'}, {'3'} ) lu.assertNotEquals( {'3'}, '3' ) lu.assertNotEquals( {'3'}, {'4'} ) lu.assertEquals( {x='1'}, {x='1'} ) lu.assertNotEquals( {x='1'}, {x='2'} ) lu.assertNotEquals( {x='1'}, {y='1'} ) end function TestLuaUnitAssertions:test_assertTableLev2() lu.assertEquals( {x={'a'}}, {x={'a'}} ) lu.assertNotEquals( {x={'a'}}, {x={'b'}} ) lu.assertNotEquals( {x={'a'}}, {z={'a'}} ) lu.assertEquals( {{x=1}}, {{x=1}} ) lu.assertNotEquals( {{x=1}}, {{y=1}} ) lu.assertEquals( {{x='a'}}, {{x='a'}} ) lu.assertNotEquals( {{x='a'}}, {{x='b'}} ) end function TestLuaUnitAssertions:test_assertTableList() lu.assertEquals( {3,4,5}, {3,4,5} ) lu.assertNotEquals( {3,4,5}, {3,4,6} ) lu.assertNotEquals( {3,4,5}, {3,5,4} ) lu.assertEquals( {3,4,x=5}, {3,4,x=5} ) lu.assertNotEquals( {3,4,x=5}, {3,4,x=6} ) lu.assertNotEquals( {3,4,x=5}, {3,x=4,5} ) lu.assertNotEquals( {3,4,5}, {2,3,4,5} ) lu.assertNotEquals( {3,4,5}, {3,2,4,5} ) lu.assertNotEquals( {3,4,5}, {3,4,5,6} ) end function TestLuaUnitAssertions:test_assertTableNil() lu.assertEquals( {3,4,5}, {3,4,5} ) lu.assertNotEquals( {3,4,5}, {nil,3,4,5} ) lu.assertNotEquals( {3,4,5}, {nil,4,5} ) lu.assertEquals( {3,4,5}, {3,4,5,nil} ) -- lua quirk lu.assertNotEquals( {3,4,5}, {3,4,nil} ) lu.assertNotEquals( {3,4,5}, {3,nil,5} ) lu.assertNotEquals( {3,4,5}, {3,4,nil,5} ) end function TestLuaUnitAssertions:test_assertTableNilFront() lu.assertEquals( {nil,4,5}, {nil,4,5} ) lu.assertNotEquals( {nil,4,5}, {nil,44,55} ) lu.assertEquals( {nil,'4','5'}, {nil,'4','5'} ) lu.assertNotEquals( {nil,'4','5'}, {nil,'44','55'} ) lu.assertEquals( {nil,{4,5}}, {nil,{4,5}} ) lu.assertNotEquals( {nil,{4,5}}, {nil,{44,55}} ) lu.assertNotEquals( {nil,{4}}, {nil,{44}} ) lu.assertEquals( {nil,{x=4,5}}, {nil,{x=4,5}} ) lu.assertEquals( {nil,{x=4,5}}, {nil,{5,x=4}} ) -- lua quirk lu.assertEquals( {nil,{x=4,y=5}}, {nil,{y=5,x=4}} ) -- lua quirk lu.assertNotEquals( {nil,{x=4,5}}, {nil,{y=4,5}} ) end function TestLuaUnitAssertions:test_assertTableAdditions() lu.assertEquals( {1,2,3}, {1,2,3} ) lu.assertNotEquals( {1,2,3}, {1,2,3,4} ) lu.assertNotEquals( {1,2,3,4}, {1,2,3} ) lu.assertEquals( {1,x=2,3}, {1,x=2,3} ) lu.assertNotEquals( {1,x=2,3}, {1,x=2,3,y=4} ) lu.assertNotEquals( {1,x=2,3,y=4}, {1,x=2,3} ) end local function assertFailureEquals(msg, ...) lu.assertErrorMsgEquals(lu.FAILURE_PREFIX .. msg, ...) end local function assertFailureMatches(msg, ...) lu.assertErrorMsgMatches(lu.FAILURE_PREFIX .. msg, ...) end local function assertFailureContains(msg, ...) lu.assertErrorMsgContains(lu.FAILURE_PREFIX .. msg, ...) end TestLuaUnitAssertionsError = {} function TestLuaUnitAssertionsError:setUp() self.f = function ( v ) local y = v + 1 end self.f_with_error = function (v) local y = v + 2 error('This is an error', 2) end end function TestLuaUnitAssertionsError:test_assertError() local x = 1 -- f_with_error generates an error local has_error = not pcall( self.f_with_error, x ) lu.assertEquals( has_error, true ) -- f does not generate an error has_error = not pcall( self.f, x ) lu.assertEquals( has_error, false ) -- lu.assertError is happy with f_with_error lu.assertError( self.f_with_error, x ) -- lu.assertError is unhappy with f assertFailureEquals( "Expected an error when calling function but no error generated", lu.assertError, self.f, x ) -- multiple arguments local function f_with_multi_arguments(a,b,c) if a == b and b == c then return end error("three arguments not equal") end lu.assertError( f_with_multi_arguments, 1, 1, 3 ) lu.assertError( f_with_multi_arguments, 1, 3, 1 ) lu.assertError( f_with_multi_arguments, 3, 1, 1 ) assertFailureEquals( "Expected an error when calling function but no error generated", lu.assertError, f_with_multi_arguments, 1, 1, 1 ) end function TestLuaUnitAssertionsError:test_assertErrorMsgContains() local x = 1 assertFailure( lu.assertErrorMsgContains, 'toto', self.f, x ) lu.assertErrorMsgContains( 'is an err', self.f_with_error, x ) lu.assertErrorMsgContains( 'This is an error', self.f_with_error, x ) assertFailure( lu.assertErrorMsgContains, ' This is an error', self.f_with_error, x ) assertFailure( lu.assertErrorMsgContains, 'This .. an error', self.f_with_error, x ) end function TestLuaUnitAssertionsError:test_assertErrorMsgEquals() local x = 1 assertFailure( lu.assertErrorMsgEquals, 'toto', self.f, x ) assertFailure( lu.assertErrorMsgEquals, 'is an err', self.f_with_error, x ) lu.assertErrorMsgEquals( 'This is an error', self.f_with_error, x ) assertFailure( lu.assertErrorMsgEquals, ' This is an error', self.f_with_error, x ) assertFailure( lu.assertErrorMsgEquals, 'This .. an error', self.f_with_error, x ) end function TestLuaUnitAssertionsError:test_assertErrorMsgMatches() local x = 1 assertFailure( lu.assertErrorMsgMatches, 'toto', self.f, x ) assertFailure( lu.assertErrorMsgMatches, 'is an err', self.f_with_error, x ) lu.assertErrorMsgMatches( 'This is an error', self.f_with_error, x ) lu.assertErrorMsgMatches( 'This is .. error', self.f_with_error, x ) assertFailure( lu.assertErrorMsgMatches, ' This is an error', self.f_with_error, x ) end ------------------------------------------------------------------ -- -- Failure message tests -- ------------------------------------------------------------------ TestLuaUnitErrorMsg = { __class__ = 'TestLuaUnitErrorMsg' } function TestLuaUnitErrorMsg:setUp() self.old_ORDER_ACTUAL_EXPECTED = lu.ORDER_ACTUAL_EXPECTED self.old_PRINT_TABLE_REF_IN_ERROR_MSG = lu.PRINT_TABLE_REF_IN_ERROR_MSG end function TestLuaUnitErrorMsg:tearDown() lu.ORDER_ACTUAL_EXPECTED = self.old_ORDER_ACTUAL_EXPECTED lu.PRINT_TABLE_REF_IN_ERROR_MSG = self.old_PRINT_TABLE_REF_IN_ERROR_MSG end function TestLuaUnitErrorMsg:test_assertEqualsMsg() assertFailureEquals( 'expected: 2, actual: 1', lu.assertEquals, 1, 2 ) assertFailureEquals( 'expected: "exp"\nactual: "act"', lu.assertEquals, 'act', 'exp' ) assertFailureEquals( 'expected: \n"exp\npxe"\nactual: \n"act\ntca"', lu.assertEquals, 'act\ntca', 'exp\npxe' ) assertFailureEquals( 'expected: true, actual: false', lu.assertEquals, false, true ) if _VERSION == 'Lua 5.3' then assertFailureEquals( 'expected: 1.2, actual: 1.0', lu.assertEquals, 1.0, 1.2) else assertFailureEquals( 'expected: 1.2, actual: 1', lu.assertEquals, 1.0, 1.2) end assertFailureMatches( 'expected: {1, 2, 3}\nactual: {3, 2, 1}', lu.assertEquals, {3,2,1}, {1,2,3} ) assertFailureMatches( 'expected: {one=1, two=2}\nactual: {3, 2, 1}', lu.assertEquals, {3,2,1}, {one=1,two=2} ) assertFailureEquals( 'expected: 2, actual: nil', lu.assertEquals, nil, 2 ) end function TestLuaUnitErrorMsg:test_assertEqualsOrderReversedMsg() lu.ORDER_ACTUAL_EXPECTED = false assertFailureEquals( 'expected: 1, actual: 2', lu.assertEquals, 1, 2 ) assertFailureEquals( 'expected: "act"\nactual: "exp"', lu.assertEquals, 'act', 'exp' ) end function TestLuaUnitErrorMsg:test_assertAlmostEqualsMsg() assertFailureEquals('Values are not almost equal\nExpected: 1 with margin of 0.1, received: 2', lu.assertAlmostEquals, 2, 1, 0.1 ) end function TestLuaUnitErrorMsg:test_assertAlmostEqualsOrderReversedMsg() lu.ORDER_ACTUAL_EXPECTED = false assertFailureEquals('Values are not almost equal\nExpected: 2 with margin of 0.1, received: 1', lu.assertAlmostEquals, 2, 1, 0.1 ) end function TestLuaUnitErrorMsg:test_assertNotAlmostEqualsMsg() assertFailureEquals('Values are almost equal\nExpected: 1 with a difference above margin of 0.2, received: 1.1', lu.assertNotAlmostEquals, 1.1, 1, 0.2 ) end function TestLuaUnitErrorMsg:test_assertNotAlmostEqualsMsg() lu.ORDER_ACTUAL_EXPECTED = false assertFailureEquals('Values are almost equal\nExpected: 1.1 with a difference above margin of 0.2, received: 1', lu.assertNotAlmostEquals, 1.1, 1, 0.2 ) end function TestLuaUnitErrorMsg:test_assertNotEqualsMsg() assertFailureEquals( 'Received the not expected value: 1', lu.assertNotEquals, 1, 1 ) assertFailureMatches( 'Received the not expected value: {1, 2}', lu.assertNotEquals, {1,2}, {1,2} ) assertFailureEquals( 'Received the not expected value: nil', lu.assertNotEquals, nil, nil ) end function TestLuaUnitErrorMsg:test_assertNotEqualsOrderReversedMsg() lu.ORDER_ACTUAL_EXPECTED = false assertFailureEquals( 'Received the not expected value: 1', lu.assertNotEquals, 1, 1 ) end function TestLuaUnitErrorMsg:test_assertTrueFalse() assertFailureEquals( 'expected: true, actual: false', lu.assertTrue, false ) assertFailureEquals( 'expected: true, actual: nil', lu.assertTrue, nil ) assertFailureEquals( 'expected: false, actual: true', lu.assertFalse, true ) assertFailureEquals( 'expected: false, actual: 0', lu.assertFalse, 0) assertFailureMatches( 'expected: false, actual: {}', lu.assertFalse, {}) assertFailureEquals( 'expected: false, actual: "abc"', lu.assertFalse, 'abc') assertFailureContains( 'expected: false, actual: function', lu.assertFalse, function () end ) end function TestLuaUnitErrorMsg:test_assertNil() assertFailureEquals( 'expected: nil, actual: false', lu.assertNil, false ) assertFailureEquals( 'expected non nil value, received nil', lu.assertNotNil, nil ) end function TestLuaUnitErrorMsg:test_assertStrContains() assertFailureEquals( 'Error, substring "xxx" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'xxx' ) assertFailureEquals( 'Error, substring "aBc" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'aBc' ) assertFailureEquals( 'Error, substring "xxx" was not found in string ""', lu.assertStrContains, '', 'xxx' ) assertFailureEquals( 'Error, substring "xxx" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'xxx', false ) assertFailureEquals( 'Error, substring "aBc" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'aBc', false ) assertFailureEquals( 'Error, substring "xxx" was not found in string ""', lu.assertStrContains, '', 'xxx', false ) assertFailureEquals( 'Error, regexp "xxx" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'xxx', true ) assertFailureEquals( 'Error, regexp "aBc" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'aBc', true ) assertFailureEquals( 'Error, regexp "xxx" was not found in string ""', lu.assertStrContains, '', 'xxx', true ) end function TestLuaUnitErrorMsg:test_assertStrIContains() assertFailureEquals( 'Error, substring "xxx" was not found in string "abcdef"', lu.assertStrContains, 'abcdef', 'xxx' ) assertFailureEquals( 'Error, substring "xxx" was not found in string ""', lu.assertStrContains, '', 'xxx' ) end function TestLuaUnitErrorMsg:test_assertNotStrContains() assertFailureEquals( 'Error, substring "abc" was found in string "abcdef"', lu.assertNotStrContains, 'abcdef', 'abc' ) assertFailureEquals( 'Error, substring "abc" was found in string "abcdef"', lu.assertNotStrContains, 'abcdef', 'abc', false ) assertFailureEquals( 'Error, regexp "..." was found in string "abcdef"', lu.assertNotStrContains, 'abcdef', '...', true) end function TestLuaUnitErrorMsg:test_assertNotStrIContains() assertFailureEquals( 'Error, substring "aBc" was found (case insensitively) in string "abcdef"', lu.assertNotStrIContains, 'abcdef', 'aBc' ) assertFailureEquals( 'Error, substring "abc" was found (case insensitively) in string "abcdef"', lu.assertNotStrIContains, 'abcdef', 'abc' ) end function TestLuaUnitErrorMsg:test_assertStrMatches() assertFailureEquals('Error, pattern "xxx" was not matched by string "abcdef"', lu.assertStrMatches, 'abcdef', 'xxx' ) end function TestLuaUnitErrorMsg:test_assertIsNumber() assertFailureEquals( 'Expected: a number value, actual: type string, value "abc"', lu.assertIsNumber, 'abc' ) assertFailureEquals( 'Expected: a number value, actual: type nil, value nil', lu.assertIsNumber, nil ) end function TestLuaUnitErrorMsg:test_assertIsString() assertFailureEquals( 'Expected: a string value, actual: type number, value 1.2', lu.assertIsString, 1.2 ) assertFailureEquals( 'Expected: a string value, actual: type nil, value nil', lu.assertIsString, nil ) end function TestLuaUnitErrorMsg:test_assertIsTable() assertFailureEquals( 'Expected: a table value, actual: type number, value 1.2', lu.assertIsTable, 1.2 ) assertFailureEquals( 'Expected: a table value, actual: type nil, value nil', lu.assertIsTable, nil ) end function TestLuaUnitErrorMsg:test_assertIsBoolean() assertFailureEquals( 'Expected: a boolean value, actual: type number, value 1.2', lu.assertIsBoolean, 1.2 ) assertFailureEquals( 'Expected: a boolean value, actual: type nil, value nil', lu.assertIsBoolean, nil ) end function TestLuaUnitErrorMsg:test_assertIsFunction() assertFailureEquals( 'Expected: a function value, actual: type number, value 1.2', lu.assertIsFunction, 1.2 ) assertFailureEquals( 'Expected: a function value, actual: type nil, value nil', lu.assertIsFunction, nil ) end function TestLuaUnitErrorMsg:test_assertIsThread() assertFailureEquals( 'Expected: a thread value, actual: type number, value 1.2', lu.assertIsThread, 1.2 ) assertFailureEquals( 'Expected: a thread value, actual: type nil, value nil', lu.assertIsThread, nil ) end function TestLuaUnitErrorMsg:test_assertIsUserdata() assertFailureEquals( 'Expected: a userdata value, actual: type number, value 1.2', lu.assertIsUserdata, 1.2 ) assertFailureEquals( 'Expected: a userdata value, actual: type nil, value nil', lu.assertIsUserdata, nil ) end function TestLuaUnitErrorMsg:test_assertNotIsNumber() assertFailureEquals( 'Not expected: a number type, actual: value 123', lu.assertNotIsNumber, 123 ) end function TestLuaUnitErrorMsg:test_assertNotIsString() assertFailureEquals( 'Not expected: a string type, actual: value "abc"', lu.assertNotIsString, "abc" ) end function TestLuaUnitErrorMsg:test_assertNotIsTable() assertFailureEquals( 'Not expected: a table type, actual: value {1, 2, 3}', lu.assertNotIsTable, {1,2,3} ) end function TestLuaUnitErrorMsg:test_assertNotIsBoolean() assertFailureEquals( 'Not expected: a boolean type, actual: value false', lu.assertNotIsBoolean, false ) end function TestLuaUnitErrorMsg:test_assertNotIsFunction() assertFailureContains( 'Not expected: a function type, actual: value function:', lu.assertNotIsFunction, function() return true end ) end function TestLuaUnitErrorMsg:test_assertNotIsThread() assertFailureContains( 'Not expected: a thread type, actual: value thread:', lu.assertNotIsThread, coroutine.create( function(v) local y=v+1 end ) ) end --[[ How do you create UserData ? function TestLuaUnitErrorMsg:test_assertIsNotUserdata() assertFailureEquals( 'Not expected: a userdata type, actual: value XXX ???', lu.assertIsNotUserdata, XXX ??? ) end ]] function TestLuaUnitErrorMsg:test_assertIs() assertFailureEquals( 'Expected object and actual object are not the same\nExpected: 1, actual: 2', lu.assertIs, 2, 1 ) lu.ORDER_ACTUAL_EXPECTED = false assertFailureEquals( 'Expected object and actual object are not the same\nExpected: 2, actual: 1', lu.assertIs, 2, 1 ) end function TestLuaUnitErrorMsg:test_assertNotIs() local v = {1,2} assertFailureMatches( 'Expected object and actual object are the same object: {1, 2}', lu.assertNotIs, v, v ) lu.ORDER_ACTUAL_EXPECTED = false -- order shouldn't matter here, but let's cover it assertFailureMatches( 'Expected object and actual object are the same object: {1, 2}', lu.assertNotIs, v, v ) end function TestLuaUnitErrorMsg:test_assertItemsEquals() assertFailureMatches('Contents of the tables are not identical:\nExpected: {one=2, two=3}\nActual: {1, 2}' , lu.assertItemsEquals, {1,2}, {one=2, two=3} ) assertFailureContains('Contents of the tables are not identical' , lu.assertItemsEquals, {}, {1} ) -- actual table empty, = doesn't contain expected value assertFailureContains('Contents of the tables are not identical' , lu.assertItemsEquals, nil, 'foobar' ) -- type mismatch assertFailureContains('Contents of the tables are not identical' , lu.assertItemsEquals, 'foo', 'bar' ) -- value mismatch end function TestLuaUnitErrorMsg:test_assertError() assertFailureEquals('Expected an error when calling function but no error generated' , lu.assertError, function( v ) local y = v+1 end, 3 ) end function TestLuaUnitErrorMsg:test_assertErrorMsg() assertFailureEquals('No error generated when calling function but expected error: "bla bla bla"' , lu.assertErrorMsgEquals, 'bla bla bla', function( v ) local y = v+1 end, 3 ) assertFailureEquals('No error generated when calling function but expected error containing: "bla bla bla"' , lu.assertErrorMsgContains, 'bla bla bla', function( v ) local y = v+1 end, 3 ) assertFailureEquals('No error generated when calling function but expected error matching: "bla bla bla"' , lu.assertErrorMsgMatches, 'bla bla bla', function( v ) local y = v+1 end, 3 ) assertFailureEquals('Exact error message expected: "bla bla bla"\nError message received: "toto xxx"\n' , lu.assertErrorMsgEquals, 'bla bla bla', function( v ) error('toto xxx',2) end, 3 ) assertFailureEquals('Error message does not contain: "bla bla bla"\nError message received: "toto xxx"\n' , lu.assertErrorMsgContains, 'bla bla bla', function( v ) error('toto xxx',2) end, 3 ) assertFailureEquals('Error message does not match: "bla bla bla"\nError message received: "toto xxx"\n' , lu.assertErrorMsgMatches, 'bla bla bla', function( v ) error('toto xxx',2) end, 3 ) end function TestLuaUnitErrorMsg:test_printTableWithRef() lu.PRINT_TABLE_REF_IN_ERROR_MSG = true assertFailureMatches( 'Received the not expected value: {1, 2}', lu.assertNotEquals, {1,2}, {1,2} ) -- trigger multiline prettystr assertFailureMatches( 'Received the not expected value: {1, 2, 3, 4}', lu.assertNotEquals, {1,2,3,4}, {1,2,3,4} ) assertFailureMatches( 'expected: false, actual: {}', lu.assertFalse, {}) local v = {1,2} assertFailureMatches( 'Expected object and actual object are the same object: {1, 2}', lu.assertNotIs, v, v ) assertFailureMatches('Contents of the tables are not identical:\nExpected: {one=2, two=3}\nActual: {1, 2}' , lu.assertItemsEquals, {1,2}, {one=2, two=3} ) assertFailureMatches( 'expected: {1, 2, 3}\nactual: {3, 2, 1}', lu.assertEquals, {3,2,1}, {1,2,3} ) -- trigger multiline prettystr assertFailureMatches( 'expected: {1, 2, 3, 4}\nactual: {3, 2, 1, 4}', lu.assertEquals, {3,2,1,4}, {1,2,3,4} ) assertFailureMatches( 'expected: {one=1, two=2}\nactual: {3, 2, 1}', lu.assertEquals, {3,2,1}, {one=1,two=2} ) end ------------------------------------------------------------------ -- -- Execution Tests -- ------------------------------------------------------------------ local executedTests MyTestToto1 = {} --class function MyTestToto1:test1() table.insert( executedTests, "MyTestToto1:test1" ) end function MyTestToto1:testb() table.insert( executedTests, "MyTestToto1:testb" ) end function MyTestToto1:test3() table.insert( executedTests, "MyTestToto1:test3" ) end function MyTestToto1:testa() table.insert( executedTests, "MyTestToto1:testa" ) end function MyTestToto1:test2() table.insert( executedTests, "MyTestToto1:test2" ) end MyTestToto2 = {} --class function MyTestToto2:test1() table.insert( executedTests, "MyTestToto2:test1" ) end MyTestWithErrorsAndFailures = {} --class function MyTestWithErrorsAndFailures:testWithFailure1() lu.assertEquals(1, 2) end function MyTestWithErrorsAndFailures:testWithFailure2() lu.assertError( function() end ) end function MyTestWithErrorsAndFailures:testWithError1() error('some error') end function MyTestWithErrorsAndFailures:testOk() end MyTestOk = {} --class function MyTestOk:testOk1() end function MyTestOk:testOk2() end function MyTestFunction() table.insert( executedTests, "MyTestFunction" ) end TestLuaUnitExecution = { __class__ = 'TestLuaUnitExecution' } function TestLuaUnitExecution:tearDown() executedTests = {} lu.LuaUnit.isTestName = lu.LuaUnit.isTestNameOld end function TestLuaUnitExecution:setUp() executedTests = {} lu.LuaUnit.isTestNameOld = lu.LuaUnit.isTestName lu.LuaUnit.isTestName = function( s ) return (string.sub(s,1,6) == 'MyTest') end end function TestLuaUnitExecution:test_collectTests() local allTests = lu.LuaUnit.collectTests() lu.assertEquals( allTests, {"MyTestFunction", "MyTestOk", "MyTestToto1", "MyTestToto2","MyTestWithErrorsAndFailures"}) end function TestLuaUnitExecution:test_MethodsAreExecutedInRightOrder() local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuite( 'MyTestToto1' ) lu.assertEquals( #executedTests, 5 ) lu.assertEquals( executedTests[1], "MyTestToto1:test1" ) lu.assertEquals( executedTests[2], "MyTestToto1:test2" ) lu.assertEquals( executedTests[3], "MyTestToto1:test3" ) lu.assertEquals( executedTests[4], "MyTestToto1:testa" ) lu.assertEquals( executedTests[5], "MyTestToto1:testb" ) end function TestLuaUnitExecution:test_runSuiteByNames() -- note: this also test that names are executed in explicit order local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByNames( { 'MyTestToto2', 'MyTestToto1', 'MyTestFunction' } ) lu.assertEquals( #executedTests, 7 ) lu.assertEquals( executedTests[1], "MyTestToto2:test1" ) lu.assertEquals( executedTests[2], "MyTestToto1:test1" ) lu.assertEquals( executedTests[7], "MyTestFunction" ) end function TestLuaUnitExecution:testRunSomeTestByGlobalInstance( ) lu.assertEquals( #executedTests, 0 ) local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'Toto', MyTestToto1 } } ) lu.assertEquals( #executedTests, 5 ) lu.assertEquals( #runner.result.tests, 5 ) lu.assertEquals( runner.result.tests[1].testName, "Toto.test1" ) lu.assertEquals( runner.result.tests[5].testName, "Toto.testb" ) end function TestLuaUnitExecution:testRunSomeTestByLocalInstance( ) local MyLocalTestToto1 = {} --class function MyLocalTestToto1:test1() table.insert( executedTests, "MyLocalTestToto1:test1" ) end local MyLocalTestToto2 = {} --class function MyLocalTestToto2:test1() table.insert( executedTests, "MyLocalTestToto2:test1" ) end function MyLocalTestToto2:test2() table.insert( executedTests, "MyLocalTestToto2:test2" ) end local function MyLocalTestFunction() table.insert( executedTests, "MyLocalTestFunction" ) end lu.assertEquals( #executedTests, 0 ) local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyLocalTestToto1', MyLocalTestToto1 }, { 'MyLocalTestToto2.test2', MyLocalTestToto2 }, { 'MyLocalTestFunction', MyLocalTestFunction }, } ) lu.assertEquals( #executedTests, 3 ) lu.assertEquals( executedTests[1], 'MyLocalTestToto1:test1') lu.assertEquals( executedTests[2], 'MyLocalTestToto2:test2') lu.assertEquals( executedTests[3], 'MyLocalTestFunction') end function TestLuaUnitExecution:testRunReturnsNumberOfFailures() local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) local ret = runner:runSuite( 'MyTestWithErrorsAndFailures' ) lu.assertEquals(ret, 3) ret = runner:runSuite( 'MyTestToto1' ) lu.assertEquals(ret, 0) end function TestLuaUnitExecution:testTestCountAndFailCount() local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuite( 'MyTestWithErrorsAndFailures' ) lu.assertEquals( runner.result.testCount, 4) lu.assertEquals( runner.result.notPassedCount, 3) lu.assertEquals( runner.result.failureCount, 2) lu.assertEquals( runner.result.errorCount, 1) runner:runSuite( 'MyTestToto1' ) lu.assertEquals( runner.result.testCount, 5) lu.assertEquals( runner.result.notPassedCount, 0) lu.assertEquals( runner.result.failureCount, 0) lu.assertEquals( runner.result.errorCount, 0) end function TestLuaUnitExecution:testRunSetupAndTeardown() local myExecutedTests = {} local MyTestWithSetupTeardown = {} function MyTestWithSetupTeardown:setUp() table.insert( myExecutedTests, '1setUp' ) end function MyTestWithSetupTeardown:test1() table.insert( myExecutedTests, '1test1' ) end function MyTestWithSetupTeardown:test2() table.insert( myExecutedTests, '1test2' ) end function MyTestWithSetupTeardown:tearDown() table.insert( myExecutedTests, '1tearDown' ) end local MyTestWithSetupTeardown2 = {} function MyTestWithSetupTeardown2:setUp() table.insert( myExecutedTests, '2setUp' ) end function MyTestWithSetupTeardown2:test1() table.insert( myExecutedTests, '2test1' ) end function MyTestWithSetupTeardown2:tearDown() table.insert( myExecutedTests, '2tearDown' ) end local MyTestWithSetupTeardown3 = {} function MyTestWithSetupTeardown3:Setup() table.insert( myExecutedTests, '3Setup' ) end function MyTestWithSetupTeardown3:test1() table.insert( myExecutedTests, '3test1' ) end function MyTestWithSetupTeardown3:Teardown() table.insert( myExecutedTests, '3Teardown' ) end local MyTestWithSetupTeardown4 = {} function MyTestWithSetupTeardown4:setup() table.insert( myExecutedTests, '4setup' ) end function MyTestWithSetupTeardown4:test1() table.insert( myExecutedTests, '4test1' ) end function MyTestWithSetupTeardown4:teardown() table.insert( myExecutedTests, '4teardown' ) end local MyTestWithSetupTeardown5 = {} function MyTestWithSetupTeardown5:SetUp() table.insert( myExecutedTests, '5SetUp' ) end function MyTestWithSetupTeardown5:test1() table.insert( myExecutedTests, '5test1' ) end function MyTestWithSetupTeardown5:TearDown() table.insert( myExecutedTests, '5TearDown' ) end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupTeardown.test1', MyTestWithSetupTeardown } } ) lu.assertEquals( runner.result.notPassedCount, 0 ) lu.assertEquals( myExecutedTests[1], '1setUp' ) lu.assertEquals( myExecutedTests[2], '1test1') lu.assertEquals( myExecutedTests[3], '1tearDown') lu.assertEquals( #myExecutedTests, 3) myExecutedTests = {} runner:runSuiteByInstances( { { 'MyTestWithSetupTeardown', MyTestWithSetupTeardown }, { 'MyTestWithSetupTeardown2', MyTestWithSetupTeardown2 }, { 'MyTestWithSetupTeardown3', MyTestWithSetupTeardown3 }, { 'MyTestWithSetupTeardown4', MyTestWithSetupTeardown4 }, { 'MyTestWithSetupTeardown5', MyTestWithSetupTeardown5 } } ) lu.assertEquals( runner.result.notPassedCount, 0 ) lu.assertEquals( myExecutedTests[1], '1setUp' ) lu.assertEquals( myExecutedTests[2], '1test1') lu.assertEquals( myExecutedTests[3], '1tearDown') lu.assertEquals( myExecutedTests[4], '1setUp' ) lu.assertEquals( myExecutedTests[5], '1test2') lu.assertEquals( myExecutedTests[6], '1tearDown') lu.assertEquals( myExecutedTests[7], '2setUp' ) lu.assertEquals( myExecutedTests[8], '2test1') lu.assertEquals( myExecutedTests[9], '2tearDown') lu.assertEquals( myExecutedTests[10], '3Setup') lu.assertEquals( myExecutedTests[11], '3test1') lu.assertEquals( myExecutedTests[12], '3Teardown') lu.assertEquals( myExecutedTests[13], '4setup') lu.assertEquals( myExecutedTests[14], '4test1') lu.assertEquals( myExecutedTests[15], '4teardown') lu.assertEquals( myExecutedTests[16], '5SetUp') lu.assertEquals( myExecutedTests[17], '5test1') lu.assertEquals( myExecutedTests[18], '5TearDown') lu.assertEquals( #myExecutedTests, 18) end function TestLuaUnitExecution:testWithSetupTeardownFailure1() local myExecutedTests = {} local MyTestWithSetupFailure = {} function MyTestWithSetupFailure:setUp() table.insert( myExecutedTests, 'setUp' ) lu.assertEquals( 'b', 'c') end function MyTestWithSetupFailure:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupFailure:tearDown() table.insert( myExecutedTests, 'tearDown' ) end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupFailure', MyTestWithSetupFailure } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testWithSetupTeardownFailure2() local myExecutedTests = {} local MyTestWithSetupFailure = {} function MyTestWithSetupFailure:setUp() table.insert( myExecutedTests, 'setUp' ) end function MyTestWithSetupFailure:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupFailure:tearDown() table.insert( myExecutedTests, 'tearDown' ) lu.assertEquals( 'b', 'c') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupFailure', MyTestWithSetupFailure } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'test1' ) lu.assertEquals( myExecutedTests[3], 'tearDown') lu.assertEquals( #myExecutedTests, 3) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testWithSetupTeardownFailure3() local myExecutedTests = {} local MyTestWithSetupFailure = {} function MyTestWithSetupFailure:setUp() table.insert( myExecutedTests, 'setUp' ) lu.assertEquals( 'b', 'c') end function MyTestWithSetupFailure:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupFailure:tearDown() table.insert( myExecutedTests, 'tearDown' ) lu.assertEquals( 'b', 'c') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupFailure', MyTestWithSetupFailure } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report two failures for this lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testWithSetupTeardownFailure4() local myExecutedTests = {} local MyTestWithSetupFailure = {} function MyTestWithSetupFailure:setUp() table.insert( myExecutedTests, 'setUp' ) lu.assertEquals( 'b', 'c') end function MyTestWithSetupFailure:test1() table.insert( myExecutedTests, 'test1' ) lu.assertEquals( 'b', 'c') end function MyTestWithSetupFailure:tearDown() table.insert( myExecutedTests, 'tearDown' ) lu.assertEquals( 'b', 'c') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupFailure', MyTestWithSetupFailure } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report two failures for this lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testWithSetupTeardownFailure5() local myExecutedTests = {} local MyTestWithSetupFailure = {} function MyTestWithSetupFailure:setUp() table.insert( myExecutedTests, 'setUp' ) end function MyTestWithSetupFailure:test1() table.insert( myExecutedTests, 'test1' ) lu.assertEquals( 'b', 'c') end function MyTestWithSetupFailure:tearDown() table.insert( myExecutedTests, 'tearDown' ) lu.assertEquals( 'b', 'c') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupFailure', MyTestWithSetupFailure } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report two failures for this lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'test1' ) lu.assertEquals( myExecutedTests[3], 'tearDown') lu.assertEquals( #myExecutedTests, 3) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testWithSetupTeardownErrors1() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) error('setup error') end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrors2() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) error('teardown error') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'test1' ) lu.assertEquals( myExecutedTests[3], 'tearDown') lu.assertEquals( #myExecutedTests, 3) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrors3() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) error('setup error') end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) error('teardown error') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report two errors for this lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrors4() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) error('setup error') end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) error('test error') end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) error('teardown error') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report two errors for this lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrors5() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) error('test error') end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) error('teardown error') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report two errors for this lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'test1' ) lu.assertEquals( myExecutedTests[3], 'tearDown') lu.assertEquals( #myExecutedTests, 3) lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrorsAndFailures1() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) lu.assertEquals( 'a', 'b') end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) error('teardown error') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report failure + error for this lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) -- The first error/failure set the whole test status lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testWithSetupTeardownErrorsAndFailures2() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) error('setup error') end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) lu.assertEquals( 'a', 'b') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report failure + error for this lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'tearDown') lu.assertEquals( #myExecutedTests, 2) -- The first error/failure set the whole test status lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrorsAndFailures3() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) error('test error') end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) lu.assertEquals( 'a', 'b') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report failure + error for this lu.assertEquals( runner.result.failureCount, 0 ) lu.assertEquals( runner.result.errorCount, 1 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'test1' ) lu.assertEquals( myExecutedTests[3], 'tearDown') lu.assertEquals( #myExecutedTests, 3) -- The first error/failure set the whole test status lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.ERROR ) end function TestLuaUnitExecution:testWithSetupTeardownErrorsAndFailures4() local myExecutedTests = {} local MyTestWithSetupError = {} function MyTestWithSetupError:setUp() table.insert( myExecutedTests, 'setUp' ) end function MyTestWithSetupError:test1() table.insert( myExecutedTests, 'test1' ) lu.assertEquals( 'a', 'b') end function MyTestWithSetupError:tearDown() table.insert( myExecutedTests, 'tearDown' ) error('teardown error') end local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuiteByInstances( { { 'MyTestWithSetupError', MyTestWithSetupError } } ) lu.assertEquals( runner.result.notPassedCount, 1 ) -- Note: in the future, we may want to report failure + error for this lu.assertEquals( runner.result.failureCount, 1 ) lu.assertEquals( runner.result.errorCount, 0 ) lu.assertEquals( runner.result.testCount, 1 ) lu.assertEquals( myExecutedTests[1], 'setUp' ) lu.assertEquals( myExecutedTests[2], 'test1' ) lu.assertEquals( myExecutedTests[3], 'tearDown') lu.assertEquals( #myExecutedTests, 3) -- The first error/failure set the whole test status lu.assertEquals( runner.result.notPassed[1].status, lu.NodeStatus.FAIL ) end function TestLuaUnitExecution:testOutputInterface() local runner = lu.LuaUnit.new() runner.outputType = Mock runner:runSuite( 'MyTestWithErrorsAndFailures', 'MyTestOk' ) local m = runner.output lu.assertEquals( m.calls[1][1], 'startSuite' ) lu.assertEquals(#m.calls[1], 2 ) lu.assertEquals( m.calls[2][1], 'startClass' ) lu.assertEquals( m.calls[2][3], 'MyTestWithErrorsAndFailures' ) lu.assertEquals(#m.calls[2], 3 ) lu.assertEquals( m.calls[3][1], 'startTest' ) lu.assertEquals( m.calls[3][3], 'MyTestWithErrorsAndFailures.testOk' ) lu.assertEquals(#m.calls[3], 3 ) lu.assertEquals( m.calls[4][1], 'endTest' ) lu.assertEquals(#m.calls[4], 3 ) lu.assertIsTable( m.calls[4][3] ) lu.assertEquals( m.calls[4][3].status, lu.NodeStatus.PASS ) lu.assertEquals( m.calls[5][1], 'startTest' ) lu.assertEquals( m.calls[5][3], 'MyTestWithErrorsAndFailures.testWithError1' ) lu.assertEquals(#m.calls[5], 3 ) lu.assertEquals( m.calls[6][1], 'addStatus' ) lu.assertEquals(#m.calls[6], 3 ) lu.assertEquals( m.calls[7][1], 'endTest' ) lu.assertEquals(#m.calls[7], 3 ) lu.assertIsTable( m.calls[7][3] ) lu.assertEquals( m.calls[7][3].status, lu.NodeStatus.ERROR ) lu.assertEquals( m.calls[8][1], 'startTest' ) lu.assertEquals( m.calls[8][3], 'MyTestWithErrorsAndFailures.testWithFailure1' ) lu.assertEquals(#m.calls[8], 3 ) lu.assertEquals( m.calls[9][1], 'addStatus' ) lu.assertEquals(#m.calls[9], 3 ) lu.assertEquals( m.calls[10][1], 'endTest' ) lu.assertEquals(#m.calls[10], 3 ) lu.assertIsTable( m.calls[10][3] ) lu.assertEquals( m.calls[10][3].status, lu.NodeStatus.FAIL ) lu.assertEquals( m.calls[11][1], 'startTest' ) lu.assertEquals( m.calls[11][3], 'MyTestWithErrorsAndFailures.testWithFailure2' ) lu.assertEquals(#m.calls[11], 3 ) lu.assertEquals( m.calls[12][1], 'addStatus' ) lu.assertEquals(#m.calls[12], 3 ) lu.assertEquals( m.calls[13][1], 'endTest' ) lu.assertEquals(#m.calls[13], 3 ) lu.assertIsTable(m.calls[13][3] ) lu.assertEquals( m.calls[13][3].status, lu.NodeStatus.FAIL ) lu.assertEquals( m.calls[14][1], 'endClass' ) lu.assertEquals(#m.calls[14], 2 ) lu.assertEquals( m.calls[15][1], 'startClass' ) lu.assertEquals( m.calls[15][3], 'MyTestOk' ) lu.assertEquals(#m.calls[15], 3 ) lu.assertEquals( m.calls[16][1], 'startTest' ) lu.assertEquals( m.calls[16][3], 'MyTestOk.testOk1' ) lu.assertEquals(#m.calls[16], 3 ) lu.assertEquals( m.calls[17][1], 'endTest' ) lu.assertEquals(#m.calls[17], 3 ) lu.assertIsTable( m.calls[17][3] ) lu.assertEquals( m.calls[17][3].status, lu.NodeStatus.PASS ) lu.assertEquals( m.calls[18][1], 'startTest' ) lu.assertEquals( m.calls[18][3], 'MyTestOk.testOk2' ) lu.assertEquals(#m.calls[18], 3 ) lu.assertEquals( m.calls[19][1], 'endTest' ) lu.assertEquals(#m.calls[19], 3 ) lu.assertIsTable( m.calls[19][3] ) lu.assertEquals( m.calls[19][3].status, lu.NodeStatus.PASS ) lu.assertEquals( m.calls[20][1], 'endClass' ) lu.assertEquals(#m.calls[20], 2 ) lu.assertEquals( m.calls[21][1], 'endSuite' ) lu.assertEquals(#m.calls[21], 2 ) lu.assertEquals( m.calls[22], nil ) end function TestLuaUnitExecution:testInvocation() local runner = lu.LuaUnit.new() -- test alternative "object" syntax for run(), passing self runner:run('--output', 'nil', 'MyTestOk') -- select class instance by name runner.run('--output', 'nil', 'MyTestOk.testOk2') -- check error handling lu.assertErrorMsgContains('No such name in global space', runner.runSuite, runner, 'foobar') lu.assertErrorMsgContains('Name must match a function or a table', runner.runSuite, runner, '_VERSION') lu.assertErrorMsgContains('No such name in global space', runner.runSuite, runner, 'foo.bar') lu.assertErrorMsgContains('must be a function, not', runner.runSuite, runner, '_G._VERSION') lu.assertErrorMsgContains('Could not find method in class', runner.runSuite, runner, 'MyTestOk.foobar') lu.assertErrorMsgContains('Instance must be a table or a function', runner.expandClasses, {{'foobar', 'INVALID'}}) lu.assertErrorMsgContains('Could not find method in class', runner.expandClasses, {{'MyTestOk.foobar', {}}}) end function TestLuaUnitExecution:test_filterWithPattern() local runner = lu.LuaUnit.new() runner:setOutputType( "NIL" ) runner:runSuite('-p', 'Function', '-p', 'Toto.' ) lu.assertEquals( executedTests[1], "MyTestFunction" ) lu.assertEquals( executedTests[2], "MyTestToto1:test1" ) lu.assertEquals( executedTests[3], "MyTestToto1:test2" ) lu.assertEquals( executedTests[4], "MyTestToto1:test3" ) lu.assertEquals( executedTests[5], "MyTestToto1:testa" ) lu.assertEquals( executedTests[6], "MyTestToto1:testb" ) lu.assertEquals( executedTests[7], "MyTestToto2:test1" ) lu.assertEquals( #executedTests, 7) end ------------------------------------------------------------------ -- -- Results Tests -- ------------------------------------------------------------------ TestLuaUnitResults = { __class__ = 'TestLuaUnitResults' } function TestLuaUnitResults:tearDown() executedTests = {} lu.LuaUnit.isTestName = lu.LuaUnit.isTestNameOld end function TestLuaUnitResults:setUp() executedTests = {} lu.LuaUnit.isTestNameOld = lu.LuaUnit.isTestName lu.LuaUnit.isTestName = function( s ) return (string.sub(s,1,6) == 'MyTest') end end function TestLuaUnitResults:test_statusLine() -- full success local r = {runCount=5, duration=0.17, passedCount=5, notPassedCount=0, failureCount=0, errorCount=0, nonSelectedCount=0} lu.assertEquals( lu.LuaUnit.statusLine(r), 'Ran 5 tests in 0.170 seconds, 5 successes, 0 failures') -- 1 failure, nothing more displayed r = {runCount=5, duration=0.17, passedCount=4, notPassedCount=1, failureCount=1, errorCount=0, nonSelectedCount=0} lu.assertEquals( lu.LuaUnit.statusLine(r), 'Ran 5 tests in 0.170 seconds, 4 successes, 1 failure') -- 1 error, no failure displayed r = {runCount=5, duration=0.17, passedCount=4, notPassedCount=1, failureCount=0, errorCount=1, nonSelectedCount=0} lu.assertEquals( lu.LuaUnit.statusLine(r), 'Ran 5 tests in 0.170 seconds, 4 successes, 1 error') -- 1 error, 1 failure r = {runCount=5, duration=0.17, passedCount=3, notPassedCount=2, failureCount=1, errorCount=1, nonSelectedCount=0} lu.assertEquals( lu.LuaUnit.statusLine(r), 'Ran 5 tests in 0.170 seconds, 3 successes, 1 failure, 1 error') -- 1 error, 1 failure, 1 non selected r = {runCount=5, duration=0.17, passedCount=3, notPassedCount=2, failureCount=1, errorCount=1, nonSelectedCount=1} lu.assertEquals( lu.LuaUnit.statusLine(r), 'Ran 5 tests in 0.170 seconds, 3 successes, 1 failure, 1 error, 1 non-selected') -- full success, 1 non selected r = {runCount=5, duration=0.17, passedCount=5, notPassedCount=0, failureCount=0, errorCount=0, nonSelectedCount=1} lu.assertEquals( lu.LuaUnit.statusLine(r), 'Ran 5 tests in 0.170 seconds, 5 successes, 0 failures, 1 non-selected') end function TestLuaUnitResults:test_nodeStatus() local es = lu.NodeStatus.new() lu.assertEquals( es.status, lu.NodeStatus.PASS ) lu.assertTrue( es:isPassed() ) lu.assertNil( es.msg ) lu.assertNil( es.stackTrace ) lu.assertStrContains( es:statusXML(), " tmpscZSVg/test/errFailPassTextStopOnError-2.txt0000644000175000017500000000151712777131567021150 0ustar vsevavseva..FFE ERROR during LuaUnit test execution: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value Failed tests: ------------- 1) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 2) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 3) TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value stack traceback: [C]: in function 'xpcall' Ran 5 tests in 0.000 seconds, 2 successes, 2 failures, 1 error, 9 non-selected LuaUnit ABORTED (as requested by --error or --failure option) tmpscZSVg/test/errFailPassXmlVerbose-success.txt0000644000175000017500000000072012777131575021436 0ustar vsevavseva# XML output to test/ref/errFailPassXmlVerbose-success.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: testFuncSuccess1 # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/errFailPassXmlQuiet.xml0000644000175000017500000001022612777131575017435 0ustar vsevavseva tmpscZSVg/test/testWithXmlDefault.xml0000644000175000017500000000260212777131571017325 0ustar vsevavseva tmpscZSVg/test/errFailPassTextQuiet-success.txt0000644000175000017500000000012312777131574021300 0ustar vsevavseva..... Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/errFailPassTapQuiet-failures.txt0000644000175000017500000000104212777131570021237 0ustar vsevavseva1..10 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test3_Fail1 not ok 4 TestAnotherThing.test3_Fail2 # Starting class: TestSomething ok 5 TestSomething.test1_Success1 ok 6 TestSomething.test1_Success2 not ok 7 TestSomething.test2_Fail1 not ok 8 TestSomething.test2_Fail2 not ok 9 testFuncFail1 ok 10 testFuncSuccess1 # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassTapVerbose-success.txt0000644000175000017500000000056212777131570021421 0ustar vsevavseva1..5 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 # Starting class: TestSomething ok 3 TestSomething.test1_Success1 ok 4 TestSomething.test1_Success2 ok 5 testFuncSuccess1 # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/errFailPassTapVerbose-failures.txt0000644000175000017500000000255612777131570021570 0ustar vsevavseva1..10 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' not ok 4 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' # Starting class: TestSomething ok 5 TestSomething.test1_Success1 ok 6 TestSomething.test1_Success2 not ok 7 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' not ok 8 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' not ok 9 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' ok 10 testFuncSuccess1 # Ran 10 tests in 0.000 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassXmlDefault.xml0000644000175000017500000001022612777131574017731 0ustar vsevavseva tmpscZSVg/test/errFailPassXmlQuiet-failures.txt0000644000175000017500000000201512777131575021261 0ustar vsevavseva# XML output to test/ref/errFailPassXmlQuiet-failures.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 10 tests in 0.002 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassTapQuiet-success.txt0000644000175000017500000000056212777131570021103 0ustar vsevavseva1..5 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 # Starting class: TestSomething ok 3 TestSomething.test1_Success1 ok 4 TestSomething.test1_Success2 ok 5 testFuncSuccess1 # Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/testWithXmlVerbose.xml0000644000175000017500000000260212777131574017351 0ustar vsevavseva tmpscZSVg/test/errFailPassXmlVerbose-failures.xml0000644000175000017500000000523212777131575021564 0ustar vsevavseva tmpscZSVg/test/errFailPassTextDefault-failures.txt0000644000175000017500000000203412777131574021742 0ustar vsevavseva..FF..FFF. Failed tests: ------------- 1) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 2) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 3) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 4) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 5) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassTapDefault.txt0000644000175000017500000000271412777131570017733 0ustar vsevavseva1..15 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value not ok 4 TestAnotherThing.test2_Err2 test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value not ok 5 TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 not ok 6 TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 not ok 10 TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 not ok 11 TestSomething.test3_Err1 test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value not ok 12 TestSomething.test3_Err2 test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value not ok 13 testFuncErr1 test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value not ok 14 testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 ok 15 testFuncSuccess1 # Ran 15 tests in 0.003 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/legacyExample.txt0000644000175000017500000000550112777131567016331 0ustar vsevavsevaTestTiti:setUp some stuff test 1 TestTiti:tearDown FTestTiti:setUp some stuff test 2 TestTiti:tearDown FTestTiti:setUp some stuff test 3 TestTiti:tearDown .some stuff test 1 Fsome stuff test 2 Fsome stuff test 3 .some stuff test 4 Fsome stuff test 5 Fsome stuff test 6 FFEEEE. Failed tests: ------------- 1) TestTiti.test1_withFailure test/legacy_example_with_luaunit.lua:99: expected: 2, actual: 1 stack traceback: test/legacy_example_with_luaunit.lua:99: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure test/legacy_example_with_luaunit.lua:108: expected: "bof" actual: "hop" stack traceback: test/legacy_example_with_luaunit.lua:108: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure test/legacy_example_with_luaunit.lua:19: expected: 2, actual: 1 stack traceback: test/legacy_example_with_luaunit.lua:19: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure test/legacy_example_with_luaunit.lua:28: expected: "bof" actual: "hop" stack traceback: test/legacy_example_with_luaunit.lua:28: in function 'TestToto.test2_withFailure' 5) TestToto.test4 test/legacy_example_with_luaunit.lua:41: Received the not expected value: 1 stack traceback: test/legacy_example_with_luaunit.lua:41: in function 'TestToto.test4' 6) TestToto.test5 test/legacy_example_with_luaunit.lua:47: expected: false, actual: 1 stack traceback: test/legacy_example_with_luaunit.lua:47: in function 'TestToto.test5' 7) TestToto.test6 test/legacy_example_with_luaunit.lua:52: expected: true, actual: false stack traceback: test/legacy_example_with_luaunit.lua:52: in function 'TestToto.test6' 8) TestToto.test7 test/legacy_example_with_luaunit.lua:58: expected: {1, 2, three=3} actual: {1, 2} stack traceback: test/legacy_example_with_luaunit.lua:58: in function 'TestToto.test7' 9) TestToto.test8a test/legacy_example_with_luaunit.lua:76: Bouhouhoum error! stack traceback: test/legacy_example_with_luaunit.lua:76: in function 'funcWithError' test/legacy_example_with_luaunit.lua:63: in function 'TestToto.test8a' 10) TestToto.test8b test/legacy_example_with_luaunit.lua:76: Bouhouhoum error! stack traceback: test/legacy_example_with_luaunit.lua:76: in function 'funcWithError' test/legacy_example_with_luaunit.lua:72: in function 'funcWithFuncWithError' test/legacy_example_with_luaunit.lua:68: in function 'TestToto.test8b' 11) test1_withFailure test/legacy_example_with_luaunit.lua:124: assertion failed! stack traceback: test/legacy_example_with_luaunit.lua:124: in function 'test1_withFailure' 12) test2_withFailure test/legacy_example_with_luaunit.lua:130: assertion failed! stack traceback: test/legacy_example_with_luaunit.lua:130: in function 'test2_withFailure' Ran 15 tests in 0.001 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/errFailPassXmlVerbose.xml0000644000175000017500000001022612777131575017753 0ustar vsevavseva tmpscZSVg/test/errFailPassXmlDefault-failures.xml0000644000175000017500000000523212777131575021543 0ustar vsevavseva tmpscZSVg/test/testWithXmlVerbose.txt0000644000175000017500000000102112777131574017362 0ustar vsevavseva# XML output to test/ref/testWithXmlVerbose.xml # Started on 01/01/16 22:13:03 # Starting class: TestFailuresWithXml # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml # Failure: test/test_with_xml.lua:13: expected: "got it" actual: "cdata does not like ]]>" # Starting test: TestFailuresWithXml.test_failure_with_simple_xml # Failure: test/test_with_xml.lua:9: expected: "got it" actual: 'ti"ti' # Starting test: TestThatLastsALongTime # Ran 3 tests in 1.102 seconds, 1 success, 2 failures tmpscZSVg/test/errFailPassXmlDefault-success.txt0000644000175000017500000000072012777131574021414 0ustar vsevavseva# XML output to test/ref/errFailPassXmlDefault-success.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: testFuncSuccess1 # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/exampleXmlQuiet.xml0000644000175000017500000001106012777131575016652 0ustar vsevavseva tmpscZSVg/test/testWithXmlQuiet.txt0000644000175000017500000000101712777131572017047 0ustar vsevavseva# XML output to test/ref/testWithXmlQuiet.xml # Started on 01/01/16 22:13:04 # Starting class: TestFailuresWithXml # Starting test: TestFailuresWithXml.test_failure_with_cdata_xml # Failure: test/test_with_xml.lua:13: expected: "got it" actual: "cdata does not like ]]>" # Starting test: TestFailuresWithXml.test_failure_with_simple_xml # Failure: test/test_with_xml.lua:9: expected: "got it" actual: 'ti"ti' # Starting test: TestThatLastsALongTime # Ran 3 tests in 1.102 seconds, 1 success, 2 failures tmpscZSVg/test/errFailPassTextDefault-success.txt0000644000175000017500000000012312777131574021575 0ustar vsevavseva..... Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/test/testWithXmlQuiet.xml0000644000175000017500000000260212777131572017031 0ustar vsevavseva tmpscZSVg/test/exampleTextVerbose.txt0000644000175000017500000000667112777131574017406 0ustar vsevavsevaStarted on 01/27/16 21:35:20 TestTiti.test1_withFailure ... FAIL example_with_luaunit.lua:101: expected: 2, actual: 1 TestTiti.test2_withFailure ... FAIL example_with_luaunit.lua:110: expected: "bof" actual: "hop" TestTiti.test3 ... Ok TestToto.test1_withFailure ... FAIL example_with_luaunit.lua:21: expected: 2, actual: 1 TestToto.test2_withFailure ... FAIL example_with_luaunit.lua:30: expected: "bof" actual: "hop" TestToto.test3 ... Ok TestToto.test4 ... FAIL example_with_luaunit.lua:43: Received the not expected value: 1 TestToto.test5 ... FAIL example_with_luaunit.lua:49: expected: false, actual: 1 TestToto.test6 ... FAIL example_with_luaunit.lua:54: expected: true, actual: false TestToto.test7 ... FAIL example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} TestToto.test8a ... ERROR example_with_luaunit.lua:78: Bouhouhoum error! TestToto.test8b ... ERROR example_with_luaunit.lua:78: Bouhouhoum error! test1_withFailure ... ERROR example_with_luaunit.lua:126: assertion failed! test2_withFailure ... ERROR example_with_luaunit.lua:132: assertion failed! test3 ... Ok ========================================================= Failed tests: ------------- 1) TestTiti.test1_withFailure example_with_luaunit.lua:101: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:101: in function 'TestTiti.test1_withFailure' 2) TestTiti.test2_withFailure example_with_luaunit.lua:110: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:110: in function 'TestTiti.test2_withFailure' 3) TestToto.test1_withFailure example_with_luaunit.lua:21: expected: 2, actual: 1 stack traceback: example_with_luaunit.lua:21: in function 'TestToto.test1_withFailure' 4) TestToto.test2_withFailure example_with_luaunit.lua:30: expected: "bof" actual: "hop" stack traceback: example_with_luaunit.lua:30: in function 'TestToto.test2_withFailure' 5) TestToto.test4 example_with_luaunit.lua:43: Received the not expected value: 1 stack traceback: example_with_luaunit.lua:43: in function 'TestToto.test4' 6) TestToto.test5 example_with_luaunit.lua:49: expected: false, actual: 1 stack traceback: example_with_luaunit.lua:49: in function 'TestToto.test5' 7) TestToto.test6 example_with_luaunit.lua:54: expected: true, actual: false stack traceback: example_with_luaunit.lua:54: in function 'TestToto.test6' 8) TestToto.test7 example_with_luaunit.lua:60: expected: {1, 2, three=3} actual: {1, 2} stack traceback: example_with_luaunit.lua:60: in function 'TestToto.test7' 9) TestToto.test8a example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:65: in function 'TestToto.test8a' 10) TestToto.test8b example_with_luaunit.lua:78: Bouhouhoum error! stack traceback: example_with_luaunit.lua:78: in function 'funcWithError' example_with_luaunit.lua:74: in function 'funcWithFuncWithError' example_with_luaunit.lua:70: in function 'TestToto.test8b' 11) test1_withFailure example_with_luaunit.lua:126: assertion failed! stack traceback: example_with_luaunit.lua:126: in function 'test1_withFailure' 12) test2_withFailure example_with_luaunit.lua:132: assertion failed! stack traceback: example_with_luaunit.lua:132: in function 'test2_withFailure' Ran 15 tests in 0.004 seconds, 3 successes, 8 failures, 4 errors tmpscZSVg/test/compat_luaunit_v2x.lua0000644000175000017500000001423212777131552017331 0ustar vsevavsevaEXPORT_ASSERT_TO_GLOBALS = true local lu = require('luaunit') --[[ Use Luaunit in the v2.1 fashion and check that it still works. Exercise every luaunit v2.1 function and have it executed successfully. Coverage: x Made LuaUnit:run() method able to be called with 'run' or 'Run'. x Made LuaUnit.wrapFunctions() function able to be called with 'wrapFunctions' or 'WrapFunctions' or 'wrap_functions'. x Moved wrapFunctions to the LuaUnit module table (e.g. local LuaUnit = require( "luaunit" ); LuaUnit.wrapFunctions( ... ) ) x Added LuaUnit.is and LuaUnit.is_ helper functions. (e.g. assert( LuaUnit.isString( getString() ) ) x Added assert and assert_ x Added assertNot and assert_not_ x Added _VERSION variable to hold the LuaUnit version x Added LuaUnit:setVerbosity(lvl) method to the LuaUnit. Alias: LuaUnit:SetVerbosity() and LuaUnit:set_verbosity(). x Added table deep compare x check that wrapFunctions works x Made "testable" classes able to start with 'test' or 'Test' for their name. x Made "testable" methods able to start with 'test' or 'Test' for their name. x Made testClass:setUp() methods able to be named with 'setUp' or 'Setup' or 'setup'. x Made testClass:tearDown() methods able to be named with 'tearDown' or 'TearDown' or 'teardown'. ]] TestLuaUnitV2Compat = {} function TestLuaUnitV2Compat:testRunAliases() -- some old function assertFunction( lu.run ) assertEquals( lu.Run, lu.run ) end function TestLuaUnitV2Compat:testWrapFunctionsAliases() assertFunction( lu.wrapFunctions ) assertEquals( lu.wrapFunctions, lu.WrapFunctions ) assertEquals( lu.wrapFunctions, lu.wrap_functions ) end local function typeAsserter( goodType, badType, goodAsserter, badAsserter ) goodAsserter( goodType ) if badAsserter ~= nil then badAsserter( badType ) end end function TestLuaUnitV2Compat:testAssertType() local f = function (v) return v+1 end local t = coroutine.create( function(v) local y=v+1 end ) local typesToVerify = { -- list of: { goodType, badType, goodAsserter, badAsserter } { true, "toto", assertBoolean, assertNotBoolean }, { true, "toto", assert_boolean, assert_not_boolean }, { 1 , "toto", assertNumber, assertNotNumber }, { 1 , "toto", assert_number, assert_not_number }, { "q" , 1 , assertString, assertNotString }, { "q" , 1 , assert_string, assert_not_string }, { nil , 1 , assertNil, assertNotNil }, { nil , 1 , assert_nil, assert_not_nil }, { {1,2}, "toto", assertTable, assertNotTable }, { {1,2}, "toto", assert_table, assert_not_table }, { f , "toto", assertFunction, assertNotFunction }, { f , "toto", assert_function,assert_not_function }, { t , "toto", assertThread, assertNotThread }, { t , "toto", assert_thread, assert_not_thread }, } for _,v in ipairs( typesToVerify ) do local goodType, badType, goodAsserter, badAsserter = v[1], v[2], v[3], v[4] typeAsserter( goodType, badType, goodAsserter, badAsserter ) end assertNotUserdata( "toto" ) local typesToVerify2 = { { true, "toto", lu.isBoolean }, { true, "toto", lu.is_boolean }, { 1, "toto", lu.isNumber }, { 1, "toto", lu.is_number }, { "t", 1, lu.isString }, { "t", 1, lu.is_string }, { nil, "toto", lu.isNil }, { nil, "toto", lu.is_nil }, { {1,2},"toto", lu.isTable }, { {1,2},"toto", lu.is_table }, { f, "toto", lu.isFunction }, { f, "toto", lu.is_function }, { t, "toto", lu.isThread }, { t, "toto", lu.is_thread }, } for _,v in ipairs( typesToVerify2 ) do local goodType, badType, goodTypeVerifier = v[1], v[2], v[3] if (v[3] == nil) then print('Missing function at index '.._) assertNotNil( v[3] ) end assertTrue ( goodTypeVerifier( goodType ) ) assertFalse( goodTypeVerifier( badType ) ) end end function TestLuaUnitV2Compat:testHasVersionKey() assertNotNil( lu.VERSION ) assertString( lu.VERSION ) assertNotNil( lu._VERSION ) assertTrue( lu.is_string( lu._VERSION ) ) end function TestLuaUnitV2Compat:testTableEquality() local t1 = {1,2} local t2 = t1 local t3 = {1,2} local t4 = {1,2,3} assertEquals( t1, t1 ) assertEquals( t1, t2 ) -- new in LuaUnit v2.0 , deep table compare assertEquals( t1, t3 ) assertError( assertEquals, t1, t4 ) end -- Setup local called = {} function test_w1() called.w1 = true end function test_w2() called.w2 = true end function test_w3() called.w3 = true end TestSomeFuncs = lu.wrapFunctions( 'test_w1', 'test_w2', 'test_w3' ) TestWithCap = {} function TestWithCap:setup() called.setup = true end function TestWithCap:Test1() called.t1 = true end function TestWithCap:test2() called.t2 = true end function TestWithCap:teardown() called.teardown = true end testWithoutCap = {} function testWithoutCap:Setup() called.Setup = true end function testWithoutCap:Test3() called.t3 = true end function testWithoutCap:test4() called.t4 = true end function testWithoutCap:tearDown() called.tearDown = true end TestWithUnderscore = {} function TestWithUnderscore:setUp() called.setUp = true end function TestWithUnderscore:Test1() called.t1 = true end function TestWithUnderscore:test2() called.t2 = true end function TestWithUnderscore:TearDown() called.TearDown = true end -- Run lu:setVerbosity( 1 ) lu:set_verbosity( 1 ) lu:SetVerbosity( 1 ) local results = lu.run() -- Verif assert( called.w1 == true ) assert( called.w2 == true ) assert( called.w3 == true ) assert( called.t1 == true ) assert( called.t2 == true ) assert( called.t3 == true ) assert( called.t4 == true ) assert( called.setup == true ) assert( called.setUp == true ) assert( called.Setup == true ) assert( called.teardown == true ) assert( called.tearDown == true ) assert( called.TearDown == true ) os.exit( results ) tmpscZSVg/test/errFailPassTextQuiet-failures.txt0000644000175000017500000000203412777131574021445 0ustar vsevavseva..FF..FFF. Failed tests: ------------- 1) TestAnotherThing.test3_Fail1 test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:49: in function 'TestAnotherThing.test3_Fail1' 2) TestAnotherThing.test3_Fail2 test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:53: in function 'TestAnotherThing.test3_Fail2' 3) TestSomething.test2_Fail1 test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 stack traceback: test/test_with_err_fail_pass.lua:15: in function 'TestSomething.test2_Fail1' 4) TestSomething.test2_Fail2 test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:19: in function 'TestSomething.test2_Fail2' 5) testFuncFail1 test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 stack traceback: test/test_with_err_fail_pass.lua:62: in function 'testFuncFail1' Ran 10 tests in 0.001 seconds, 5 successes, 5 failures, 5 non-selected tmpscZSVg/test/errFailPassXmlQuiet-success.xml0000644000175000017500000000200312777131575021075 0ustar vsevavseva tmpscZSVg/test/errFailPassXmlQuiet-success.txt0000644000175000017500000000071612777131575021125 0ustar vsevavseva# XML output to test/ref/errFailPassXmlQuiet-success.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: testFuncSuccess1 # Ran 5 tests in 0.001 seconds, 5 successes, 0 failures, 10 non-selected tmpscZSVg/test/test_with_xml.lua0000644000175000017500000000107412777131552016400 0ustar vsevavseva local lu = require('luaunit') TestFailuresWithXml = {} --class TestFailuresWithXml.__class__ = 'TestFailuresWithXml' function TestFailuresWithXml:test_failure_with_simple_xml() lu.assertEquals( 'ti"ti', 'got it' ) end function TestFailuresWithXml:test_failure_with_cdata_xml() lu.assertEquals( 'cdata does not like ]]>', 'got it' ) end function TestThatLastsALongTime() local start = os.clock() while os.clock() - start < 1.1 do end end lu.LuaUnit.verbosity = 2 os.exit( lu.LuaUnit.run() ) tmpscZSVg/test/exampleNilDefault.txt0000644000175000017500000000000012777131567017141 0ustar vsevavsevatmpscZSVg/test/errFailPassXmlQuiet.txt0000644000175000017500000000324512777131575017457 0ustar vsevavseva# XML output to test/ref/errFailPassXmlQuiet.xml # Started on 03/22/16 21:29:18 # Starting class: TestAnotherThing # Starting test: TestAnotherThing.test1_Success1 # Starting test: TestAnotherThing.test1_Success2 # Starting test: TestAnotherThing.test2_Err1 # Error: test/test_with_err_fail_pass.lua:41: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test2_Err2 # Error: test/test_with_err_fail_pass.lua:45: attempt to perform arithmetic on a table value # Starting test: TestAnotherThing.test3_Fail1 # Failure: test/test_with_err_fail_pass.lua:49: expected: 0, actual: 2 # Starting test: TestAnotherThing.test3_Fail2 # Failure: test/test_with_err_fail_pass.lua:53: expected: 0, actual: 3 # Starting class: TestSomething # Starting test: TestSomething.test1_Success1 # Starting test: TestSomething.test1_Success2 # Starting test: TestSomething.test2_Fail1 # Failure: test/test_with_err_fail_pass.lua:15: expected: 0, actual: 2 # Starting test: TestSomething.test2_Fail2 # Failure: test/test_with_err_fail_pass.lua:19: expected: 0, actual: 3 # Starting test: TestSomething.test3_Err1 # Error: test/test_with_err_fail_pass.lua:23: attempt to perform arithmetic on a table value # Starting test: TestSomething.test3_Err2 # Error: test/test_with_err_fail_pass.lua:27: attempt to perform arithmetic on a table value # Starting test: testFuncErr1 # Error: test/test_with_err_fail_pass.lua:66: attempt to perform arithmetic on a table value # Starting test: testFuncFail1 # Failure: test/test_with_err_fail_pass.lua:62: expected: 0, actual: 3 # Starting test: testFuncSuccess1 # Ran 15 tests in 0.003 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/errFailPassTapQuiet.txt0000644000175000017500000000131212777131570017427 0ustar vsevavseva1..15 # Started on 03/22/16 21:58:32 # Starting class: TestAnotherThing ok 1 TestAnotherThing.test1_Success1 ok 2 TestAnotherThing.test1_Success2 not ok 3 TestAnotherThing.test2_Err1 not ok 4 TestAnotherThing.test2_Err2 not ok 5 TestAnotherThing.test3_Fail1 not ok 6 TestAnotherThing.test3_Fail2 # Starting class: TestSomething ok 7 TestSomething.test1_Success1 ok 8 TestSomething.test1_Success2 not ok 9 TestSomething.test2_Fail1 not ok 10 TestSomething.test2_Fail2 not ok 11 TestSomething.test3_Err1 not ok 12 TestSomething.test3_Err2 not ok 13 testFuncErr1 not ok 14 testFuncFail1 ok 15 testFuncSuccess1 # Ran 15 tests in 0.002 seconds, 5 successes, 5 failures, 5 errors tmpscZSVg/test/errFailPassNilDefault-success.txt0000644000175000017500000000000012777131567021367 0ustar vsevavsevatmpscZSVg/test/errFailPassTextVerbose-success.txt0000644000175000017500000000055412777131574021626 0ustar vsevavsevaStarted on 03/22/16 21:29:18 TestAnotherThing.test1_Success1 ... Ok TestAnotherThing.test1_Success2 ... Ok TestSomething.test1_Success1 ... Ok TestSomething.test1_Success2 ... Ok testFuncSuccess1 ... Ok ========================================================= Ran 5 tests in 0.000 seconds, 5 successes, 0 failures, 10 non-selected OK tmpscZSVg/luaunit.lua0000644000175000017500000023656112777131552014223 0ustar vsevavseva--[[ luaunit.lua Description: A unit testing framework Homepage: https://github.com/bluebird75/luaunit Development by Philippe Fremy Based on initial work of Ryu, Gwang (http://www.gpgstudy.com/gpgiki/LuaUnit) License: BSD License, see LICENSE.txt Version: 3.2 ]]-- require("math") local M={} -- private exported functions (for testing) M.private = {} M.VERSION='3.2' M._VERSION=M.VERSION -- For LuaUnit v2 compatibility --[[ Some people like assertEquals( actual, expected ) and some people prefer assertEquals( expected, actual ). ]]-- M.ORDER_ACTUAL_EXPECTED = true M.PRINT_TABLE_REF_IN_ERROR_MSG = false M.TABLE_EQUALS_KEYBYCONTENT = true M.LINE_LENGTH=80 -- set this to false to debug luaunit local STRIP_LUAUNIT_FROM_STACKTRACE=true M.VERBOSITY_DEFAULT = 10 M.VERBOSITY_LOW = 1 M.VERBOSITY_QUIET = 0 M.VERBOSITY_VERBOSE = 20 -- set EXPORT_ASSERT_TO_GLOBALS to have all asserts visible as global values -- EXPORT_ASSERT_TO_GLOBALS = true -- we need to keep a copy of the script args before it is overriden local cmdline_argv = rawget(_G, "arg") M.FAILURE_PREFIX = 'LuaUnit test FAILURE: ' -- prefix string for failed tests M.USAGE=[[Usage: lua [options] [testname1 [testname2] ... ] Options: -h, --help: Print this help --version: Print version information -v, --verbose: Increase verbosity -q, --quiet: Set verbosity to minimum -e, --error: Stop on first error -f, --failure: Stop on first failure or error -o, --output OUTPUT: Set output type to OUTPUT Possible values: text, tap, junit, nil -n, --name NAME: For junit only, mandatory name of xml file -p, --pattern PATTERN: Execute all test names matching the Lua PATTERN May be repeated to include severals patterns Make sure you escape magic chars like +? with % testname1, testname2, ... : tests to run in the form of testFunction, TestClass or TestClass.testMethod ]] ---------------------------------------------------------------- -- -- general utility functions -- ---------------------------------------------------------------- local crossTypeOrdering = { number = 1, boolean = 2, string = 3, table = 4, other = 5 } local crossTypeComparison = { number = function(a, b) return a < b end, string = function(a, b) return a < b end, other = function(a, b) return tostring(a) < tostring(b) end, } local function crossTypeSort(a, b) local type_a, type_b = type(a), type(b) if type_a == type_b then local func = crossTypeComparison[type_a] or crossTypeComparison.other return func(a, b) end type_a = crossTypeOrdering[type_a] or crossTypeOrdering.other type_b = crossTypeOrdering[type_b] or crossTypeOrdering.other return type_a < type_b end local function __genSortedIndex( t ) -- Returns a sequence consisting of t's keys, sorted. local sortedIndex = {} for key,_ in pairs(t) do table.insert(sortedIndex, key) end table.sort(sortedIndex, crossTypeSort) return sortedIndex end M.private.__genSortedIndex = __genSortedIndex local function sortedNext(state, control) -- Equivalent of the next() function of table iteration, but returns the -- keys in sorted order (see __genSortedIndex and crossTypeSort). -- The state is a temporary variable during iteration and contains the -- sorted key table (state.sortedIdx). It also stores the last index (into -- the keys) used by the iteration, to find the next one quickly. local key --print("sortedNext: control = "..tostring(control) ) if control == nil then -- start of iteration state.lastIdx = 1 key = state.sortedIdx[1] return key, state.t[key] end -- normally, we expect the control variable to match the last key used if control ~= state.sortedIdx[state.lastIdx] then -- strange, we have to find the next value by ourselves -- the key table is sorted in crossTypeSort() order! -> use bisection local count = #state.sortedIdx local lower, upper = 1, count repeat state.lastIdx = math.modf((lower + upper) / 2) key = state.sortedIdx[state.lastIdx] if key == control then break; end -- key found (and thus prev index) if crossTypeSort(key, control) then -- key < control, continue search "right" (towards upper bound) lower = state.lastIdx + 1 else -- key > control, continue search "left" (towards lower bound) upper = state.lastIdx - 1 end until lower > upper if lower > upper then -- only true if the key wasn't found, ... state.lastIdx = count -- ... so ensure no match for the code below end end -- proceed by retrieving the next value (or nil) from the sorted keys state.lastIdx = state.lastIdx + 1 key = state.sortedIdx[state.lastIdx] if key then return key, state.t[key] end -- getting here means returning `nil`, which will end the iteration end local function sortedPairs(tbl) -- Equivalent of the pairs() function on tables. Allows to iterate in -- sorted order. As required by "generic for" loops, this will return the -- iterator (function), an "invariant state", and the initial control value. -- (see http://www.lua.org/pil/7.2.html) return sortedNext, {t = tbl, sortedIdx = __genSortedIndex(tbl)}, nil end M.private.sortedPairs = sortedPairs local function strsplit(delimiter, text) -- Split text into a list consisting of the strings in text, separated -- by strings matching delimiter (which may _NOT_ be a pattern). -- Example: strsplit(", ", "Anna, Bob, Charlie, Dolores") if delimiter == "" then -- this would result in endless loops error("delimiter matches empty string!") end local list, pos, first, last = {}, 1 while true do first, last = text:find(delimiter, pos, true) if first then -- found? table.insert(list, text:sub(pos, first - 1)) pos = last + 1 else table.insert(list, text:sub(pos)) break end end return list end M.private.strsplit = strsplit local function hasNewLine( s ) -- return true if s has a newline return (string.find(s, '\n', 1, true) ~= nil) end M.private.hasNewLine = hasNewLine local function prefixString( prefix, s ) -- Prefix all the lines of s with prefix return prefix .. string.gsub(s, '\n', '\n' .. prefix) end M.private.prefixString = prefixString local function strMatch(s, pattern, start, final ) -- return true if s matches completely the pattern from index start to index end -- return false in every other cases -- if start is nil, matches from the beginning of the string -- if final is nil, matches to the end of the string start = start or 1 final = final or string.len(s) local foundStart, foundEnd = string.find(s, pattern, start, false) return foundStart == start and foundEnd == final end M.private.strMatch = strMatch local function xmlEscape( s ) -- Return s escaped for XML attributes -- escapes table: -- " " -- ' ' -- < < -- > > -- & & return string.gsub( s, '.', { ['&'] = "&", ['"'] = """, ["'"] = "'", ['<'] = "<", ['>'] = ">", } ) end M.private.xmlEscape = xmlEscape local function xmlCDataEscape( s ) -- Return s escaped for CData section, escapes: "]]>" return string.gsub( s, ']]>', ']]>' ) end M.private.xmlCDataEscape = xmlCDataEscape local function stripLuaunitTrace( stackTrace ) --[[ -- Example of a traceback: < [C]: in function 'xpcall' ./luaunit.lua:1449: in function 'protectedCall' ./luaunit.lua:1508: in function 'execOneFunction' ./luaunit.lua:1596: in function 'runSuiteByInstances' ./luaunit.lua:1660: in function 'runSuiteByNames' ./luaunit.lua:1736: in function 'runSuite' example_with_luaunit.lua:140: in main chunk [C]: in ?>> Other example: < [C]: in function 'xpcall' ./luaunit.lua:1517: in function 'protectedCall' ./luaunit.lua:1578: in function 'execOneFunction' ./luaunit.lua:1677: in function 'runSuiteByInstances' ./luaunit.lua:1730: in function 'runSuiteByNames' ./luaunit.lua:1806: in function 'runSuite' example_with_luaunit.lua:140: in main chunk [C]: in ?>> < [C]: in function 'xpcall' luaunit2/luaunit.lua:1532: in function 'protectedCall' luaunit2/luaunit.lua:1591: in function 'execOneFunction' luaunit2/luaunit.lua:1679: in function 'runSuiteByInstances' luaunit2/luaunit.lua:1743: in function 'runSuiteByNames' luaunit2/luaunit.lua:1819: in function 'runSuite' luaunit2/example_with_luaunit.lua:140: in main chunk [C]: in ?>> -- first line is "stack traceback": KEEP -- next line may be luaunit line: REMOVE -- next lines are call in the program under testOk: REMOVE -- next lines are calls from luaunit to call the program under test: KEEP -- Strategy: -- keep first line -- remove lines that are part of luaunit -- kepp lines until we hit a luaunit line ]] local function isLuaunitInternalLine( s ) -- return true if line of stack trace comes from inside luaunit return s:find('[/\\]luaunit%.lua:%d+: ') ~= nil end -- print( '<<'..stackTrace..'>>' ) local t = strsplit( '\n', stackTrace ) -- print( prettystr(t) ) local idx = 2 -- remove lines that are still part of luaunit while t[idx] and isLuaunitInternalLine( t[idx] ) do -- print('Removing : '..t[idx] ) table.remove(t, idx) end -- keep lines until we hit luaunit again while t[idx] and (not isLuaunitInternalLine(t[idx])) do -- print('Keeping : '..t[idx] ) idx = idx + 1 end -- remove remaining luaunit lines while t[idx] do -- print('Removing : '..t[idx] ) table.remove(t, idx) end -- print( prettystr(t) ) return table.concat( t, '\n') end M.private.stripLuaunitTrace = stripLuaunitTrace local function prettystr_sub(v, indentLevel, keeponeline, printTableRefs, recursionTable ) local type_v = type(v) if "string" == type_v then if keeponeline then v = v:gsub("\n", "\\n") end -- use clever delimiters according to content: -- enclose with single quotes if string contains ", but no ' if v:find('"', 1, true) and not v:find("'", 1, true) then return "'" .. v .. "'" end -- use double quotes otherwise, escape embedded " return '"' .. v:gsub('"', '\\"') .. '"' elseif "table" == type_v then --if v.__class__ then -- return string.gsub( tostring(v), 'table', v.__class__ ) --end return M.private._table_tostring(v, indentLevel, printTableRefs, recursionTable) end return tostring(v) end local function prettystr( v, keeponeline ) --[[ Better string conversion, to display nice variable content: For strings, if keeponeline is set to true, string is displayed on one line, with visible \n * string are enclosed with " by default, or with ' if string contains a " * if table is a class, display class name * tables are expanded ]]-- local recursionTable = {} local s = prettystr_sub(v, 1, keeponeline, M.PRINT_TABLE_REF_IN_ERROR_MSG, recursionTable) if recursionTable.recursionDetected and not M.PRINT_TABLE_REF_IN_ERROR_MSG then -- some table contain recursive references, -- so we must recompute the value by including all table references -- else the result looks like crap recursionTable = {} s = prettystr_sub(v, 1, keeponeline, true, recursionTable) end return s end M.prettystr = prettystr local function prettystrPadded(value1, value2, suffix_a, suffix_b) --[[ This function helps with the recurring task of constructing the "expected vs. actual" error messages. It takes two arbitrary values and formats corresponding strings with prettystr(). To keep the (possibly complex) output more readable in case the resulting strings contain line breaks, they get automatically prefixed with additional newlines. Both suffixes are optional (default to empty strings), and get appended to the "value1" string. "suffix_a" is used if line breaks were encountered, "suffix_b" otherwise. Returns the two formatted strings (including padding/newlines). ]] local str1, str2 = prettystr(value1), prettystr(value2) if hasNewLine(str1) or hasNewLine(str2) then -- line break(s) detected, add padding return "\n" .. str1 .. (suffix_a or ""), "\n" .. str2 end return str1 .. (suffix_b or ""), str2 end M.private.prettystrPadded = prettystrPadded local function _table_keytostring(k) -- like prettystr but do not enclose with "" if the string is just alphanumerical -- this is better for displaying table keys who are often simple strings if "string" == type(k) and k:match("^[_%a][_%w]*$") then return k end return prettystr(k) end M.private._table_keytostring = _table_keytostring local TABLE_TOSTRING_SEP = ", " local TABLE_TOSTRING_SEP_LEN = string.len(TABLE_TOSTRING_SEP) local function _table_tostring( tbl, indentLevel, printTableRefs, recursionTable ) printTableRefs = printTableRefs or M.PRINT_TABLE_REF_IN_ERROR_MSG recursionTable = recursionTable or {} recursionTable[tbl] = true local result, dispOnMultLines = {}, false local entry, count, seq_index = nil, 0, 1 for k, v in sortedPairs( tbl ) do if k == seq_index then -- for the sequential part of tables, we'll skip the "=" output entry = '' seq_index = seq_index + 1 else entry = _table_keytostring( k ) .. "=" end if recursionTable[v] then -- recursion detected! recursionTable.recursionDetected = true entry = entry .. "<"..tostring(v)..">" else entry = entry .. prettystr_sub( v, indentLevel+1, true, printTableRefs, recursionTable ) end count = count + 1 result[count] = entry end -- set dispOnMultLines if the maximum LINE_LENGTH would be exceeded local totalLength = 0 for k, v in ipairs( result ) do totalLength = totalLength + string.len( v ) if totalLength >= M.LINE_LENGTH then dispOnMultLines = true break end end if not dispOnMultLines then -- adjust with length of separator(s): -- two items need 1 sep, three items two seps, ... plus len of '{}' if count > 0 then totalLength = totalLength + TABLE_TOSTRING_SEP_LEN * (count - 1) end dispOnMultLines = totalLength + 2 >= M.LINE_LENGTH end -- now reformat the result table (currently holding element strings) if dispOnMultLines then local indentString = string.rep(" ", indentLevel - 1) result = {"{\n ", indentString, table.concat(result, ",\n " .. indentString), "\n", indentString, "}"} else result = {"{", table.concat(result, TABLE_TOSTRING_SEP), "}"} end if printTableRefs then table.insert(result, 1, "<"..tostring(tbl).."> ") -- prepend table ref end return table.concat(result) end M.private._table_tostring = _table_tostring -- prettystr_sub() needs it local function _table_contains(t, element) if type(t) == "table" then local type_e = type(element) for _, value in pairs(t) do if type(value) == type_e then if value == element then return true end if type_e == 'table' then -- if we wanted recursive items content comparison, we could use -- _is_table_items_equals(v, expected) but one level of just comparing -- items is sufficient if M.private._is_table_equals( value, element ) then return true end end end end end return false end local function _is_table_items_equals(actual, expected ) local type_a, type_e = type(actual), type(expected) if (type_a == 'table') and (type_e == 'table') then for k, v in pairs(actual) do if not _table_contains(expected, v) then return false end end for k, v in pairs(expected) do if not _table_contains(actual, v) then return false end end return true elseif type_a ~= type_e then return false elseif actual ~= expected then return false end return true end local function _is_table_equals(actual, expected, recursions) local type_a, type_e = type(actual), type(expected) recursions = recursions or {} if type_a ~= type_e then return false -- different types won't match end if (type_a == 'table') --[[ and (type_e == 'table') ]] and not recursions[actual] then -- Tables must have identical element count, or they can't match. if (#actual ~= #expected) then return false end -- add "actual" to the recursions table, to detect and avoid loops recursions[actual] = true local actualKeysMatched, actualTableKeys = {}, {} for k, v in pairs(actual) do if M.TABLE_EQUALS_KEYBYCONTENT and type(k) == "table" then -- If the keys are tables, things get a bit tricky here as we -- can have _is_table_equals(k1, k2) and t[k1] ~= t[k2]. So we -- collect actual's table keys, group them by length for -- performance, and then for each table key in expected we look -- it up in actualTableKeys. local count = #k if not actualTableKeys[count] then actualTableKeys[count] = {} end table.insert(actualTableKeys[count], k) else if not _is_table_equals(v, expected[k], recursions) then return false -- Mismatch on value, tables can't be equal end actualKeysMatched[k] = true -- Keep track of matched keys end end for k, v in pairs(expected) do if M.TABLE_EQUALS_KEYBYCONTENT and type(k) == "table" then local candidates, found = actualTableKeys[#k], nil if not candidates then return false end for i, candidate in pairs(candidates) do if _is_table_equals(candidate, k) then found = candidate -- Remove the candidate we matched against from the list -- of candidates, so each key in actual can only match -- one key in expected. candidates[i] = nil break end end if not(found and _is_table_equals(actual[found], v)) then -- Either no matching key, or a different value return false end else if not actualKeysMatched[k] then -- Found a key that we did not see in "actual" -> mismatch return false end -- Otherwise we know that actual[k] was already matched -- against v = expected[k]. Remove k from the table again. actualKeysMatched[k] = nil end end -- If we have any keys left in the actualKeysMatched table, then those -- were missing from "expected", meaning the tables are different. if next(actualKeysMatched) then return false end if M.TABLE_EQUALS_KEYBYCONTENT then for _, keys in pairs(actualTableKeys) do -- if there are any keys left in any actualTableKeys[i] then -- that is a key in actual with no matching key in expected, -- and so the tables aren't equal. if next(keys) then return false end end end return true elseif actual ~= expected then return false end return true end M.private._is_table_equals = _is_table_equals local function failure(msg, level) -- raise an error indicating a test failure -- for error() compatibility we adjust "level" here (by +1), to report the -- calling context error(M.FAILURE_PREFIX .. msg, (level or 1) + 1) end local function fail_fmt(level, ...) -- failure with printf-style formatted message and given error level failure(string.format(...), (level or 1) + 1) end M.private.fail_fmt = fail_fmt local function error_fmt(level, ...) -- printf-style error() error(string.format(...), (level or 1) + 1) end ---------------------------------------------------------------- -- -- assertions -- ---------------------------------------------------------------- local function errorMsgEquality(actual, expected) if not M.ORDER_ACTUAL_EXPECTED then expected, actual = actual, expected end if type(expected) == 'string' or type(expected) == 'table' then expected, actual = prettystrPadded(expected, actual) return string.format("expected: %s\nactual: %s", expected, actual) end return string.format("expected: %s, actual: %s", prettystr(expected), prettystr(actual)) end function M.assertError(f, ...) -- assert that calling f with the arguments will raise an error -- example: assertError( f, 1, 2 ) => f(1,2) should generate an error if pcall( f, ... ) then failure( "Expected an error when calling function but no error generated", 2 ) end end function M.assertTrue(value) if not value then failure("expected: true, actual: " ..prettystr(value), 2) end end function M.assertFalse(value) if value then failure("expected: false, actual: " ..prettystr(value), 2) end end function M.assertIsNil(value) if value ~= nil then failure("expected: nil, actual: " ..prettystr(value), 2) end end function M.assertNotIsNil(value) if value == nil then failure("expected non nil value, received nil", 2) end end function M.assertEquals(actual, expected) if type(actual) == 'table' and type(expected) == 'table' then if not _is_table_equals(actual, expected) then failure( errorMsgEquality(actual, expected), 2 ) end elseif type(actual) ~= type(expected) then failure( errorMsgEquality(actual, expected), 2 ) elseif actual ~= expected then failure( errorMsgEquality(actual, expected), 2 ) end end -- Help Lua in corner cases like almostEquals(1.1, 1.0, 0.1), which by default -- may not work. We need to give margin a small boost; EPSILON defines the -- default value to use for this: local EPSILON = 1E-11 function M.almostEquals( actual, expected, margin, margin_boost ) if type(actual) ~= 'number' or type(expected) ~= 'number' or type(margin) ~= 'number' then error_fmt(3, 'almostEquals: must supply only number arguments.\nArguments supplied: %s, %s, %s', prettystr(actual), prettystr(expected), prettystr(margin)) end if margin < 0 then error('almostEquals: margin must not be negative, current value is ' .. margin, 3) end local realmargin = margin + (margin_boost or EPSILON) return math.abs(expected - actual) <= realmargin end function M.assertAlmostEquals( actual, expected, margin ) -- check that two floats are close by margin if not M.almostEquals(actual, expected, margin) then if not M.ORDER_ACTUAL_EXPECTED then expected, actual = actual, expected end fail_fmt(2, 'Values are not almost equal\nExpected: %s with margin of %s, received: %s', expected, margin, actual) end end function M.assertNotEquals(actual, expected) if type(actual) ~= type(expected) then return end if type(actual) == 'table' and type(expected) == 'table' then if not _is_table_equals(actual, expected) then return end elseif actual ~= expected then return end fail_fmt(2, 'Received the not expected value: %s', prettystr(actual)) end function M.assertNotAlmostEquals( actual, expected, margin ) -- check that two floats are not close by margin if M.almostEquals(actual, expected, margin) then if not M.ORDER_ACTUAL_EXPECTED then expected, actual = actual, expected end fail_fmt(2, 'Values are almost equal\nExpected: %s with a difference above margin of %s, received: %s', expected, margin, actual) end end function M.assertStrContains( str, sub, useRe ) -- this relies on lua string.find function -- a string always contains the empty string if not string.find(str, sub, 1, not useRe) then sub, str = prettystrPadded(sub, str, '\n') fail_fmt(2, 'Error, %s %s was not found in string %s', useRe and 'regexp' or 'substring', sub, str) end end function M.assertStrIContains( str, sub ) -- this relies on lua string.find function -- a string always contains the empty string if not string.find(str:lower(), sub:lower(), 1, true) then sub, str = prettystrPadded(sub, str, '\n') fail_fmt(2, 'Error, substring %s was not found (case insensitively) in string %s', sub, str) end end function M.assertNotStrContains( str, sub, useRe ) -- this relies on lua string.find function -- a string always contains the empty string if string.find(str, sub, 1, not useRe) then sub, str = prettystrPadded(sub, str, '\n') fail_fmt(2, 'Error, %s %s was found in string %s', useRe and 'regexp' or 'substring', sub, str) end end function M.assertNotStrIContains( str, sub ) -- this relies on lua string.find function -- a string always contains the empty string if string.find(str:lower(), sub:lower(), 1, true) then sub, str = prettystrPadded(sub, str, '\n') fail_fmt(2, 'Error, substring %s was found (case insensitively) in string %s', sub, str) end end function M.assertStrMatches( str, pattern, start, final ) -- Verify a full match for the string -- for a partial match, simply use assertStrContains with useRe set to true if not strMatch( str, pattern, start, final ) then pattern, str = prettystrPadded(pattern, str, '\n') fail_fmt(2, 'Error, pattern %s was not matched by string %s', pattern, str) end end function M.assertErrorMsgEquals( expectedMsg, func, ... ) -- assert that calling f with the arguments will raise an error -- example: assertError( f, 1, 2 ) => f(1,2) should generate an error local no_error, error_msg = pcall( func, ... ) if no_error then failure( 'No error generated when calling function but expected error: "'..expectedMsg..'"', 2 ) end if error_msg ~= expectedMsg then error_msg, expectedMsg = prettystrPadded(error_msg, expectedMsg) fail_fmt(2, 'Exact error message expected: %s\nError message received: %s\n', expectedMsg, error_msg) end end function M.assertErrorMsgContains( partialMsg, func, ... ) -- assert that calling f with the arguments will raise an error -- example: assertError( f, 1, 2 ) => f(1,2) should generate an error local no_error, error_msg = pcall( func, ... ) if no_error then failure( 'No error generated when calling function but expected error containing: '..prettystr(partialMsg), 2 ) end if not string.find( error_msg, partialMsg, nil, true ) then error_msg, partialMsg = prettystrPadded(error_msg, partialMsg) fail_fmt(2, 'Error message does not contain: %s\nError message received: %s\n', partialMsg, error_msg) end end function M.assertErrorMsgMatches( expectedMsg, func, ... ) -- assert that calling f with the arguments will raise an error -- example: assertError( f, 1, 2 ) => f(1,2) should generate an error local no_error, error_msg = pcall( func, ... ) if no_error then failure( 'No error generated when calling function but expected error matching: "'..expectedMsg..'"', 2 ) end if not strMatch( error_msg, expectedMsg ) then expectedMsg, error_msg = prettystrPadded(expectedMsg, error_msg) fail_fmt(2, 'Error message does not match: %s\nError message received: %s\n', expectedMsg, error_msg) end end --[[ Add type assertion functions to the module table M. Each of these functions takes a single parameter "value", and checks that its Lua type matches the expected string (derived from the function name): M.assertIsXxx(value) -> ensure that type(value) conforms to "xxx" ]] for _, funcName in ipairs( {'assertIsNumber', 'assertIsString', 'assertIsTable', 'assertIsBoolean', 'assertIsFunction', 'assertIsUserdata', 'assertIsThread'} ) do local typeExpected = funcName:match("^assertIs([A-Z]%a*)$") -- Lua type() always returns lowercase, also make sure the match() succeeded typeExpected = typeExpected and typeExpected:lower() or error("bad function name '"..funcName.."' for type assertion") M[funcName] = function(value) if type(value) ~= typeExpected then fail_fmt(2, 'Expected: a %s value, actual: type %s, value %s', typeExpected, type(value), prettystrPadded(value)) end end end --[[ Add shortcuts for verifying type of a variable, without failure (luaunit v2 compatibility) M.isXxx(value) -> returns true if type(value) conforms to "xxx" ]] for _, typeExpected in ipairs( {'Number', 'String', 'Table', 'Boolean', 'Function', 'Userdata', 'Thread', 'Nil' } ) do local typeExpectedLower = typeExpected:lower() local isType = function(value) return (type(value) == typeExpectedLower) end M['is'..typeExpected] = isType M['is_'..typeExpectedLower] = isType end --[[ Add non-type assertion functions to the module table M. Each of these functions takes a single parameter "value", and checks that its Lua type differs from the expected string (derived from the function name): M.assertNotIsXxx(value) -> ensure that type(value) is not "xxx" ]] for _, funcName in ipairs( {'assertNotIsNumber', 'assertNotIsString', 'assertNotIsTable', 'assertNotIsBoolean', 'assertNotIsFunction', 'assertNotIsUserdata', 'assertNotIsThread'} ) do local typeUnexpected = funcName:match("^assertNotIs([A-Z]%a*)$") -- Lua type() always returns lowercase, also make sure the match() succeeded typeUnexpected = typeUnexpected and typeUnexpected:lower() or error("bad function name '"..funcName.."' for type assertion") M[funcName] = function(value) if type(value) == typeUnexpected then fail_fmt(2, 'Not expected: a %s type, actual: value %s', typeUnexpected, prettystrPadded(value)) end end end function M.assertIs(actual, expected) if actual ~= expected then if not M.ORDER_ACTUAL_EXPECTED then actual, expected = expected, actual end expected, actual = prettystrPadded(expected, actual, '\n', ', ') fail_fmt(2, 'Expected object and actual object are not the same\nExpected: %sactual: %s', expected, actual) end end function M.assertNotIs(actual, expected) if actual == expected then if not M.ORDER_ACTUAL_EXPECTED then expected = actual end fail_fmt(2, 'Expected object and actual object are the same object: %s', prettystrPadded(expected)) end end function M.assertItemsEquals(actual, expected) -- checks that the items of table expected -- are contained in table actual. Warning, this function -- is at least O(n^2) if not _is_table_items_equals(actual, expected ) then expected, actual = prettystrPadded(expected, actual) fail_fmt(2, 'Contents of the tables are not identical:\nExpected: %s\nActual: %s', expected, actual) end end ---------------------------------------------------------------- -- Compatibility layer ---------------------------------------------------------------- -- for compatibility with LuaUnit v2.x function M.wrapFunctions(...) -- In LuaUnit version <= 2.1 , this function was necessary to include -- a test function inside the global test suite. Nowadays, the functions -- are simply run directly as part of the test discovery process. -- so just do nothing ! io.stderr:write[[Use of WrapFunctions() is no longer needed. Just prefix your test function names with "test" or "Test" and they will be picked up and run by LuaUnit. ]] end local list_of_funcs = { -- { official function name , alias } -- general assertions { 'assertEquals' , 'assert_equals' }, { 'assertItemsEquals' , 'assert_items_equals' }, { 'assertNotEquals' , 'assert_not_equals' }, { 'assertAlmostEquals' , 'assert_almost_equals' }, { 'assertNotAlmostEquals' , 'assert_not_almost_equals' }, { 'assertTrue' , 'assert_true' }, { 'assertFalse' , 'assert_false' }, { 'assertStrContains' , 'assert_str_contains' }, { 'assertStrIContains' , 'assert_str_icontains' }, { 'assertNotStrContains' , 'assert_not_str_contains' }, { 'assertNotStrIContains' , 'assert_not_str_icontains' }, { 'assertStrMatches' , 'assert_str_matches' }, { 'assertError' , 'assert_error' }, { 'assertErrorMsgEquals' , 'assert_error_msg_equals' }, { 'assertErrorMsgContains' , 'assert_error_msg_contains' }, { 'assertErrorMsgMatches' , 'assert_error_msg_matches' }, { 'assertIs' , 'assert_is' }, { 'assertNotIs' , 'assert_not_is' }, { 'wrapFunctions' , 'WrapFunctions' }, { 'wrapFunctions' , 'wrap_functions' }, -- type assertions: assertIsXXX -> assert_is_xxx { 'assertIsNumber' , 'assert_is_number' }, { 'assertIsString' , 'assert_is_string' }, { 'assertIsTable' , 'assert_is_table' }, { 'assertIsBoolean' , 'assert_is_boolean' }, { 'assertIsNil' , 'assert_is_nil' }, { 'assertIsFunction' , 'assert_is_function' }, { 'assertIsThread' , 'assert_is_thread' }, { 'assertIsUserdata' , 'assert_is_userdata' }, -- type assertions: assertIsXXX -> assertXxx { 'assertIsNumber' , 'assertNumber' }, { 'assertIsString' , 'assertString' }, { 'assertIsTable' , 'assertTable' }, { 'assertIsBoolean' , 'assertBoolean' }, { 'assertIsNil' , 'assertNil' }, { 'assertIsFunction' , 'assertFunction' }, { 'assertIsThread' , 'assertThread' }, { 'assertIsUserdata' , 'assertUserdata' }, -- type assertions: assertIsXXX -> assert_xxx (luaunit v2 compat) { 'assertIsNumber' , 'assert_number' }, { 'assertIsString' , 'assert_string' }, { 'assertIsTable' , 'assert_table' }, { 'assertIsBoolean' , 'assert_boolean' }, { 'assertIsNil' , 'assert_nil' }, { 'assertIsFunction' , 'assert_function' }, { 'assertIsThread' , 'assert_thread' }, { 'assertIsUserdata' , 'assert_userdata' }, -- type assertions: assertNotIsXXX -> assert_not_is_xxx { 'assertNotIsNumber' , 'assert_not_is_number' }, { 'assertNotIsString' , 'assert_not_is_string' }, { 'assertNotIsTable' , 'assert_not_is_table' }, { 'assertNotIsBoolean' , 'assert_not_is_boolean' }, { 'assertNotIsNil' , 'assert_not_is_nil' }, { 'assertNotIsFunction' , 'assert_not_is_function' }, { 'assertNotIsThread' , 'assert_not_is_thread' }, { 'assertNotIsUserdata' , 'assert_not_is_userdata' }, -- type assertions: assertNotIsXXX -> assertNotXxx (luaunit v2 compat) { 'assertNotIsNumber' , 'assertNotNumber' }, { 'assertNotIsString' , 'assertNotString' }, { 'assertNotIsTable' , 'assertNotTable' }, { 'assertNotIsBoolean' , 'assertNotBoolean' }, { 'assertNotIsNil' , 'assertNotNil' }, { 'assertNotIsFunction' , 'assertNotFunction' }, { 'assertNotIsThread' , 'assertNotThread' }, { 'assertNotIsUserdata' , 'assertNotUserdata' }, -- type assertions: assertNotIsXXX -> assert_not_xxx { 'assertNotIsNumber' , 'assert_not_number' }, { 'assertNotIsString' , 'assert_not_string' }, { 'assertNotIsTable' , 'assert_not_table' }, { 'assertNotIsBoolean' , 'assert_not_boolean' }, { 'assertNotIsNil' , 'assert_not_nil' }, { 'assertNotIsFunction' , 'assert_not_function' }, { 'assertNotIsThread' , 'assert_not_thread' }, { 'assertNotIsUserdata' , 'assert_not_userdata' }, -- all assertions with Coroutine duplicate Thread assertions { 'assertIsThread' , 'assertIsCoroutine' }, { 'assertIsThread' , 'assertCoroutine' }, { 'assertIsThread' , 'assert_is_coroutine' }, { 'assertIsThread' , 'assert_coroutine' }, { 'assertNotIsThread' , 'assertNotIsCoroutine' }, { 'assertNotIsThread' , 'assertNotCoroutine' }, { 'assertNotIsThread' , 'assert_not_is_coroutine' }, { 'assertNotIsThread' , 'assert_not_coroutine' }, } -- Create all aliases in M for _,v in ipairs( list_of_funcs ) do local funcname, alias = v[1], v[2] M[alias] = M[funcname] if EXPORT_ASSERT_TO_GLOBALS then _G[funcname] = M[funcname] _G[alias] = M[funcname] end end ---------------------------------------------------------------- -- -- Outputters -- ---------------------------------------------------------------- -- A common "base" class for outputters -- For concepts involved (class inheritance) see http://www.lua.org/pil/16.2.html local genericOutput = { __class__ = 'genericOutput' } -- class local genericOutput_MT = { __index = genericOutput } -- metatable M.genericOutput = genericOutput -- publish, so that custom classes may derive from it function genericOutput.new(runner, default_verbosity) -- runner is the "parent" object controlling the output, usually a LuaUnit instance local t = { runner = runner } if runner then t.result = runner.result t.verbosity = runner.verbosity or default_verbosity t.fname = runner.fname else t.verbosity = default_verbosity end return setmetatable( t, genericOutput_MT) end -- abstract ("empty") methods function genericOutput:startSuite() end function genericOutput:startClass(className) end function genericOutput:startTest(testName) end function genericOutput:addStatus(node) end function genericOutput:endTest(node) end function genericOutput:endClass() end function genericOutput:endSuite() end ---------------------------------------------------------------- -- class TapOutput ---------------------------------------------------------------- local TapOutput = genericOutput.new() -- derived class local TapOutput_MT = { __index = TapOutput } -- metatable TapOutput.__class__ = 'TapOutput' -- For a good reference for TAP format, check: http://testanything.org/tap-specification.html function TapOutput.new(runner) local t = genericOutput.new(runner, M.VERBOSITY_LOW) return setmetatable( t, TapOutput_MT) end function TapOutput:startSuite() print("1.."..self.result.testCount) print('# Started on '..self.result.startDate) end function TapOutput:startClass(className) if className ~= '[TestFunctions]' then print('# Starting class: '..className) end end function TapOutput:addStatus( node ) io.stdout:write("not ok ", self.result.currentTestNumber, "\t", node.testName, "\n") if self.verbosity > M.VERBOSITY_LOW then print( prefixString( ' ', node.msg ) ) end if self.verbosity > M.VERBOSITY_DEFAULT then print( prefixString( ' ', node.stackTrace ) ) end end function TapOutput:endTest( node ) if node:isPassed() then io.stdout:write("ok ", self.result.currentTestNumber, "\t", node.testName, "\n") end end function TapOutput:endSuite() print( '# '..M.LuaUnit.statusLine( self.result ) ) return self.result.notPassedCount end -- class TapOutput end ---------------------------------------------------------------- -- class JUnitOutput ---------------------------------------------------------------- -- See directory junitxml for more information about the junit format local JUnitOutput = genericOutput.new() -- derived class local JUnitOutput_MT = { __index = JUnitOutput } -- metatable JUnitOutput.__class__ = 'JUnitOutput' function JUnitOutput.new(runner) local t = genericOutput.new(runner, M.VERBOSITY_LOW) t.testList = {} return setmetatable( t, JUnitOutput_MT ) end function JUnitOutput:startSuite() -- open xml file early to deal with errors if self.fname == nil then error('With Junit, an output filename must be supplied with --name!') end if string.sub(self.fname,-4) ~= '.xml' then self.fname = self.fname..'.xml' end self.fd = io.open(self.fname, "w") if self.fd == nil then error("Could not open file for writing: "..self.fname) end print('# XML output to '..self.fname) print('# Started on '..self.result.startDate) end function JUnitOutput:startClass(className) if className ~= '[TestFunctions]' then print('# Starting class: '..className) end end function JUnitOutput:startTest(testName) print('# Starting test: '..testName) end function JUnitOutput:addStatus( node ) if node:isFailure() then print('# Failure: ' .. node.msg) -- print('# ' .. node.stackTrace) elseif node:isError() then print('# Error: ' .. node.msg) -- print('# ' .. node.stackTrace) end end function JUnitOutput:endSuite() print( '# '..M.LuaUnit.statusLine(self.result)) -- XML file writing self.fd:write('\n') self.fd:write('\n') self.fd:write(string.format( ' \n', self.result.runCount, self.result.startIsodate, self.result.duration, self.result.errorCount, self.result.failureCount )) self.fd:write(" \n") self.fd:write(string.format(' \n', _VERSION ) ) self.fd:write(string.format(' \n', M.VERSION) ) -- XXX please include system name and version if possible self.fd:write(" \n") for i,node in ipairs(self.result.tests) do self.fd:write(string.format(' \n', node.className, node.testName, node.duration ) ) if node:isNotPassed() then self.fd:write(node:statusXML()) end self.fd:write(' \n') end -- Next two lines are needed to validate junit ANT xsd, but really not useful in general: self.fd:write(' \n') self.fd:write(' \n') self.fd:write(' \n') self.fd:write('\n') self.fd:close() return self.result.notPassedCount end -- class TapOutput end ---------------------------------------------------------------- -- class TextOutput ---------------------------------------------------------------- --[[ -- Python Non verbose: For each test: . or F or E If some failed tests: ============== ERROR / FAILURE: TestName (testfile.testclass) --------- Stack trace then -------------- then "Ran x tests in 0.000s" then OK or FAILED (failures=1, error=1) -- Python Verbose: testname (filename.classname) ... ok testname (filename.classname) ... FAIL testname (filename.classname) ... ERROR then -------------- then "Ran x tests in 0.000s" then OK or FAILED (failures=1, error=1) -- Ruby: Started . Finished in 0.002695 seconds. 1 tests, 2 assertions, 0 failures, 0 errors -- Ruby: >> ruby tc_simple_number2.rb Loaded suite tc_simple_number2 Started F.. Finished in 0.038617 seconds. 1) Failure: test_failure(TestSimpleNumber) [tc_simple_number2.rb:16]: Adding doesn't work. <3> expected but was <4>. 3 tests, 4 assertions, 1 failures, 0 errors -- Java Junit .......F. Time: 0,003 There was 1 failure: 1) testCapacity(junit.samples.VectorTest)junit.framework.AssertionFailedError at junit.samples.VectorTest.testCapacity(VectorTest.java:87) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) FAILURES!!! Tests run: 8, Failures: 1, Errors: 0 -- Maven # mvn test ------------------------------------------------------- T E S T S ------------------------------------------------------- Running math.AdditionTest Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.03 sec <<< FAILURE! Results : Failed tests: testLireSymbole(math.AdditionTest) Tests run: 2, Failures: 1, Errors: 0, Skipped: 0 -- LuaUnit ---- non verbose * display . or F or E when running tests ---- verbose * display test name + ok/fail ---- * blank line * number) ERROR or FAILURE: TestName Stack trace * blank line * number) ERROR or FAILURE: TestName Stack trace then -------------- then "Ran x tests in 0.000s (%d not selected, %d skipped)" then OK or FAILED (failures=1, error=1) ]] local TextOutput = genericOutput.new() -- derived class local TextOutput_MT = { __index = TextOutput } -- metatable TextOutput.__class__ = 'TextOutput' function TextOutput.new(runner) local t = genericOutput.new(runner, M.VERBOSITY_DEFAULT) t.errorList = {} return setmetatable( t, TextOutput_MT ) end function TextOutput:startSuite() if self.verbosity > M.VERBOSITY_DEFAULT then print( 'Started on '.. self.result.startDate ) end end function TextOutput:startTest(testName) if self.verbosity > M.VERBOSITY_DEFAULT then io.stdout:write( " ", self.result.currentNode.testName, " ... " ) end end function TextOutput:endTest( node ) if node:isPassed() then if self.verbosity > M.VERBOSITY_DEFAULT then io.stdout:write("Ok\n") else io.stdout:write(".") end else if self.verbosity > M.VERBOSITY_DEFAULT then print( node.status ) print( node.msg ) --[[ -- find out when to do this: if self.verbosity > M.VERBOSITY_DEFAULT then print( node.stackTrace ) end ]] else -- write only the first character of status io.stdout:write(string.sub(node.status, 1, 1)) end end end function TextOutput:displayOneFailedTest( index, failure ) print(index..") "..failure.testName ) print( failure.msg ) print( failure.stackTrace ) print() end function TextOutput:displayFailedTests() if self.result.notPassedCount == 0 then return end print("Failed tests:") print("-------------") for i,v in ipairs(self.result.notPassed) do self:displayOneFailedTest( i, v ) end end function TextOutput:endSuite() if self.verbosity > M.VERBOSITY_DEFAULT then print("=========================================================") else print() end self:displayFailedTests() print( M.LuaUnit.statusLine( self.result ) ) local ignoredString = "" if self.result.notPassedCount == 0 then print('OK') end end -- class TextOutput end ---------------------------------------------------------------- -- class NilOutput ---------------------------------------------------------------- local function nopCallable() --print(42) return nopCallable end local NilOutput = { __class__ = 'NilOuptut' } -- class local NilOutput_MT = { __index = nopCallable } -- metatable function NilOutput.new(runner) return setmetatable( { __class__ = 'NilOutput' }, NilOutput_MT ) end ---------------------------------------------------------------- -- -- class LuaUnit -- ---------------------------------------------------------------- M.LuaUnit = { outputType = TextOutput, verbosity = M.VERBOSITY_DEFAULT, __class__ = 'LuaUnit' } local LuaUnit_MT = { __index = M.LuaUnit } if EXPORT_ASSERT_TO_GLOBALS then LuaUnit = M.LuaUnit end function M.LuaUnit.new() return setmetatable( {}, LuaUnit_MT ) end -----------------[[ Utility methods ]]--------------------- function M.LuaUnit.asFunction(aObject) -- return "aObject" if it is a function, and nil otherwise if 'function' == type(aObject) then return aObject end end function M.LuaUnit.isClassMethod(aName) -- return true if aName contains a class + a method name in the form class:method return string.find(aName, '.', nil, true) ~= nil end function M.LuaUnit.splitClassMethod(someName) -- return a pair className, methodName for a name in the form class:method -- return nil if not a class + method name -- name is class + method local hasMethod, methodName, className hasMethod = string.find(someName, '.', nil, true ) if not hasMethod then return nil end methodName = string.sub(someName, hasMethod+1) className = string.sub(someName,1,hasMethod-1) return className, methodName end function M.LuaUnit.isMethodTestName( s ) -- return true is the name matches the name of a test method -- default rule is that is starts with 'Test' or with 'test' return string.sub(s, 1, 4):lower() == 'test' end function M.LuaUnit.isTestName( s ) -- return true is the name matches the name of a test -- default rule is that is starts with 'Test' or with 'test' return string.sub(s, 1, 4):lower() == 'test' end function M.LuaUnit.collectTests() -- return a list of all test names in the global namespace -- that match LuaUnit.isTestName local testNames = {} for k, v in pairs(_G) do if M.LuaUnit.isTestName( k ) then table.insert( testNames , k ) end end table.sort( testNames ) return testNames end function M.LuaUnit.parseCmdLine( cmdLine ) -- parse the command line -- Supported command line parameters: -- --verbose, -v: increase verbosity -- --quiet, -q: silence output -- --error, -e: treat errors as fatal (quit program) -- --output, -o, + name: select output type -- --pattern, -p, + pattern: run test matching pattern, may be repeated -- --name, -n, + fname: name of output file for junit, default to stdout -- [testnames, ...]: run selected test names -- -- Returns a table with the following fields: -- verbosity: nil, M.VERBOSITY_DEFAULT, M.VERBOSITY_QUIET, M.VERBOSITY_VERBOSE -- output: nil, 'tap', 'junit', 'text', 'nil' -- testNames: nil or a list of test names to run -- pattern: nil or a list of patterns local result = {} local state = nil local SET_OUTPUT = 1 local SET_PATTERN = 2 local SET_FNAME = 3 if cmdLine == nil then return result end local function parseOption( option ) if option == '--help' or option == '-h' then result['help'] = true return elseif option == '--version' then result['version'] = true return elseif option == '--verbose' or option == '-v' then result['verbosity'] = M.VERBOSITY_VERBOSE return elseif option == '--quiet' or option == '-q' then result['verbosity'] = M.VERBOSITY_QUIET return elseif option == '--error' or option == '-e' then result['quitOnError'] = true return elseif option == '--failure' or option == '-f' then result['quitOnFailure'] = true return elseif option == '--output' or option == '-o' then state = SET_OUTPUT return state elseif option == '--name' or option == '-n' then state = SET_FNAME return state elseif option == '--pattern' or option == '-p' then state = SET_PATTERN return state end error('Unknown option: '..option,3) end local function setArg( cmdArg, state ) if state == SET_OUTPUT then result['output'] = cmdArg return elseif state == SET_FNAME then result['fname'] = cmdArg return elseif state == SET_PATTERN then if result['pattern'] then table.insert( result['pattern'], cmdArg ) else result['pattern'] = { cmdArg } end return end error('Unknown parse state: '.. state) end for i, cmdArg in ipairs(cmdLine) do if state ~= nil then setArg( cmdArg, state, result ) state = nil else if cmdArg:sub(1,1) == '-' then state = parseOption( cmdArg ) else if result['testNames'] then table.insert( result['testNames'], cmdArg ) else result['testNames'] = { cmdArg } end end end end if result['help'] then M.LuaUnit.help() end if result['version'] then M.LuaUnit.version() end if state ~= nil then error('Missing argument after '..cmdLine[ #cmdLine ],2 ) end return result end function M.LuaUnit.help() print(M.USAGE) os.exit(0) end function M.LuaUnit.version() print('LuaUnit v'..M.VERSION..' by Philippe Fremy ') os.exit(0) end function M.LuaUnit.patternInclude( patternFilter, expr ) -- check if any of patternFilter is contained in expr. If so, return true. -- return false if None of the patterns are contained in expr -- if patternFilter is nil, return true (no filtering) if patternFilter == nil then return true end for i,pattern in ipairs(patternFilter) do if string.find(expr, pattern) then return true end end return false end ---------------------------------------------------------------- -- class NodeStatus ---------------------------------------------------------------- local NodeStatus = { __class__ = 'NodeStatus' } -- class local NodeStatus_MT = { __index = NodeStatus } -- metatable M.NodeStatus = NodeStatus -- values of status NodeStatus.PASS = 'PASS' NodeStatus.FAIL = 'FAIL' NodeStatus.ERROR = 'ERROR' function NodeStatus.new( number, testName, className ) local t = { number = number, testName = testName, className = className } setmetatable( t, NodeStatus_MT ) t:pass() return t end function NodeStatus:pass() self.status = self.PASS -- useless but we know it's the field we want to use self.msg = nil self.stackTrace = nil end function NodeStatus:fail(msg, stackTrace) self.status = self.FAIL self.msg = msg self.stackTrace = stackTrace end function NodeStatus:error(msg, stackTrace) self.status = self.ERROR self.msg = msg self.stackTrace = stackTrace end function NodeStatus:isPassed() return self.status == NodeStatus.PASS end function NodeStatus:isNotPassed() -- print('hasFailure: '..prettystr(self)) return self.status ~= NodeStatus.PASS end function NodeStatus:isFailure() return self.status == NodeStatus.FAIL end function NodeStatus:isError() return self.status == NodeStatus.ERROR end function NodeStatus:statusXML() if self:isError() then return table.concat( {' \n', ' \n'}) elseif self:isFailure() then return table.concat( {' \n', ' \n'}) end return ' \n' -- (not XSD-compliant! normally shouldn't get here) end --------------[[ Output methods ]]------------------------- local function conditional_plural(number, singular) -- returns a grammatically well-formed string "%d " local suffix = '' if number ~= 1 then -- use plural suffix = (singular:sub(-2) == 'ss') and 'es' or 's' end return string.format('%d %s%s', number, singular, suffix) end function M.LuaUnit.statusLine(result) -- return status line string according to results local s = { string.format('Ran %d tests in %0.3f seconds', result.runCount, result.duration), conditional_plural(result.passedCount, 'success'), } if result.notPassedCount > 0 then if result.failureCount > 0 then table.insert(s, conditional_plural(result.failureCount, 'failure')) end if result.errorCount > 0 then table.insert(s, conditional_plural(result.errorCount, 'error')) end else table.insert(s, '0 failures') end if result.nonSelectedCount > 0 then table.insert(s, string.format("%d non-selected", result.nonSelectedCount)) end return table.concat(s, ', ') end function M.LuaUnit:startSuite(testCount, nonSelectedCount) self.result = { testCount = testCount, nonSelectedCount = nonSelectedCount, passedCount = 0, runCount = 0, currentTestNumber = 0, currentClassName = "", currentNode = nil, suiteStarted = true, startTime = os.clock(), startDate = os.date(os.getenv('LUAUNIT_DATEFMT')), startIsodate = os.date('%Y-%m-%dT%H:%M:%S'), patternFilter = self.patternFilter, tests = {}, failures = {}, errors = {}, notPassed = {}, } self.outputType = self.outputType or TextOutput self.output = self.outputType.new(self) self.output:startSuite() end function M.LuaUnit:startClass( className ) self.result.currentClassName = className self.output:startClass( className ) end function M.LuaUnit:startTest( testName ) self.result.currentTestNumber = self.result.currentTestNumber + 1 self.result.runCount = self.result.runCount + 1 self.result.currentNode = NodeStatus.new( self.result.currentTestNumber, testName, self.result.currentClassName ) self.result.currentNode.startTime = os.clock() table.insert( self.result.tests, self.result.currentNode ) self.output:startTest( testName ) end function M.LuaUnit:addStatus( err ) -- "err" is expected to be a table / result from protectedCall() if err.status == NodeStatus.PASS then return end local node = self.result.currentNode --[[ As a first approach, we will report only one error or one failure for one test. However, we can have the case where the test is in failure, and the teardown is in error. In such case, it's a good idea to report both a failure and an error in the test suite. This is what Python unittest does for example. However, it mixes up counts so need to be handled carefully: for example, there could be more (failures + errors) count that tests. What happens to the current node ? We will do this more intelligent version later. ]] -- if the node is already in failure/error, just don't report the new error (see above) if node.status ~= NodeStatus.PASS then return end if err.status == NodeStatus.FAIL then node:fail( err.msg, err.trace ) table.insert( self.result.failures, node ) elseif err.status == NodeStatus.ERROR then node:error( err.msg, err.trace ) table.insert( self.result.errors, node ) end if node:isFailure() or node:isError() then -- add to the list of failed tests (gets printed separately) table.insert( self.result.notPassed, node ) end self.output:addStatus( node ) end function M.LuaUnit:endTest() local node = self.result.currentNode -- print( 'endTest() '..prettystr(node)) -- print( 'endTest() '..prettystr(node:isNotPassed())) node.duration = os.clock() - node.startTime node.startTime = nil self.output:endTest( node ) if node:isPassed() then self.result.passedCount = self.result.passedCount + 1 elseif node:isError() then if self.quitOnError or self.quitOnFailure then -- Runtime error - abort test execution as requested by -- "--error" option. This is done by setting a special -- flag that gets handled in runSuiteByInstances(). print("\nERROR during LuaUnit test execution:\n" .. node.msg) self.result.aborted = true end elseif node:isFailure() then if self.quitOnFailure then -- Failure - abort test execution as requested by -- "--failure" option. This is done by setting a special -- flag that gets handled in runSuiteByInstances(). print("\nFailure during LuaUnit test execution:\n" .. node.msg) self.result.aborted = true end end self.result.currentNode = nil end function M.LuaUnit:endClass() self.output:endClass() end function M.LuaUnit:endSuite() if self.result.suiteStarted == false then error('LuaUnit:endSuite() -- suite was already ended' ) end self.result.duration = os.clock()-self.result.startTime self.result.suiteStarted = false -- Expose test counts for outputter's endSuite(). This could be managed -- internally instead, but unit tests (and existing use cases) might -- rely on these fields being present. self.result.notPassedCount = #self.result.notPassed self.result.failureCount = #self.result.failures self.result.errorCount = #self.result.errors self.output:endSuite() end function M.LuaUnit:setOutputType(outputType) -- default to text -- tap produces results according to TAP format if outputType:upper() == "NIL" then self.outputType = NilOutput return end if outputType:upper() == "TAP" then self.outputType = TapOutput return end if outputType:upper() == "JUNIT" then self.outputType = JUnitOutput return end if outputType:upper() == "TEXT" then self.outputType = TextOutput return end error( 'No such format: '..outputType,2) end --------------[[ Runner ]]----------------- function M.LuaUnit:protectedCall(classInstance, methodInstance, prettyFuncName) -- if classInstance is nil, this is just a function call -- else, it's method of a class being called. local function err_handler(e) -- transform error into a table, adding the traceback information return { status = NodeStatus.ERROR, msg = e, trace = string.sub(debug.traceback("", 3), 2) } end local ok, err if classInstance then -- stupid Lua < 5.2 does not allow xpcall with arguments so let's use a workaround ok, err = xpcall( function () methodInstance(classInstance) end, err_handler ) else ok, err = xpcall( function () methodInstance() end, err_handler ) end if ok then return {status = NodeStatus.PASS} end -- determine if the error was a failed test: -- We do this by stripping the failure prefix from the error message, -- while keeping track of the gsub() count. A non-zero value -> failure local failed err.msg, failed = err.msg:gsub(M.FAILURE_PREFIX, "", 1) if failed > 0 then err.status = NodeStatus.FAIL end -- reformat / improve the stack trace if prettyFuncName then -- we do have the real method name err.trace = err.trace:gsub("in (%a+) 'methodInstance'", "in %1 '"..prettyFuncName.."'") end if STRIP_LUAUNIT_FROM_STACKTRACE then err.trace = stripLuaunitTrace(err.trace) end return err -- return the error "object" (table) end function M.LuaUnit:execOneFunction(className, methodName, classInstance, methodInstance) -- When executing a test function, className and classInstance must be nil -- When executing a class method, all parameters must be set if type(methodInstance) ~= 'function' then error( tostring(methodName)..' must be a function, not '..type(methodInstance)) end local prettyFuncName if className == nil then className = '[TestFunctions]' prettyFuncName = methodName else prettyFuncName = className..'.'..methodName end if self.lastClassName ~= className then if self.lastClassName ~= nil then self:endClass() end self:startClass( className ) self.lastClassName = className end self:startTest(prettyFuncName) -- run setUp first (if any) if classInstance then local func = self.asFunction( classInstance.setUp ) or self.asFunction( classInstance.Setup ) or self.asFunction( classInstance.setup ) or self.asFunction( classInstance.SetUp ) if func then self:addStatus(self:protectedCall(classInstance, func, className..'.setUp')) end end -- run testMethod() if self.result.currentNode:isPassed() then self:addStatus(self:protectedCall(classInstance, methodInstance, prettyFuncName)) end -- lastly, run tearDown (if any) if classInstance then local func = self.asFunction( classInstance.tearDown ) or self.asFunction( classInstance.TearDown ) or self.asFunction( classInstance.teardown ) or self.asFunction( classInstance.Teardown ) if func then self:addStatus(self:protectedCall(classInstance, func, className..'.tearDown')) end end self:endTest() end function M.LuaUnit.expandOneClass( result, className, classInstance ) -- add all test methods of classInstance to result for methodName, methodInstance in sortedPairs(classInstance) do if M.LuaUnit.asFunction(methodInstance) and M.LuaUnit.isMethodTestName( methodName ) then table.insert( result, { className..'.'..methodName, classInstance } ) end end end function M.LuaUnit.expandClasses( listOfNameAndInst ) -- expand all classes (provided as {className, classInstance}) to a list of {className.methodName, classInstance} -- functions and methods remain untouched local result = {} for i,v in ipairs( listOfNameAndInst ) do local name, instance = v[1], v[2] if M.LuaUnit.asFunction(instance) then table.insert( result, { name, instance } ) else if type(instance) ~= 'table' then error( 'Instance must be a table or a function, not a '..type(instance)..', value '..prettystr(instance)) end if M.LuaUnit.isClassMethod( name ) then local className, methodName = M.LuaUnit.splitClassMethod( name ) local methodInstance = instance[methodName] if methodInstance == nil then error( "Could not find method in class "..tostring(className).." for method "..tostring(methodName) ) end table.insert( result, { name, instance } ) else M.LuaUnit.expandOneClass( result, name, instance ) end end end return result end function M.LuaUnit.applyPatternFilter( patternFilter, listOfNameAndInst ) local included, excluded = {}, {} for i, v in ipairs( listOfNameAndInst ) do -- local name, instance = v[1], v[2] if M.LuaUnit.patternInclude( patternFilter, v[1] ) then table.insert( included, v ) else table.insert( excluded, v ) end end return included, excluded end function M.LuaUnit:runSuiteByInstances( listOfNameAndInst ) -- Run an explicit list of tests. All test instances and names must be supplied. -- each test must be one of: -- * { function name, function instance } -- * { class name, class instance } -- * { class.method name, class instance } local expandedList = self.expandClasses( listOfNameAndInst ) local filteredList, filteredOutList = self.applyPatternFilter( self.patternFilter, expandedList ) self:startSuite( #filteredList, #filteredOutList ) for i,v in ipairs( filteredList ) do local name, instance = v[1], v[2] if M.LuaUnit.asFunction(instance) then self:execOneFunction( nil, name, nil, instance ) else if type(instance) ~= 'table' then error( 'Instance must be a table or a function, not a '..type(instance)..', value '..prettystr(instance)) else assert( M.LuaUnit.isClassMethod( name ) ) local className, methodName = M.LuaUnit.splitClassMethod( name ) local methodInstance = instance[methodName] if methodInstance == nil then error( "Could not find method in class "..tostring(className).." for method "..tostring(methodName) ) end self:execOneFunction( className, methodName, instance, methodInstance ) end end if self.result.aborted then break end -- "--error" or "--failure" option triggered end if self.lastClassName ~= nil then self:endClass() end self:endSuite() if self.result.aborted then print("LuaUnit ABORTED (as requested by --error or --failure option)") os.exit(-2) end end function M.LuaUnit:runSuiteByNames( listOfName ) -- Run an explicit list of test names local instanceName, instance local listOfNameAndInst = {} for i,name in ipairs( listOfName ) do if M.LuaUnit.isClassMethod( name ) then local className, methodName = M.LuaUnit.splitClassMethod( name ) instanceName = className instance = _G[instanceName] if instance == nil then error( "No such name in global space: "..instanceName ) end if type(instance) ~= 'table' then error( 'Instance of '..instanceName..' must be a table, not '..type(instance)) end local methodInstance = instance[methodName] if methodInstance == nil then error( "Could not find method in class "..tostring(className).." for method "..tostring(methodName) ) end else -- for functions and classes instanceName = name instance = _G[instanceName] end if instance == nil then error( "No such name in global space: "..instanceName ) end if (type(instance) ~= 'table' and type(instance) ~= 'function') then error( 'Name must match a function or a table: '..instanceName ) end table.insert( listOfNameAndInst, { name, instance } ) end self:runSuiteByInstances( listOfNameAndInst ) end function M.LuaUnit.run(...) -- Run some specific test classes. -- If no arguments are passed, run the class names specified on the -- command line. If no class name is specified on the command line -- run all classes whose name starts with 'Test' -- -- If arguments are passed, they must be strings of the class names -- that you want to run or generic command line arguments (-o, -p, -v, ...) local runner = M.LuaUnit.new() return runner:runSuite(...) end function M.LuaUnit:runSuite( ... ) local args = {...} if type(args[1]) == 'table' and args[1].__class__ == 'LuaUnit' then -- run was called with the syntax M.LuaUnit:runSuite() -- we support both M.LuaUnit.run() and M.LuaUnit:run() -- strip out the first argument table.remove(args,1) end if #args == 0 then args = cmdline_argv end local no_error, val = pcall( M.LuaUnit.parseCmdLine, args ) if not no_error then print(val) -- error message print() print(M.USAGE) os.exit(-1) end local options = val -- We expect these option fields to be either `nil` or contain -- valid values, so it's safe to always copy them directly. self.verbosity = options.verbosity self.quitOnError = options.quitOnError self.quitOnFailure = options.quitOnFailure self.fname = options.fname self.patternFilter = options.pattern if options.output and options.output:lower() == 'junit' and options.fname == nil then print('With junit output, a filename must be supplied with -n or --name') os.exit(-1) end if options.output then no_error, val = pcall(self.setOutputType, self, options.output) if not no_error then print(val) -- error message print() print(M.USAGE) os.exit(-1) end end self:runSuiteByNames( options.testNames or M.LuaUnit.collectTests() ) return self.result.notPassedCount end -- class LuaUnit -- For compatbility with LuaUnit v2 M.run = M.LuaUnit.run M.Run = M.LuaUnit.run function M:setVerbosity( verbosity ) M.LuaUnit.verbosity = verbosity end M.set_verbosity = M.setVerbosity M.SetVerbosity = M.setVerbosity return M tmpscZSVg/doit.py0000644000175000017500000000674312777131552013345 0ustar vsevavsevaimport subprocess, sys, os, shutil, os.path, optparse VERSION='3.2' RELEASE_NAME='luaunit-%s' % VERSION RELEASE_DIR='release/' + RELEASE_NAME + '/' TARGET_ZIP=RELEASE_NAME + '.zip' TARGET_TGZ=RELEASE_NAME + '.tgz' REPO_PATH='d:/work/luaunit/luaunit-git/luaunit2/' # LUA50='d:/program/dev/lua/lua50/lua50.exe' LUA51='d:/program/dev/lua/lua51/lua51.exe' LUA52='d:/program/dev/lua/lua52/lua52.exe' LUA53='d:/program/dev/lua/lua53/lua53.exe' ALL_LUA = ( (LUA53, 'lua 5.3'), (LUA52, 'lua 5.2'), (LUA51, 'lua 5.1'), # (LUA50, 'lua 5.0'), ) os.environ["nodosfilewarning"] = "1" def report( s ): print '[[[[[[[[[[[[[ %s ]]]]]]]]]]]]]' % s def run_tests(): '''Run tests with all versions of lua''' for lua, luaversion in ALL_LUA: report( 'Running unit-tests tests with %s' % luaversion ) retcode = subprocess.call( [lua, 'run_unit_tests.lua'] ) if retcode != 0: report( 'Invalid retcode when running tests: %d' % retcode ) sys.exit( retcode ) report( 'Running functional tests tests with %s' % luaversion ) retcode = subprocess.call( [lua, 'run_functional_tests.lua'] ) if retcode != 0: report( 'Invalid retcode when running tests: %d' % retcode ) sys.exit( retcode ) report( 'All tests succeed!' ) def run_example(): for lua, luaversion in ALL_LUA: report( 'Running examples with %s' % luaversion ) retcode = subprocess.call( [lua, 'example_with_luaunit.lua'] ) if retcode != 12: report( 'Invalid retcode when running examples: %d' % retcode ) sys.exit( retcode ) report( 'All examples ran!' ) def packageit(): shutil.rmtree('release', True) try: os.mkdir('release') except OSError: pass subprocess.check_call(['d:/program/utils/Git/bin/git.exe', 'clone', '--no-hardlinks', REPO_PATH, RELEASE_DIR]) os.chdir( RELEASE_DIR ) # Release dir cleanup shutil.rmtree('.git') os.unlink('.gitignore') run_tests() run_example() makedoc() shutil.rmtree('doc/_build') # Packaging os.chdir('..') report('Start packaging') shutil.make_archive(RELEASE_NAME, 'zip', root_dir='.', base_dir=RELEASE_NAME ) shutil.make_archive(RELEASE_NAME, 'gztar', root_dir='.', base_dir=RELEASE_NAME ) report('Zip and tgz ready!') def help(): print( 'Available actions:') for opt in OptToFunc: print '\t%s' % opt def makedoc(): os.chdir('doc') if os.path.exists('html'): shutil.rmtree('html') subprocess.check_call(['make.bat', 'html']) shutil.copytree('_build/html', 'html') os.chdir('..') def install(): installpath = '/usr/local/share/lua/' for lua, luaversion in ALL_LUA: lua,ver = luaversion.split( ) if os.path.exists(installpath+ver): shutil.copy('luaunit.lua',installpath+ver) OptToFunc = { 'runtests' : run_tests, 'runexample' : run_example, 'packageit' : packageit, 'makedoc' : makedoc, 'install' : install, 'help' : help, } if __name__ == '__main__': doingNothing = True for arg in sys.argv[1:]: if OptToFunc.has_key(arg): doingNothing = False OptToFunc[arg]() else: print 'No such action :', arg sys.exit(-1) if doingNothing: help() tmpscZSVg/luaunit-3.2.1-1.rockspec0000644000175000017500000000310612777131552016033 0ustar vsevavsevapackage = "LuaUnit" version = "3.2.1-1" source = { url = "git://github.com/bluebird75/luaunit", tag = "LUAUNIT_V3_2_1" } description = { summary = "A unit testing framework for Lua", detailed = [[ Luaunit is a unit-testing framework for Lua. It allows you to write test functions and test classes with test methods, combined with setup/teardown functionality. A wide range of assertions are supported. Luaunit supports several output format, like Junit or TAP, for easier integration into Continuous Integration platforms (Jenkins, Maven, ...) . The integrated command-line options provide a flexible interface to select tests by name or patterns, control output format, set verbosity, ... LuaUnit works with Lua 5.1, LuaJIT 2.0, LuaJIT 2.1 beta, Lua 5.2 and Lua 5.3 . It is tested on Windows Seven, Windows Server 2012 R2 (x64) and Ubuntu 14.04 (see continuous build results on Travis-CI and AppVeyor) and should work on all platforms supported by Lua. It has no other dependency than Lua itself. **Important note when upgrading to version 3.1 and above** : break of backward compatibility, assertions functions are no longer exported directly to the global namespace. See [documentation](http://luaunit.readthedocs.io/en/latest/#luaunit-global-asserts) on how to adjust or restore previous behavior. ]], homepage = "http://github.com/bluebird75/luaunit", license = "BSD" } dependencies = { "lua >= 5.1" } build = { type = "builtin", modules = { luaunit = "luaunit.lua" }, -- copy_directories = { "doc/html" } }