parser-combinator
Version:
Parser combinators
147 lines (127 loc) • 4.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _option = require('../../lib/data/option');
var _option2 = _interopRequireDefault(_option);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
======== A Handy Little Nodeunit Reference ========
https://github.com/caolan/nodeunit
Test methods:
test.expect(numAssertions)
test.done()
Test assertions:
test.ok(value, [message])
test.equal(actual, expected, [message])
test.notEqual(actual, expected, [message])
test.deepEqual(actual, expected, [message])
test.notDeepEqual(actual, expected, [message])
test.strictEqual(actual, expected, [message])
test.notStrictEqual(actual, expected, [message])
test.throws(block, [error], [message])
test.doesNotThrow(block, [error], [message])
test.ifError(value)
*/
exports.default = {
setUp: function setUp(done) {
done();
},
'option empty': function optionEmpty(test) {
test.expect(1);
// tests here
test.equal(_option2.default.none().isPresent(), false, 'should be empty option.');
test.done();
},
'option not empty': function optionNotEmpty(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).isPresent(), true, 'should not be empty option.');
test.done();
},
'option empty mapped': function optionEmptyMapped(test) {
test.expect(1);
// tests here
test.equal(_option2.default.none().map(function (a) {
return a;
}).isPresent(), false, 'should be empty option.');
test.done();
},
'option not empty mapped': function optionNotEmptyMapped(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).map(function (a) {
return a;
}).get(), 12, 'should not be empty option.');
test.done();
},
'option not empty flat mapped to option': function optionNotEmptyFlatMappedToOption(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).flatmap(function (a) {
return _option2.default.some(a);
}).get(), 12, 'should not be empty option.');
test.done();
},
'option empty flat mapped': function optionEmptyFlatMapped(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some().flatmap(function (a) {
return a;
}).isPresent(), false, 'should be empty option.');
test.done();
},
'option empty or else': function optionEmptyOrElse(test) {
test.expect(1);
// tests here
test.equal(_option2.default.none().orElse(12), 12, 'should be empty option.');
test.done();
},
'option not empty or else': function optionNotEmptyOrElse(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).orElse(14), 12, 'should be not empty option.');
test.done();
},
'option empty or lazy else': function optionEmptyOrLazyElse(test) {
test.expect(1);
// tests here
test.equal(_option2.default.none().orLazyElse(function () {
return 12;
}), 12, 'should be empty option.');
test.done();
},
'option not empty or lazy else': function optionNotEmptyOrLazyElse(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).orLazyElse(function () {
return 14;
}), 12, 'should be not empty option.');
test.done();
},
'option empty filter': function optionEmptyFilter(test) {
test.expect(1);
// tests here
test.equal(_option2.default.none().filter(function (v) {
return v === 1;
}).isPresent(), false, 'should be empty option.');
test.done();
},
'option not empty filter': function optionNotEmptyFilter(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).filter(function (v) {
return v === 12;
}).get(), 12, 'should be not empty option.');
test.done();
},
'option not empty wrong filter': function optionNotEmptyWrongFilter(test) {
test.expect(1);
// tests here
test.equal(_option2.default.some(12).filter(function (v) {
return v === 13;
}).isPresent(), false, 'should be empty option.');
test.done();
}
};
//# sourceMappingURL=option_test.js.map