Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrijk committed Apr 14, 2017
1 parent 4c8db7c commit 12b7679
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Still to implement:

- create generators for all operators:
- and: fails on test '::even?', 0
- keys
- ...
- conformKeys for mapOf
Expand Down
2 changes: 1 addition & 1 deletion lib/conform.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function conform(spec, value) {
if (_.isBoolean(result)) {
return result ? value : invalidString;
} else {
return result ? result : invalidString;
return result !== null ? result : invalidString;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const {sampleFromSpec} = require('./gen');

function exercise(spec, n = 10) {
const samples = [...sampleFromSpec(spec, n)];

return _.map(samples, sample => [sample, conform(spec, sample)]);
}

Expand Down
8 changes: 4 additions & 4 deletions test/and.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
const _ = require('lodash');

const {expect} = require('chai');;

Expand All @@ -15,7 +15,7 @@ describe('Test the and function', () => {

it('should test the and of 2 specs', () => {
s.def('::even?', s.and(isInteger, isEven));
expect(s.conform('::even?', 12)).to.equal(12);
expect(s.conform('::even?', 0)).to.equal(0);
expect(s.conform('::even?', 13)).to.equal(invalidString);
});

Expand All @@ -26,8 +26,8 @@ describe('Test the and function', () => {

it('should implement a generator', () => {
s.def('::even?', s.and(isInteger, isEven));
console.log(s.exercise('::even?', 7));
expect(s.exercise('::even?', 7)).to.have.length(7);
expect(s.exercise('::even?', 7)).to.have.length(7)
.to.satisfy(sample => _.every(sample, ([v]) => isInteger(v) && isEven(v)));
});
});

0 comments on commit 12b7679

Please sign in to comment.