Adding testing

This commit is contained in:
Devine Lu Linvega 2019-07-14 07:39:43 +09:00
parent 97861dc3f3
commit c571d32ef2
5 changed files with 43 additions and 15 deletions

View File

@ -4,16 +4,17 @@ Ronin is a graphic design tool under development.
<img src='https://raw.githubusercontent.com/hundredrabbits/Ronin/master/PREVIEW.jpg' width='600'/>
## Themes
## Electron Build
Drag a .thm file on the window to install it.
## Controls
<img src='https://cdn.rawgit.com/hundredrabbits/Ronin/master/LAYOUT.svg?v=1' width="600"/>
```
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!

View File

@ -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)

View File

@ -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
}
}

View File

@ -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)
},

16
examples/benchmark.lisp Normal file
View File

@ -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)
)