diff --git a/.luacov b/.luacov index 1b4c80e..5c65a43 100644 --- a/.luacov +++ b/.luacov @@ -9,7 +9,7 @@ return { ['configfile'] = '.luacov', -- filename to store stats collected - ['statsfile'] = 'test/luacov.stats.out', + ['statsfile'] = 'luacov.stats.out', -- filename to store report ['reportfile'] = 'luacov.report.out', diff --git a/app/app.lua b/app/app.lua index 978517a..76fa584 100644 --- a/app/app.lua +++ b/app/app.lua @@ -70,7 +70,7 @@ function App:start(options) print( 'Cherry: ' .. App.cherryVersion) print('--------------------------------') print('extensions:') - _G.tprint(App.extension, 1) + print(_G.inspect(App.extension, 1)) print('--------------------------------') self:deviceSetup() diff --git a/cherry.lua b/cherry.lua index de3033c..9cd9c77 100644 --- a/cherry.lua +++ b/cherry.lua @@ -8,4 +8,6 @@ _G.Effects = require 'engine.effects' _G.Game = require 'engine.game' _G.Sound = require 'engine.sound' -require 'tprint' +-- debug +_G.inspect = require 'inspect' + diff --git a/install-rocks b/install-rocks index 0a43afc..2fa318d 100755 --- a/install-rocks +++ b/install-rocks @@ -3,3 +3,4 @@ luarocks install busted; luarocks install luacheck; luarocks install luacov; luarocks install dkjson; +luarocks install inspect; diff --git a/libs/tprint.lua b/libs/tprint.lua deleted file mode 100644 index a27f2ff..0000000 --- a/libs/tprint.lua +++ /dev/null @@ -1,21 +0,0 @@ -_G.tprint = function (tbl, depth, loop) - if depth == nil then depth = 10 end - if loop == nil then loop = 1 end - if not tbl then print("Table nil") return end - - if type(tbl) ~= "table" then - print(tostring(tbl)) - else - for k, v in pairs(tbl) do - local formatting = string.rep(" ", loop) .. k - if type(v) == "table" then - print(formatting) - if(depth > 1) then - _G.tprint(v, depth - 1, loop + 1) - end - else - print(formatting .. ': ' .. tostring(v)) - end - end - end -end diff --git a/test/.luacov b/test/.luacov deleted file mode 100644 index c1a915b..0000000 --- a/test/.luacov +++ /dev/null @@ -1,44 +0,0 @@ ---- Global configuration file. Copy, customize and store in your --- project folder as '.luacov' for project specific configuration --- @class module --- @name luacov.defaults -return { - - -- default filename to load for config options if not provided - -- only has effect in 'luacov.defaults.lua' - ['configfile'] = '.luacov', - - -- filename to store stats collected - ['statsfile'] = 'luacov.stats.out', - - -- filename to store report - ['reportfile'] = 'luacov.report.out', - - -- Run reporter on completion? (won't work for ticks) - runreport = true, - - -- Delete stats file after reporting? - deletestats = true, - - -- Patterns for files to include when reporting - -- all will be included if nothing is listed - -- (exclude overrules include, do not include - -- the .lua extension) - ['include'] = { - 'app', - 'components', - 'engine', - 'libs', - 'screens' - }, - - -- Patterns for files to exclude when reporting - -- all will be included if nothing is listed - -- (exclude overrules include, do not include - -- the .lua extension) - ['exclude'] = { - 'mocks', - 'mocks', - 'tprint' - }, -} diff --git a/test/_global.lua b/test/_global.lua index 6fae413..9b732ec 100644 --- a/test/_global.lua +++ b/test/_global.lua @@ -1,13 +1,5 @@ expose('[setting up tests Globals]', function() - require('tprint') - - _G.sleep = function(n) - local t = os.clock() - while os.clock() - t <= n do - -- nothing - end - end - + _G.inspect = require('inspect') _G.display = require('mocks.display') _G.transition = require('mocks.transition') _G.App = require('mocks.app') diff --git a/test/mocks/display.lua b/test/mocks/display.lua index 810aa95..ad6d1d7 100644 --- a/test/mocks/display.lua +++ b/test/mocks/display.lua @@ -286,6 +286,22 @@ display = { newText.size = size return newText end, + newEmbossedText = function(options) + local newText = newDisplayObject() + newText.setEmbossColor = function(text, color) + local highlight = color.highlight + local shadow = color.shadow + newText.highlight = { r = highlight.r, g = highlight.g, b = highlight.b } + newText.shadow = { r = shadow.r, g = shadow.g, b = shadow.b } + end + + newText.x = options.x + newText.y = options.y + newText.text = options.text + newText.size = options.size + + return newText + end, currentStage = _currentStage, getCurrentStage = function() return display.currentStage end, TopLeftReferencePoint = 7, diff --git a/test/run b/test/run index 9aca93d..12b5b7a 100755 --- a/test/run +++ b/test/run @@ -1,11 +1,11 @@ #!/bin/bash if [[ $1 = "travis" ]]; then - busted \ + busted -v \ --run=tests \ --config-file=test/.busted \ -m '/home/travis/build/chrisdugne/cherry/test/?.lua;/home/travis/build/chrisdugne/cherry/libs/?.lua;/home/travis/build/chrisdugne/cherry/?.lua' else - busted \ + busted -v \ --run=tests \ --config-file=test/.busted fi diff --git a/test/spec/libs/text.lua b/test/spec/libs/text.lua new file mode 100644 index 0000000..3c96442 --- /dev/null +++ b/test/spec/libs/text.lua @@ -0,0 +1,19 @@ +local Text = require 'text' + +describe('[text]', function() + it('> should create Text.embossed', function() + local parent = display.newGroup() + local text = Text.embossed({ + parent = parent, + text = 'foo', + x = 111, + y = 222, + width = 333, + height = 444, + fontSize = 20 + }) + + assert.are.equal(text.x, 111) + assert.are.equal(text.y, 222) + end) +end)