Example #1
0
function gSuite(gen, inv) {
    return suite(inv, suite.generate(1000,
        [gen],
        function(op, a, b) {
            return op(a, b);
        }
    ));
}
Example #2
0
function aSuite(fn, doc, preconditions, postconditions, name) {
    suite(partial(getMeta, fn), [
        '_doc', doc,
        '_preconditions', preconditions,
        '_postconditions', postconditions,
        '_name', name
    ]);
}
Example #3
0
function numberRangeTest() {
    var numberOfTens = 0;
    var cases = 10;

    suite(f.id, suite.generate(cases,
        [g.number(1, 10), g.number(11, 30)],
        function(op, a, b) {
            if(a == 10) numberOfTens++;

            return true;
        })
    );

    return cases != numberOfTens;
}
Example #4
0
var suite = require('suite.js');
var f = require('funkit');

suite(f.common.prop('foo'), [
    {foo: 4}, 4,
    {bar: 2}, undefined
]);
Example #5
0
File: not.js Project: bebraw/funkit
var suite = require('suite.js');
var not = require('funkit/functional').not;

suite(not(alwaysTrue), [
    'a', false,
    2, false
]);

suite(not(alwaysFalse), [
    'a', true,
    2, true
]);

suite(not(odd), [
    2, true,
    3, false
]);

function alwaysTrue() {
    return true;
}

function alwaysFalse() {
    return false;
}

function odd(a) {
    return a % 2;
}
Example #6
0
suite(parseGh, [
    'foo', {},
    'git://github.com/coolony/kiwi', {
        user: '******',
        repo: 'kiwi'
    },
    'git@github.com:jquery/jquery.git', {
        user: '******',
        repo: 'jquery'
    },
    'https://github.com/mootools/mootools', {
        user: '******',
        repo: 'mootools'
    },
    'https://github.com/prototype/prototype.git', {
        user: '******',
        repo: 'prototype'
    },
    'https://github.com/peterwilli/CoolQueue.io', {
        user: '******',
        repo: 'CoolQueue.io'
    },
    'git://github.com/angular-strap/angular-strap.git', {
        user: '******',
        repo: 'angular-strap'
    },
    'https://github.com/nathansmith/960-Grid-System/blob/master/code/css/960.css', {
        user: '******',
        repo: '960-Grid-System'
    },
    'http://fortawesome.github.com/Font-Awesome/', {
        user: '******',
        repo: 'Font-Awesome'
    },
    'http://sapegin.github.io/social-likes/', {
        user: '******',
        repo: 'social-likes'
    }
]);
Example #7
0
File: lte.js Project: bebraw/funkit
var suite = require('suite.js');
var f = require('funkit/ops');

suite(f.lte, [
    [3, 2], true,
    [3, 3], true,
    [2, 3], false
]);
Example #8
0
var suite = require('suite.js');
var g = require('generators.js');
var f = require('funkit/array');
var equals = require('funkit/ops/equals');

suite._amount = 1000;
suite._generator = g.any;

suite(f.chunk, function(op, len, arr) {
    return equals(f.flatten(op(len, arr)), arr);
});
Example #9
0
var suite = require('suite.js');
var f = require('funkit/functional');

suite(f.count, [
    [[1, 2, 3]], 3,
    [[]], 0,
    [{}], 0,
    [{a: 1, b: 2}], 2
]);
Example #10
0
var suite = require('suite.js');
var f = require('funkit/string');

suite(f.reverse, [
    'foobar', 'raboof',
    '', '',
    'FOOBAR', 'RABOOF'
]);
Example #11
0
var suite = require('suite.js');
var g = require('generators.js');
var f = require('funkit');

suite(f.ops.equals, suite.generate(1000,
    [g.structure],
    function(op, a) {
        return op(a, a);
    }
));

suite(f.partial(f.ops.equals, []), [
    {}, false,
    [[]], true,
    [[3]], false
]);

suite(f.partial(f.ops.equals, {}), [
    [[]], false
]);

suite(f.partial(f.ops.equals, [{a: 2}]), [
    [[{a: 2}]], true,
    {0: {a: 2}}, false
]);

suite(f.partial(f.ops.equals, [1, 2, 3]), [
    [[1, 2, 3]], true,
    [[1, 2, 3, 5]], false
]);
Example #12
0
var suite = require('suite.js');
var f = require('funkit/functional');

suite(f.ziptoo, [
    [[['a', 1], ['b', 2], ['c', 3]]], {a: 1, b: 2, c: 3}
]);
Example #13
0
File: gt.js Project: bebraw/funkit
var suite = require('suite.js');
var f = require('funkit/ops');

suite(f.gt, [
    [3, 2], false,
    [3, 3], false,
    [2, 3], true
]);
Example #14
0
var suite = require('suite.js');
var arr = require('funkit/array');
var f = require('funkit/math');

suite(f.between, function(op, val, a, b) {
    return op(val, a, b) == (arr.index(val, f.range(a, b + 1)) >= 0);
});
Example #15
0
File: sin.js Project: bebraw/funkit
var suite = require('suite.js');
var f = require('funkit/math');

suite(f.sin, function(op, a) {
    return f.between(op(a), -1, 1);
});
Example #16
0
var suite = require('suite.js');

var convertTag = require('../lib/convert_tag');

suite(convertTag, [
    'foo', 'Foo',
    'self help', 'Self Help',
    'self-help', 'Self-help',
    'another self help', 'Another Self Help',
    'another-self-help', 'Another-self-help',
    'SciFi', 'Scifi',
    'SciFiToo', 'Scifitoo',
    'sci-fi', 'Sci-fi'
]);
Example #17
0
var suite = require('suite.js');
var f = require('funkit/array');

// TODO: figure out a nicer invariant for this
suite(f.index, function(op, item, arr) {
    return op(item, arr) >= -1;
});
Example #18
0
#!/usr/bin/env node
var suite = require('suite.js');
var g = require('./generators');
var f = require('funkit');

suite(f.sum, suite.generate(1000, [g.number(100), g.number(100)], commutativity));
suite(f.reverse, suite.generate(1000, [g.word(10)], reversability));

function commutativity(op, a, b) {
    if(isNaN(a) && isNaN(b)) return true; // NaN == evaluates as false always

    return op(a, b) == op(b, a);
}

function reversability(op, a) {
    return op(op(a)) == a;
}

gSuite(g.any, function(res) {
    return true;
});
gSuite(g.array, f.isArray);
gSuite(g.object, f.isObject);
gSuite(g.number(), f.isNumber);
gSuite(g.number(100), f.isNumber);
gSuite(g.number(20, 30), f.partial(f.between, 20, 30));
gSuite(g.upperCharacter, charCodeBetween(65, 90));
gSuite(g.lowerCharacter, charCodeBetween(97, 122));
gSuite(g.character, charCodeBetween(33, 126));
gSuite(g.word(10), function(res) {
    return res.length == 10 && allBetween(res, 33, 126);
Example #19
0
var suite = require('suite.js');
var f = require('funkit');

suite(f.partial(f.string.split, '='), [
    'bar=foo', ['bar', 'foo'],
    'bar', ['bar'],
    'bar=foo=bar', ['bar', 'foo', 'bar']
]);
Example #20
0
var suite = require('suite.js');
var f = require('funkit/object');

suite(f.keys, [
    {a: 2, b: 23, c: 31}, ['a', 'b', 'c']
]);
Example #21
0
var noDispatch = annotate('noDispatch', 'No dispatch');

var WARNINGS = parseInt(process.env.YIELD_WARNINGS, 10);


if(WARNINGS) {
    noDispatch(); // should yield a warning (no operation)
}

var addNumber = annotate('addNumber').on(is.number, add);
aSuite(addNumber, '', [[is.number]], [], 'addNumber');

if(WARNINGS) {
    suite(addNumber, [
        [1, 'a'], '1a'
    ]);

    addNumber('foo', 'bar'); // should yield a warning
}

var addNumbers = annotate('addNumbers', 'Adds numbers')
    .on(is.number, is.number, add)
    .satisfies(is.number);
aSuite(addNumbers, 'Adds numbers', [[is.number, is.number]], [is.number], 'addNumbers');

suite(addNumbers, [
    [1, 2], 3
]);

var addString = annotate().on(is.string, add);
Example #22
0
File: map.js Project: bebraw/funkit
var assert = require('assert');
var suite = require('suite.js');
var f = require('funkit');
var is = require('is-js');

suite(suite.async(f.partial(f.async.map, getName)), [
    [['1', '2', '3']], ['1', '2', '3']
]);

function getName(name, done, i) {
    assert(is.number(i));
    done(null, name);
}
Example #23
0
#!/usr/bin/env node
var suite = require('suite.js');
var is = require('is-js');
var partial = require('funkit').partial;
var annotate = require('./annotate');

var noDispatch = annotate('noDispatch', 'No dispatch');
noDispatch(); // should yield a warning (no operation)

var addNumber = annotate('addNumber').on(is.number, add);
aSuite(addNumber, '', [[is.number]], [], 'addNumber');
suite(addNumber, [
    [1, 'a'], '1a'
]);

addNumber('foo', 'bar'); // should yield a warning

var addNumbers = annotate('addNumbers', 'Adds numbers')
    .on(is.number, is.number, add)
    .satisfies(is.number);
aSuite(addNumbers, 'Adds numbers', [[is.number, is.number]], [is.number], 'addNumbers');
suite(addNumbers, [
    [1, 2], 3
]);

var addString = annotate().on(is.string, add);
aSuite(addString, '', [[is.string]], [], '');
suite(addString, [
    ['a', 1], 'a1'
]);
Example #24
0
'use strict';
var suite = require('suite.js');

var analyze = require('../lib/analyze');
var treeify = require('../lib/tree').ify;

suite(analyze, [
  [['a']], [{l: '', r: 'a'}],
  [['a', 'b']], [{l: '', r: 'a'}, {l: '', r: 'b'}],
  [['  a']], [{l: '  ', r: 'a'}],
  [['a', '  b']], [{l: '', r: 'a'}, {l: '  ', r: 'b'}]
]);

suite(analyzeAndTreeify, {
  '': [],
  'a': [{name: 'a', children: [], parent: null, ind: 0}]
  // TODO: figure out a smarter way to test this. parent is ref to actual ob!!!
  // perhaps it's possible to eliminate parent ref here?
  //'a,  b': [{name: 'a', children: [{name: 'b', parent: null}], parent: null, ind: 0}]
});

function analyzeAndTreeify(a) {
  return treeify(analyze([a]));
}
Example #25
0
var suite = require('suite.js');
var f = require('funkit/string');

suite(f.title, [
    'foobar', 'Foobar',
    'foobar foobar', 'Foobar Foobar',
    'FOOBAR', 'Foobar'
]);