Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-chailove
Commits
831e3fc5
Verified
Commit
831e3fc5
authored
Mar 04, 2018
by
RobLoach
Browse files
tests: Add more unit tests
parent
95f2bc9e
Changes
10
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
831e3fc5
...
...
@@ -4,7 +4,7 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
The format is based on
[
Keep a Changelog
](
http://keepachangelog.com/en/1.0.0/
)
and this project adheres to
[
Semantic Versioning
](
http://semver.org/spec/v2.0.0.html
)
.
## 0.15.0 -
Unreleased
## 0.15.0 -
2017-03-04
### Changed
-
Updated the input description names
-
Switch Keyboard/Mouse input from SDL API to libretro API
...
...
examples/README.md
View file @
831e3fc5
...
...
@@ -3,3 +3,10 @@
Provides a few examples of usage of ChaiLove. To run them, execute:
retroarch -L chailove_libretro.so examples/snake/main.chai
## Examples
-
Benchmark
-
Pong
-
Simple
-
Snake
jni/Android.mk
View file @
831e3fc5
...
...
@@ -9,7 +9,7 @@ ifneq ($(GIT_VERSION)," unknown")
LOCAL_CXXFLAGS
+=
-DGIT_VERSION
=
\"
$(GIT_VERSION)
\"
endif
CORE_DIR
=
..
/..
CORE_DIR
=
..
JIT
=
DESMUME_JIT
=
0
...
...
src/ChaiLove.h
View file @
831e3fc5
...
...
@@ -41,7 +41,7 @@
* - \link love::keyboard keyboard \endlink Provides an interface to the user's keyboard.
* - \link love::math math \endlink Provides system-independent mathematical functions.
* - \link love::mouse mouse \endlink Provides an interface to the user's mouse.
* - \link love::script script \endlink This module is responsible for
interacting with the script
.
* - \link love::script script \endlink This module is responsible for
callback events
.
* - \link love::sound sound \endlink This module is responsible for decoding sound files.
* - \link love::system system \endlink Provides access to information about the user's system.
* - \link love::timer timer \endlink Provides high-resolution timing functionality.
...
...
test/unittests/assets/chailove.png
0 → 100644
View file @
831e3fc5
51.4 KB
test/unittests/filesystem.chai
View file @
831e3fc5
...
...
@@ -8,25 +8,25 @@ for (file : files) {
}
}
assert(foundUnitChai, "filesystem.getDirectoryItems()")
assert(foundUnitChai, "
love.
filesystem.getDirectoryItems()")
var contents = love.filesystem.read("main.chai")
var needle = "Unit Testing Framework"
var found = contents.find(needle)
assert(found > 50, "filesystem.read()")
assert(found > 50, "
love.
filesystem.read()")
assert(love.filesystem.exists("math.chai"), "filesystem.exists('math.chai')")
assert(!love.filesystem.exists("notexist.chai"), "filesystem.exists('notexist.chai')")
assert(love.filesystem.exists("math.chai"), "
love.
filesystem.exists('math.chai')")
assert(!love.filesystem.exists("notexist.chai"), "
love.
filesystem.exists('notexist.chai')")
assert(love.filesystem.getSize("filesystem.chai") > 10, "filesystem.getSize()")
assert_equal(love.filesystem.getSize("notexist.chai"), -1, "filesystem.getSize('notexist.chai')")
assert(love.filesystem.getSize("filesystem.chai") > 10, "
love.
filesystem.getSize()")
assert_equal(love.filesystem.getSize("notexist.chai"), -1, "
love.
filesystem.getSize('notexist.chai')")
assert(love.filesystem.isFile("filesystem.chai"), "filesystem.isFile()")
assert(!love.filesystem.isFile("notexist.chai"), "filesystem.isFile('notexist.chai')")
assert(love.filesystem.isFile("filesystem.chai"), "
love.
filesystem.isFile()")
assert(!love.filesystem.isFile("notexist.chai"), "
love.
filesystem.isFile('notexist.chai')")
assert_not(love.filesystem.isDirectory("keyboard.chai"), "love.filesystem.isDirectory()")
assert_equal(love.filesystem.getDirectoryItems("assets").size(),
1
, "love.filesystem.getDirectoryItems()")
assert_equal(love.filesystem.getDirectoryItems("assets").size(),
2
, "love.filesystem.getDirectoryItems()")
var theLines = love.filesystem.lines("filesystem.chai")
assert_equal(theLines[0], "// Filesystem", "love.filesystem.lines()")
test/unittests/image.chai
0 → 100644
View file @
831e3fc5
var theImage = love.image.newImageData("assets/chailove.png")
assert_equal(theImage.getWidth(), 480, "Image.getWidth()")
assert_equal(theImage.getHeight(), 480, "Image.getHeight()")
test/unittests/main.chai
View file @
831e3fc5
...
...
@@ -4,19 +4,20 @@ def load() {
print("\n================================\n")
print("ChaiLove: Unit Testing Framework\n")
love.filesystem.load("assert.chai")
love.filesystem.load("audio.chai")
love.filesystem.load("filesystem.chai")
love.filesystem.load("font.chai")
love.filesystem.load("graphics.chai")
love.filesystem.load("math.chai")
love.filesystem.load("mouse.chai")
love.filesystem.load("joystick.chai")
love.filesystem.load("keyboard.chai")
love.filesystem.load("timer.chai")
love.filesystem.load("sound.chai")
love.filesystem.load("system.chai")
love.filesystem.load("window.chai")
love.filesystem.load("assert")
love.filesystem.load("audio")
love.filesystem.load("filesystem")
love.filesystem.load("font")
love.filesystem.load("graphics")
love.filesystem.load("image")
love.filesystem.load("math")
love.filesystem.load("mouse")
love.filesystem.load("joystick")
love.filesystem.load("keyboard")
love.filesystem.load("timer")
love.filesystem.load("sound")
love.filesystem.load("system")
love.filesystem.load("window")
if (failure != "") {
print("\n" + failure + "\n")
...
...
test/unittests/math.chai
View file @
831e3fc5
var num = love.math.random()
assert(num >= 0 && num <= 1, "math.random()")
assert(num >= 0 && num <= 1, "
love.
math.random()")
num = love.math.random(10)
assert(num >= 0 && num <= 10, "math.random(10)")
assert(num >= 0 && num <= 10, "
love.
math.random(10)")
num = love.math.random(10.0)
assert(num >= 0 && num <= 10, "math.random(10)")
assert(num >= 0 && num <= 10, "
love.
math.random(10)")
num = love.math.random(10.0f)
assert(num >= 0 && num <= 10, "math.random(10)")
assert(num >= 0 && num <= 10, "
love.
math.random(10)")
num = love.math.random(10, 100)
assert(num >= 10 && num <= 100, "math.random(10, 100)")
assert(num >= 10 && num <= 100, "
love.
math.random(10, 100)")
num = love.math.random(10.0, 100.0)
assert(num >= 10.0 && num <= 100.0, "math.random(10.0, 100.0)")
assert(num >= 10.0 && num <= 100.0, "
love.
math.random(10.0, 100.0)")
num = love.math.random(10.0f, 100.0f)
assert(num >= 10.0f && num <= 100.0f, "math.random(10.0, 100.0)")
assert(num >= 10.0f && num <= 100.0f, "
love.
math.random(10.0, 100.0)")
love.math.setRandomSeed(50, 100)
assert(true, "math.setRandomSeed(50, 100)")
assert(true, "
love.
math.setRandomSeed(50, 100)")
love.math.setRandomSeed(10)
assert(true, "math.setRandomSeed(10)")
assert_equal(love.math.getRandomSeed(), 10, "math.getRandomSeed()")
assert(true, "
love.
math.setRandomSeed(10)")
assert_equal(love.math.getRandomSeed(), 10, "
love.
math.getRandomSeed()")
var text = "Hello World! Hello World! Hello World!"
var compressed = love.math.compress(text)
assert_not_equal(text, compressed, "math.compress()")
assert_not_equal(text, compressed, "
love.
math.compress()")
var decompressed = love.math.decompress(compressed)
assert_equal(decompressed, text, "math.decompress()")
assert_equal(decompressed, text, "
love.
math.decompress()")
assert(love.math.pi > 3.0f && love.math.pi < 4.0f, "math.pi")
assert(love.math.e > 2.0f, "math.e")
assert(love.math.pi > 3.0f && love.math.pi < 4.0f, "
love.
math.pi")
assert(love.math.e > 2.0f, "
love.
math.e")
test/unittests/timer.chai
View file @
831e3fc5
var delta = love.timer.getDelta()
assert(delta >= 0, "timer.getDelta()")
assert(delta >= 0, "
love.
timer.getDelta()")
var fps = love.timer.getFPS()
assert(fps >= 0, "love.timer.getFPS()")
assert(fps >= 0, "love.
love.
timer.getFPS()")
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment