From c571d32ef20038523c7d65fd7c64b6796121b89b Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 14 Jul 2019 07:39:43 +0900 Subject: [PATCH] Adding testing --- README.md | 15 ++++++++------- desktop/sources/scripts/lib/theme.js | 2 +- desktop/sources/scripts/library.js | 23 +++++++++++++++++------ desktop/sources/scripts/lisp.js | 2 +- examples/benchmark.lisp | 16 ++++++++++++++++ 5 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 examples/benchmark.lisp diff --git a/README.md b/README.md index 84f5e10..9eebfd5 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,17 @@ Ronin is a graphic design tool under development. -## Themes +## Electron Build -Drag a .thm file on the window to install it. - -## Controls - - +``` +cd desktop +npm install +npm start +``` ## Extras -- Download additional [themes](https://github.com/hundredrabbits/Themes). +- This application supports the [Ecosystem Theme](https://github.com/hundredrabbits/Themes). - Support this project through [Patreon](https://patreon.com/100). - See the [License](LICENSE.md) file for license rights and limitations (MIT). +- Pull Requests are welcome! diff --git a/desktop/sources/scripts/lib/theme.js b/desktop/sources/scripts/lib/theme.js index 8ae7708..2618d9a 100644 --- a/desktop/sources/scripts/lib/theme.js +++ b/desktop/sources/scripts/lib/theme.js @@ -60,7 +60,7 @@ function Theme (_default) { e.stopPropagation() const file = e.dataTransfer.files[0] if (!file || !file.name) { console.warn('Theme', 'Unnamed file.'); return } - if (file.name.indexOf('.thm') < 0 && file.name.indexOf('.svg') < 0) { console.warn('Theme', 'Skipped, not a theme'); return } + if (file.name.indexOf('.thm') < 0 && file.name.indexOf('.svg') < 0) { return } const reader = new FileReader() reader.onload = function (e) { themer.load(e.target.result) diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index ed98056..0d0c012 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -131,11 +131,6 @@ function Library (ronin) { return rect } - this.echo = function (any) { - console.log(any) - return any - } - // this.of = function (h, k) { @@ -155,7 +150,7 @@ function Library (ronin) { this.mul = function (...args) { return args.reduce((sum, val) => sum * val) } - + this.div = function (...args) { return args.reduce((sum, val) => sum / val) } @@ -171,4 +166,20 @@ function Library (ronin) { this.step = function (val, step) { return Math.round(val / step) * step } + + // Generics + + this.echo = function (...args) { + console.log(args.reduce((acc, val) => { return acc + val + ' ' }, '')) + return args + } + + this.test = function (name, a, b) { + if (a !== b) { + console.warn('failed ' + name, a, b) + } else { + console.log('passed ' + name, a, b) + } + return a === b + } } diff --git a/desktop/sources/scripts/lisp.js b/desktop/sources/scripts/lisp.js index 0cb4b73..4f864c7 100644 --- a/desktop/sources/scripts/lisp.js +++ b/desktop/sources/scripts/lisp.js @@ -22,7 +22,7 @@ function Lisp (input, lib) { run: (input, context) => { const file = fs.readFileSync( path.resolve(input[1].value), - {encoding: "utf-8"}) + { encoding: 'utf-8' }) return interpret(this.parse(file), context) }, diff --git a/examples/benchmark.lisp b/examples/benchmark.lisp new file mode 100644 index 0000000..7a51145 --- /dev/null +++ b/examples/benchmark.lisp @@ -0,0 +1,16 @@ +; benchmark + +( +; Basics + + (test "add" (add 8 4 2) 14) + (test "sub" (sub 8 4 2) 2) + (test "mul" (mul 8 4 2) 64) + (test "div" (div 8 4 2) 1) + +; Others + + (test "mod" (mod 6 4) 2) + (test "clamp" (clamp 12 4 8) 8) + (test "step" (step 12 10) 10) +) \ No newline at end of file