Unverified Commit f9d414fb authored by RobLoach's avatar RobLoach Committed by GitHub
Browse files

Merge pull request #327 from libretro/update-tests

0.28.0
parents ba37b58c ee0bc20a
......@@ -4,9 +4,10 @@ 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.28.0 - Unreleased
## 0.28.0 - 2018-10-07
### Features
- `love.timer.step()` now returns `dt`
- Adds `string::replace(search, replace)` to replace all instances of a string
### Fixes
- Fixes undefined reference to `process_sinc_neon_asm()`
......@@ -16,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Chores
- Update libretro-common
- Update PhysFS
- Rework the testing framework
- Fix Doxygen warnings
## 0.27.0 - 2018-09-25
### Features
......
......@@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API"
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = "0.27.0"
PROJECT_NUMBER = "0.28.0"
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
......@@ -51,7 +51,7 @@ OUTPUT_LANGUAGE = English
# whereas setting the tag to NO uses a Unix-style encoding (the default for
# all platforms other than Windows).
USE_WINDOWS_ENCODING = NO
# USE_WINDOWS_ENCODING = NO
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
......@@ -120,7 +120,7 @@ MULTILINE_CPP_IS_BRIEF = NO
# If set to NO, the detailed description appears after the member
# documentation.
DETAILS_AT_TOP = NO
# DETAILS_AT_TOP = NO
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
......@@ -270,7 +270,7 @@ SORT_MEMBER_DOCS = YES
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
GENERATE_TODOLIST = YES
GENERATE_TODOLIST = NO
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
......@@ -288,7 +288,7 @@ GENERATE_BUGLIST = YES
# disable (NO) the deprecated list. This list is created by putting
# \deprecated commands in the documentation.
GENERATE_DEPRECATEDLIST= YES
GENERATE_DEPRECATEDLIST= NO
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
......@@ -483,7 +483,7 @@ VERBATIM_HEADERS = YES
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
ALPHABETICAL_INDEX = NO
ALPHABETICAL_INDEX = YES
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
......@@ -542,7 +542,7 @@ HTML_STYLESHEET =
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
HTML_ALIGN_MEMBERS = YES
# HTML_ALIGN_MEMBERS = YES
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
......@@ -776,13 +776,13 @@ XML_OUTPUT = xml
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_SCHEMA =
# XML_SCHEMA =
# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
XML_DTD =
# XML_DTD =
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
......@@ -1036,7 +1036,7 @@ DOTFILE_DIRS =
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_WIDTH = 1024
# MAX_DOT_GRAPH_WIDTH = 1024
# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height
# (in pixels) of the graphs generated by dot. If a graph becomes larger than
......@@ -1044,7 +1044,7 @@ MAX_DOT_GRAPH_WIDTH = 1024
# the specified constraint. Beware that most browsers cannot cope with very
# large images.
MAX_DOT_GRAPH_HEIGHT = 1024
# MAX_DOT_GRAPH_HEIGHT = 1024
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
......
......@@ -47,7 +47,7 @@ global T
def conf(t) {
t.window.width = WIDTH * gridScale
t.window.height = HEIGHT * gridScale
t.version = "0.27.0"
t.version = "0.28.0"
}
/**
......
......@@ -47,9 +47,9 @@
#define SRC_CHAILOVE_H_
#define CHAILOVE_VERSION_MAJOR 0
#define CHAILOVE_VERSION_MINOR 27
#define CHAILOVE_VERSION_MINOR 28
#define CHAILOVE_VERSION_PATCH 0
#define CHAILOVE_VERSION_STRING "0.27.0"
#define CHAILOVE_VERSION_STRING "0.28.0"
#include "SDL.h"
#include "libretro.h"
......
#ifndef SRC_CHAILOVEDOCS_H_
#define SRC_CHAILOVEDOCS_H_
/**
* @file Globals.h
* @page globals Globals
*
* This provides documentation about globals available through ChaiLove.
*/
#include <string>
/**
......@@ -73,4 +80,26 @@ class List {
*/
bool require(const std::string& module);
/**
* Provides some additional functionality to the basic string object.
*/
class String {
public:
/**
* Replaces all instances of the search string with the given replace string.
*
* @param search The string to search for that should be replaced.
* @param replace The string that will replace the found string.
*
* @return The new string with the replaced strings.
*
* @code
* var hello = "Hello World!"
* var goodbye = hello.replace("Hello", "Goodbye")
* // => "Goodbye World!"
* @endcode
*/
std::string replace(const std::string& search, const std::string& replace);
};
#endif // SRC_CHAILOVEDOCS_H_
......@@ -43,7 +43,7 @@ class filesystem {
/**
* Read the contents of a file.
*
* @param file The name (and path) of the file.
* @param filename The name (and path) of the file.
*
* @return The contents of the file.
*
......@@ -72,7 +72,7 @@ class filesystem {
/**
* Get the size in bytes of a file.
*
* @param The file to get the size of.
* @param file The file to get the size of.
*
* @return The size of the given file.
*/
......@@ -105,7 +105,7 @@ class filesystem {
/**
* Creates a new FileData from a file on the storage device.
*
* @param path Path to the file.
* @param filepath Path to the file.
*
* @return The new FileData, or nil if an error occurred.
*
......
......@@ -295,6 +295,9 @@ class graphics {
* @param drawmode How to draw the arc. Can be "fill" or "line".
* @param x The position to draw the object (x-axis).
* @param y The position to draw the object (y-axis).
* @param radius The radius of the arc.
* @param angle1 The angle of the first
* @param angle2 The angle of the second.
*/
graphics& arc(const std::string& drawmode, int x, int y, int radius, int angle1, int angle2);
......
......@@ -37,7 +37,7 @@ class math {
* Sets the random seed to a random seed between the given min and max values.
*
* @param min The lower 32 bits of the seed value.
* @param high The higher 32 bits of the seed value.
* @param max The higher 32 bits of the seed value.
*
* @return The math module, to allow for method chaining.
*
......
......@@ -91,6 +91,24 @@ script::script(const std::string& file) {
chai.add(bootstrap::standard_library::vector_type<std::vector<std::string>>("StringVector"));
chai.add(bootstrap::standard_library::map_type<std::map<std::string, bool>>("StringBoolMap"));
// Global Helpers
// string::replace(std::string search, std::string replace)
chai.add(fun([](const std::string& subject, const std::string& search, const std::string& replace) {
std::string newSubject(subject);
size_t pos = 0;
while ((pos = newSubject.find(search, pos)) != std::string::npos) {
newSubject.replace(pos, search.length(), replace);
pos += replace.length();
}
return newSubject;
}), "replace");
// string::replace(char search, char replace)
chai.add(fun([](const std::string& subject, char search, char replace) {
std::string newSubject(subject);
std::replace(newSubject.begin(), newSubject.end(), search, replace);
return newSubject;
}), "replace");
// List
auto listModule = std::make_shared<chaiscript::Module>();
chaiscript::bootstrap::standard_library::list_type<std::list<chaiscript::Boxed_Value> >("List", *listModule);
......
......@@ -93,7 +93,7 @@ window& window::showMessageBox(const std::string& msg, int frames) {
}
window& window::showMessageBox(const std::string& msg) {
showMessageBox(msg, 2800);
showMessageBox(msg, 1000);
return *this;
}
......
/**
* Cheat Test
*
* retroarch -L chailove_libretro.so test/sound.chai
* retroarch -L chailove_libretro.so test/cheats.chai
*/
global lastcheatcode
......
class graphics_draw {
var name;
var x;
var y;
var image;
def graphics_draw() {
this.name = "graphics.draw()";
}
def load() {
this.image = love.graphics.newImage("assets/graphics_draw.png");
this.x = love.graphics.getWidth() / 2.0f - this.image.getWidth() / 2.0f;
this.y = love.graphics.getHeight() / 2.0f - this.image.getHeight() / 2.0f;
}
def draw() {
love.graphics.draw(this.image, this.x, this.y);
}
def update(delta) {
}
};
class love_audio_play {
def love_audio_play() {
// Nothing.
}
def load() {
this.chailovesound = love.audio.newSource("unittests/assets/chailove.ogg")
}
def draw() {
love.graphics.print("Press the X key", 100, 200)
}
def update(delta) {
if (love.keyboard.isDown("x")) {
love.audio.play(this.chailovesound)
}
}
};
/**
* love.graphics.draw testing
*
* An alternative test with a different file name.
*
* retroarch -L chailove_libretro.so test/love.graphics.draw.chai
*/
class love_graphics_draw {
global keyPressed = "a";
global keyReleased = "b";
global logo
global angle = 0.0f
global scale = 1.0f
def load() {
logo = love.image.newImageData("assets/graphics_draw.png")
love.graphics.setBackgroundColor(50, 50, 100)
}
def update(dt) {
angle = angle - dt * 180.0f
if (keyPressed == "up") {
scale = scale + dt * 1.0f
}
else if (keyPressed == "down") {
scale = scale - dt * 1.0f
def love_graphics_draw() {
// Nothing.
}
}
def draw() {
love.graphics.print("Key Pressed: " + keyPressed, 5, 20)
love.graphics.print("Key Released: " + keyReleased, 5, 100)
love.graphics.setColor(255, 0, 0)
//love.graphics.draw(logo, graphics.getWidth() / 2, graphics.getHeight() / 2, math.rad(angle), 2, 2, 64/2, 64/2)
love.graphics.point(love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 2.0f)
love.graphics.draw(logo, love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 2.0f, love.math.rad(angle), scale, scale, logo.getWidth() / 2.0f, logo.getHeight() / 2.0f)
love.graphics.point(love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 2.0f)
//love.graphics.point(graphics.getWidth() / 2
}
def load() {
this.image = love.graphics.newImage("assets/graphics_draw.png");
this.x = love.graphics.getWidth() / 2.0f - this.image.getWidth() / 2.0f;
this.y = love.graphics.getHeight() / 2.0f - this.image.getHeight() / 2.0f;
}
def keypressed(key, scancode) {
keyPressed = key
}
def draw() {
love.graphics.draw(this.image, this.x, this.y);
}
def keyreleased(key, scancode) {
keyReleased = key
}
def update(delta) {
// Nothing.
}
};
class love_graphics_draw_scaling {
def love_graphics_draw_scaling() {
// Nothing.
}
def load() {
this.logo = love.image.newImageData("assets/graphics_draw.png")
this.angle = 0.0f
this.scale = 1.0f
}
def draw() {
love.graphics.setColor(255, 0, 0)
//love.graphics.draw(logo, graphics.getWidth() / 2, graphics.getHeight() / 2, math.rad(angle), 2, 2, 64/2, 64/2)
love.graphics.point(love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 2.0f)
love.graphics.draw(this.logo, love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 2.0f, love.math.rad(this.angle), this.scale, this.scale, this.logo.getWidth() / 2.0f, this.logo.getHeight() / 2.0f)
love.graphics.point(love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 2.0f)
//love.graphics.point(graphics.getWidth() / 2
love.graphics.print("Press x/z", 100, 100)
}
def update(dt) {
this.angle = this.angle - dt * 180.0f
if (love.keyboard.isDown("x")) {
this.scale = this.scale + dt * 1.0f
}
else if (love.keyboard.isDown("z")) {
this.scale = this.scale - dt * 1.0f
}
}
};
class graphics_point {
var name;
def graphics_point() {
this.name = "graphics.point()";
}
class love_graphics_point {
def love_graphics_point() {}
def load() {
//graphics.setBackgroundColor(255,200,100)
// Nothing.
}
def draw() {
//graphics.setColor(0, 255, 0)
// graphics.setColor(0, 255, 0)
love.graphics.point(100, 200).point(200, 300)
}
def update(delta) {
// Nothing.
}
};
class graphics_print {
var name;
var x;
var y;
class love_graphics_print {
def graphics_print() {
this.name = "graphics.print()";
def love_graphics_print() {
//this.x = 100;
}
def load() {
this.x = 100;
this.y = love.graphics.getHeight() / 2.0f - 30;
this.x = 100
this.y = love.graphics.getHeight() / 2.0f - 30
}
def draw() {
love.graphics.setColor(0, 255, 0)
love.graphics.print("Press left/right to switch tests", this.x, this.y);
love.graphics.print("Press left/right to switch tests", this.x, this.y)
}
def update(delta) {
// Nothing
}
};
class graphics_print_font {
var name;
var ttffont;
var pngfont;
class love_graphics_print_font {
def graphics_print_font() {
this.name = "graphics.print(font)";
def love_graphics_print_font() {
// Nothing.
}
def load() {
......@@ -31,5 +28,7 @@ class graphics_print_font {
love.graphics.print(text, love.graphics.getWidth() / 2.0f - width / 2.0f, love.graphics.getHeight() - height)
}
def update(delta) {}
def update(delta) {
// Nothing.
}
};
class mouse_getPosition {
var name;
class love_mouse_getPosition {
def mouse_getPosition() {
this.name = "mouse.getPosition()";
def love_mouse_getPosition() {
// Nothing.
}
def load() {}
def load() {
// Nothing.
}
def draw() {
love.graphics.setColor(255, 150, 0)
......@@ -14,5 +15,7 @@ class mouse_getPosition {
love.graphics.print(output, pos.x, pos.y);
}
def update(delta) {}
def update(delta) {
// Nothing.
}
};
......@@ -2,11 +2,13 @@
* ChaiLove: Testing Framework
*/
global testNames = [
"graphics_print",
"graphics_draw",
"graphics_point",
"mouse_getPosition",
"graphics_print_font"
"love.graphics.print",
"love.graphics.print.font",
"love.graphics.draw",
"love.graphics.point",
"love.mouse.getPosition",
"love.audio.play",
"love.graphics.draw.scaling"
]
global tests = []
global currenttest = 0
......@@ -15,17 +17,24 @@ def conf(t) {
t.window.width = 460
t.window.height = 320
t.console = true
t.version = "0.27.0"
}
def load() {
print("------------------")
print("------------------")
print("- ChaiLove Tests -")
print("------------------")
print("------------------")
// Set the background to grey, so that we can see screen size.
love.graphics.setBackgroundColor(50, 50, 50)
// Index the test cases.
for (name : testNames) {
love.filesystem.load(name + ".chai");
tests.push_back(eval(name + "()"));
var className = name.replace('.', '_')
print(className)
tests.push_back(eval(className + "()"));
}
// Load all the tests.
......@@ -46,7 +55,7 @@ def draw() {
// Use the default font.
love.graphics.setFont()
love.graphics.setColor(255, 255, 255)
love.graphics.print("Test " + to_string(currenttest + 1) + "/" + to_string(tests.size()) + ": " + tests[currenttest].name, 5, 5);
love.graphics.print("Test " + to_string(currenttest + 1) + "/" + to_string(tests.size()) + ": " + testNames[currenttest], 5, 5);
love.graphics.print("FPS " + to_string(love.timer.getFPS()), 5, 20);
love.graphics.print("Username: " + love.system.getUsername(), 5, 35)
......
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