[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/sam-github/lunit/master/lua/lunitx/example.lua [Back]  [Original]

lunit = require "lunitx"


if _VERSION >= 'Lua 5.2' then
    _ENV = lunit.module('simple','seeall')
else
    module( "simple", package.seeall, lunit.testcase )
end

function test_success()
  assert_true( true, "This test never fails.")
end

function test_failure()
  assert_true( "Hello World!", "This test always fails!")
end


if _VERSION >= 'Lua 5.2' then
    _ENV = lunit.module('enhanced','seeall')
else
    module( "enhanced", package.seeall, lunit.testcase )
end

local foobar = nil

function setup()
  foobar = "Hello World"
end

function teardown()
  foobar = nil
end

function test1()
  assert_equal("Hello World", foobar)
  foobar = string.sub(foobar, 1, 5)
  assert_equal("Hello", foobar)
end

function test2()
  assert_equal("Hello World", foobar)
  foobar = string.sub(foobar, -5)
  assert_equal("World", foobar)
end

Web Proxy Viewer  |  New URL  |  Original Page