voqn / macchiato Goto Github PK
View Code? Open in Web Editor NEWBDD + QDD testing framework for JavaScript
Home Page: voqn.github.com/macchiato
BDD + QDD testing framework for JavaScript
Home Page: voqn.github.com/macchiato
Implement arbitrary.prototype.sample
method
本家 QuickCheck の様に sample :: Show a => Gen a -> IO ()
を実装する。
console.log
に吐き出してもかまわないのだけど、戻りの値も欲しいので、返り値は生成したすべての値を配列で返す実装にする
// default, return 10 sample values ( in array )
var sample_integers = arbitrary('integer').sample();
// #=> [ 0, -1, 3, -4, 0, 10, -2, -1, 5, 9 ]
// if call it with number argument, it return values specified quantity
var sample_5_booleans = arbitrary('bool').sample( 5 );
// #=> [ true, false, true, true, true ]
/**
* @param {number=} opt_count
* @return {Array}
*/
arbitrary.prototype.sample = function( opt_count ){
// ...
};
Generate distribution for Node.js module by Cakefile
Now, macchiato utility function map
each
use isList
in internal.
isList
function is kind of this mistake. ↓ :-(
if (o instanceof Array)
{
// Oh frabjous day!
}
Sadly, this code doesn't work as expected.
from Determining with absolute accuracy whether or not a JavaScript object is an array by mozila
Array.isArray
if(!Array.isArray) {
Array.isArray = function (vArg) {
return Object.prototype.toString.call(vArg) === "[object Array]";
};
}
from isArray - MDN
Generate macchiato.min.js
file by Makefile.
Write Makefile or ShellScript.
dist/macchiato.min.js
for web front enddist/macchiato.js
for Node.jsmake test-node
, make test-web
)Now, Macchiato test view object depends on TestView
object. TestView
object depends on static html page ( and its dom ).
Add these object
TestViewControl
WebTestView
ConsoleTestView
TestViewControl
switch TestView
entity either WebTestView
(testing on web html) or ConsoleTestView
(testing on node.js).
in QuickCheck, test property is very easy, and simple to write
prop_commutative :: Int -> Int -> Bool
prop_commutative x y =
x + y == y + x
now, macchiato.js test property declaration is more verbosely than QuickCheck.
macchiato.stock({
'commuative with 2 numbers':
arbitrary('number', 'number').property(function (x, y) {
return x + y === y + x;
})
});
I design new short hand test property declaration now.
// test target function
macchiato.stock({
'[(number, number) -> (x, y)] => commutative' : function (x, y) {
return x + y === y + x;
}
});
in case test a method return boolean,
macchiato.stock({
'[[integer] -> arr] => is array list' : Array.isArray
});
label = /^\[(value)\]\s*=>\s*(.*)$/
value = /(type)\s*\->\s*(param)(\s*,\s*(cond)+)?/
types = params = /\w+(\s*,\s*\w+)*/ # types :: "number, string", params :: "x, y",
cond = /(state|operate)/ # condition well boolean expression
state = /(\w+)\.(\w+\(\s*\w*\s*\))/ # state :: "Array.isArray(x)", ""
operate = /(\w+)\s*(op)\s*(\w+)/ # operate :: "x > y", "x && y"
op = /((<)|(>)|(==)|(!=)|(===)|(!==)|(&&)|(\|\|)/ # operator signature
i want node.js console view!
Write article to wiki, about macchiato architecture, design bases, and dependency tree.
基本的な設計をwikiにまとめること。オブジェクト間のメッセージパッシングの関係性などの設計をやる
Write article to wiki about macchiato
basic API and extension API.
macchiato
の基本的な API と拡張プラグインのためのAPI の仕様を作る
Now, Macchiato test view object depends on TestView
object. TestView
object depends on static html page ( and its dom ).
Add these object
TestViewControl
WebTestView
ConsoleTestView
TestViewControl
switch TestView
entity either WebTestView
(testing on web html) or ConsoleTestView
(testing on node.js).
Write README for end-users, and developers.
README 書こう
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.