Skip to content

Commit

Permalink
Merge pull request #68 from davidchambers/ramda
Browse files Browse the repository at this point in the history
ramda@0.18.x
  • Loading branch information
davidchambers committed Jan 18, 2016
2 parents 89f23ff + b1edda5 commit 17f8194
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 41 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dependencies": {
"coffee-script": "1.10.x",
"jquery": "2.1.x",
"ramda": "0.17.x"
"ramda": "0.18.x"
},
"devDependencies": {
"qunit": "1.19.x"
Expand Down
66 changes: 27 additions & 39 deletions lib/doctest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
options = {};
}
if (callback == null) {
callback = noop;
callback = function() {};
}

var validateOption = function(name, validValues) {
Expand Down Expand Up @@ -85,9 +85,6 @@
// appendTo :: [a] -> a -> [a]
var appendTo = R.flip(R.append);

// compose :: (b -> c) -> (a -> b) -> (a -> c)
var compose = R.curryN(2, R.compose);

// fromMaybe :: a -> [a] -> a
var fromMaybe = R.curry(function(x, maybe) {
return R.isEmpty(maybe) ? x : maybe[0];
Expand All @@ -108,9 +105,6 @@
null;
});

// noop :: * -> ()
var noop = function() {};

// quote :: String -> String
var quote = function(s) {
return "'" + (R.replace(/'/g, "\\'", s)) + "'";
Expand Down Expand Up @@ -189,30 +183,26 @@

// normalizeTest :: { output :: { value :: String } } ->
// { ! :: Boolean, output :: { value :: String } }
var normalizeTest = R.converge(
R.call,
var normalizeTest = function(x) {
var f =
R.pipe(R.of,
R.filter(R.has('output')),
R.map(R.prop('output')),
R.map(R.prop('value')),
R.map(R.match(/^![ ]?([^:]*)(?::[ ]?(.*))?$/)),
R.map(R.ifElse(R.isEmpty,
R.always(R.assoc('!', false)),
R.converge(R.pipe(function(type, message) {
return 'new ' + type +
'(' + message + ')';
},
R.assocPath(['output', 'value']),
compose(R.assoc('!', true))),
R.nth(1),
R.pipe(R.nth(2),
R.of,
R.reject(R.isNil),
R.map(quote),
fromMaybe(''))))),
fromMaybe(R.identity)),
R.identity
);
function(match) {
var s = 'new ' + match[1] + '(' +
(match[2] == null ? '' : quote(match[2])) +
')';
return R.pipe(R.assocPath(['output', 'value'], s),
R.assoc('!', true));
})),
fromMaybe(R.identity));

return f(x)(x);
};


var _commentIndex = R.lensProp('commentIndex');
Expand Down Expand Up @@ -337,9 +327,7 @@
[R.concat(accum[0], chr), true] :
[accum[0], false];
}),
R.converge(R.prepend,
R.pipe(R.head, R.concat(R.head(accum))),
R.tail)
R.over(_1, R.concat(R.head(accum)))
)(line);
}),
R.head
Expand Down Expand Up @@ -433,7 +421,7 @@
// produced by step 6 (substituting "step 6" for "step 2").

var getComments =
R.pipe(R.partialRight(esprima.parse, {comment: true, loc: true}),
R.pipe(R.partialRight(esprima.parse, [{comment: true, loc: true}]),
R.prop('comments'));

// tests :: { blockTests :: [Test], lineTests :: [Test] }
Expand Down Expand Up @@ -534,7 +522,7 @@
},
R.last,
R.map(normalizeTest),
R.map(R.converge(indentN, R.path(['indent', 'length']), wrap.coffee)),
R.map(R.lift(indentN)(R.path(['indent', 'length']), wrap.coffee)),
joinLines
), chunks.commentChunks);

Expand Down Expand Up @@ -612,15 +600,15 @@
return results;
};

var log =
R.converge(noop,
R.pipe(R.map(R.ifElse(R.head, R.always('.'), R.always('x'))),
R.join(''),
R.bind(console.log, console)),
R.pipe(R.reject(R.head),
R.forEach(R.apply(function(pass, actual, expected, num) {
console.log('FAIL: expected ' + expected +
' on line ' + num + ' (got ' + actual + ')');
}))));
var log = function(results) {
console.log(R.join('',
R.map(R.ifElse(R.head, R.always('.'), R.always('x')),
results)));
R.forEach(R.apply(function(pass, actual, expected, num) {
console.log('FAIL: expected ' + expected +
' on line ' + num + ' (got ' + actual + ')');
}),
R.reject(R.head, results));
};

}.call(this, this));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"coffee-script": "1.10.x",
"commander": "2.8.x",
"esprima": "2.6.x",
"ramda": "0.17.x"
"ramda": "0.18.x"
},
"devDependencies": {
"bower": "1.5.x",
Expand Down

0 comments on commit 17f8194

Please sign in to comment.