2011-04-20 23:11:42 +00:00
|
|
|
local inspect = require 'inspect'
|
|
|
|
|
|
|
|
context( 'inspect', function()
|
|
|
|
|
2011-04-23 18:17:43 +00:00
|
|
|
test('Should work with numbers', function()
|
|
|
|
assert_equal(inspect(1), "1")
|
|
|
|
assert_equal(inspect(1.5), "1.5")
|
|
|
|
assert_equal(inspect(-3.14), "-3.14")
|
|
|
|
end)
|
|
|
|
|
2011-04-23 19:00:41 +00:00
|
|
|
test('Should work with strings', function()
|
|
|
|
assert_equal(inspect("hello"), '"hello"')
|
|
|
|
assert_equal(inspect('I have "quotes"'), "'I have \"quotes\"'")
|
|
|
|
assert_equal(inspect("I have \"quotes\" and 'apostrophes'"), '"I have \\"quotes\\" and \'apostrophes\'"')
|
|
|
|
assert_equal(inspect('I have \n new \n lines'), '"I have \\\\n new \\\\n lines"')
|
|
|
|
end)
|
|
|
|
|
2011-04-23 18:07:57 +00:00
|
|
|
test('Should work with simple array-like tables', function()
|
|
|
|
assert_equal(inspect({1,2,3}), "{1, 2, 3}" )
|
2011-04-23 17:48:43 +00:00
|
|
|
end)
|
2011-04-20 23:11:42 +00:00
|
|
|
|
2011-04-23 18:17:43 +00:00
|
|
|
test('Should work with nested arrays', function()
|
|
|
|
assert_equal(inspect({1,2,3, {4,5}, 6}), "{1, 2, 3, {4, 5}, 6}" )
|
|
|
|
end)
|
|
|
|
|
2011-04-20 23:11:42 +00:00
|
|
|
end)
|