Verified Commit 831e3fc5 authored by RobLoach's avatar RobLoach
Browse files

tests: Add more unit tests

parent 95f2bc9e
......@@ -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
......
......@@ -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
......@@ -9,7 +9,7 @@ ifneq ($(GIT_VERSION)," unknown")
LOCAL_CXXFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
CORE_DIR = ../..
CORE_DIR = ..
JIT=
DESMUME_JIT=0
......
......@@ -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.
......
......@@ -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()")
var theImage = love.image.newImageData("assets/chailove.png")
assert_equal(theImage.getWidth(), 480, "Image.getWidth()")
assert_equal(theImage.getHeight(), 480, "Image.getHeight()")
......@@ -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")
......
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")
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()")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment