-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests
- Loading branch information
Showing
16 changed files
with
330 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Run tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build_and_run: | ||
name: Build and run tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
lfs: true | ||
- uses: actions/setup-java@v1 | ||
with: | ||
java-version: '17' | ||
|
||
- name: Build && Run | ||
run: | | ||
deployer_url="https://raw.githubusercontent.com/Insality/defold-deployer/4/deployer.sh" | ||
curl -s ${deployer_url} | bash -s lbd --headless --settings ./test/test.ini | ||
- name: Upload test report | ||
run: bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
local reporter = require("luacov.reporter.defold") | ||
|
||
--- Default values for configuration options. | ||
-- For project specific configuration create '.luacov' file in your project | ||
-- folder. It should be a Lua script setting various options as globals | ||
-- or returning table of options. | ||
-- @class module | ||
-- @name deftest.coverage.configuration | ||
return { | ||
|
||
--- Reporter class to use when creating a report. Default: DefaultReporter from reporter.lua | ||
reporter = reporter, | ||
|
||
--- Filename to store collected stats. Default: "luacov.stats.out". | ||
statsfile = "luacov.stats.out", | ||
|
||
--- Filename to store report. Default: "luacov.report.out". | ||
reportfile = "luacov.report.out", | ||
|
||
--- Enable saving coverage data after every `savestepsize` lines? | ||
-- Setting this flag to `true` in config is equivalent to running LuaCov | ||
-- using `luacov.tick` module. Default: false. | ||
tick = false, | ||
|
||
--- Stats file updating frequency for `luacov.tick`. | ||
-- The lower this value - the more frequently results will be written out to the stats file. | ||
-- You may want to reduce this value (to, for example, 2) to avoid losing coverage data in | ||
-- case your program may terminate without triggering luacov exit hooks that are supposed | ||
-- to save the data. Default: 100. | ||
savestepsize = 100, | ||
|
||
--- Run reporter on completion? Default: true. | ||
runreport = true, | ||
|
||
--- Delete stats file after reporting? Default: false. | ||
deletestats = true, | ||
|
||
--- Process Lua code loaded from raw strings? | ||
-- That is, when the 'source' field in the debug info | ||
-- does not start with '@'. Default: true. | ||
codefromstrings = true, | ||
|
||
--- Lua patterns for files to include when reporting. | ||
-- All will be included if nothing is listed. | ||
-- Do not include the '.lua' extension. Path separator is always '/'. | ||
-- Overruled by `exclude`. | ||
-- @usage | ||
-- include = { | ||
-- "mymodule$", -- the main module | ||
-- "mymodule%/.+$", -- and everything namespaced underneath it | ||
-- } | ||
include = {}, | ||
|
||
--- Lua patterns for files to exclude when reporting. | ||
-- Nothing will be excluded if nothing is listed. | ||
-- Do not include the '.lua' extension. Path separator is always '/'. | ||
-- Overrules `include`. | ||
exclude = { "^test%/.+$" }, | ||
|
||
--- Table mapping names of modules to be included to their filenames. | ||
-- Has no effect if empty. | ||
-- Real filenames mentioned here will be used for reporting | ||
-- even if the modules have been installed elsewhere. | ||
-- Module name can contain '*' wildcard to match groups of modules, | ||
-- in this case corresponding path will be used as a prefix directory | ||
-- where modules from the group are located. | ||
-- @usage | ||
-- modules = { | ||
-- ["some_rock"] = "src/some_rock.lua", | ||
-- ["some_rock.*"] = "src" | ||
-- } | ||
modules = {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Lua.diagnostics.globals": [ | ||
"tweener", | ||
"describe", | ||
"it", | ||
"sys", | ||
"init", | ||
"timer", | ||
"socket", | ||
"go", | ||
"before", | ||
"gui", | ||
"vmath" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Path to bob folder. It will find and save new bob.jar files inside | ||
bob_folder=./ | ||
|
||
# You can point bob version for project in format "filename:sha" | ||
bob_sha="181:fd1ad4c17bfdcd890ea7176f2672c35102384419" | ||
|
||
# Select Defold channel. Values: stable, beta, alpha | ||
bob_channel="stable" | ||
|
||
# If true, it will check and download latest bob version. It will ignore bob_sha param | ||
use_latest_bob=false | ||
|
||
# Select Defold build server | ||
build_server="https://build.defold.com" | ||
|
||
# Is need to build html report | ||
is_build_html_report=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: "default" | ||
scale_along_z: 0 | ||
embedded_instances { | ||
id: "test" | ||
data: "components {\n" | ||
" id: \"test\"\n" | ||
" component: \"/test/test.gui\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
" property_decls {\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
script: "/test/test.gui_script" | ||
background_color { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 0.0 | ||
} | ||
material: "/builtins/materials/gui.material" | ||
adjust_reference: ADJUST_REFERENCE_PARENT | ||
max_nodes: 512 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
local deftest = require("deftest.deftest") | ||
|
||
function init(self) | ||
deftest.add(require("test.test_tweener")) | ||
|
||
local is_report = sys.get_config("test.report") == "1" | ||
deftest.run({ coverage = { enabled = is_report } }) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[bootstrap] | ||
main_collection = /test/test.collectionc | ||
|
||
[display] | ||
height = 256 | ||
width = 256 | ||
|
||
[test] | ||
report = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
return function() | ||
---@type tweener | ||
---@diagnostic disable-next-line: missing-fields | ||
local tweener = {} | ||
|
||
describe("Defold Tweener", function() | ||
before(function() | ||
tweener = require("tweener.tweener") | ||
end) | ||
|
||
it("Tweener Ease", function() | ||
assert(tweener.ease(go.EASING_LINEAR, 0, 100, 1, 0) == 0) | ||
assert(tweener.ease(go.EASING_LINEAR, 0, 100, 1, 0.5) == 50) | ||
assert(tweener.ease(go.EASING_LINEAR, 0, 100, 1, 1) == 100) | ||
|
||
assert(tweener.ease(go.EASING_INOUTQUAD, 0, 100, 1, 0) == 0) | ||
assert(tweener.ease(go.EASING_INOUTQUAD, 0, 100, 1, 0.5) == 50) | ||
assert(tweener.ease(go.EASING_INOUTQUAD, 0, 100, 1, 1) == 100) | ||
end) | ||
|
||
it("Tweener Custom Ease", function() | ||
local easing = {0, 1, 2, 1, 0} | ||
|
||
assert(tweener.ease(easing, 0, 100, 1, 0) == 0) | ||
assert(tweener.ease(easing, 0, 100, 1, 0.25) == 100) | ||
assert(tweener.ease(easing, 0, 100, 1, 0.5) == 200) | ||
assert(tweener.ease(easing, 0, 100, 1, 0.75) == 100) | ||
assert(tweener.ease(easing, 0, 100, 1, 1) == 0) | ||
|
||
-- Edge | ||
assert(tweener.ease(easing, 0, 100, 1, -1) == 0) | ||
assert(tweener.ease(easing, 0, 100, 1, 0) == 0) | ||
assert(tweener.ease(easing, 0, 100, 1, 2) == 0) | ||
end) | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
---Download Defold annotations from here: https://github.com/astrochili/defold-annotations/releases/ | ||
|
||
---@alias easing_function (fun(current: number, from: number, to: number, time: number): number)|constant|number[] | ||
|
||
---@class tweener | ||
---@field tween fun(easing_function: easing_function, from: number, to: number, time: number, callback: fun(value: number, is_end: boolean), update_delta_time: number|nil): hash | ||
---@field ease fun(easing_function: easing_function, from: number, to: number, time: number, time_elapsed: number): number |
Oops, something went wrong.