@ -6,7 +6,8 @@ test('Testing binarySearch', (t) => {
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof binarySearch === 'function', 'binarySearch is a Function');
|
||||
//t.deepEqual(binarySearch(args..), 'Expected');
|
||||
//t.equal(binarySearch(args..), 'Expected');
|
||||
t.equal(binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 6), 2, 'Finds item in array');
|
||||
t.equal(binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 21), -1, 'Returns -1 when not found');
|
||||
//t.false(binarySearch(args..), 'Expected');
|
||||
//t.throws(binarySearch(args..), 'Expected');
|
||||
t.end();
|
||||
|
||||
@ -6,7 +6,7 @@ test('Testing call', (t) => {
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof call === 'function', 'call is a Function');
|
||||
//t.deepEqual(call(args..), 'Expected');
|
||||
//t.equal(call(args..), 'Expected');
|
||||
t.looseEqual(call('map', x => x * 2)([1, 2, 3]), [2, 4, 6], 'Calls function on given object');
|
||||
//t.false(call(args..), 'Expected');
|
||||
//t.throws(call(args..), 'Expected');
|
||||
t.end();
|
||||
|
||||
@ -6,8 +6,25 @@ test('Testing chainAsync', (t) => {
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof chainAsync === 'function', 'chainAsync is a Function');
|
||||
//t.deepEqual(chainAsync(args..), 'Expected');
|
||||
//t.equal(chainAsync(args..), 'Expected');
|
||||
// chainAsync([
|
||||
// next => {
|
||||
// next();
|
||||
// },
|
||||
// next => {
|
||||
// (() =>{
|
||||
// next()
|
||||
// })();
|
||||
// },
|
||||
// next => {
|
||||
// t.pass("Calls all functions in an array");
|
||||
// next();
|
||||
// }
|
||||
// ]);
|
||||
//
|
||||
// // Ensure we wait for the 2nd assertion to be made
|
||||
// t.plan(2);
|
||||
|
||||
//t.false(chainAsync(args..), 'Expected');
|
||||
//t.throws(chainAsync(args..), 'Expected');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
@ -6,7 +6,18 @@ test('Testing collatz', (t) => {
|
||||
//Please go to https://github.com/substack/tape
|
||||
t.true(typeof collatz === 'function', 'collatz is a Function');
|
||||
//t.deepEqual(collatz(args..), 'Expected');
|
||||
//t.equal(collatz(args..), 'Expected');
|
||||
t.equal(collatz(8), 4, 'When n is even, divide by 2');
|
||||
t.equal(collatz(9), 28, 'When n is odd, times by 3 and add 1');
|
||||
|
||||
let n = 9;
|
||||
while(true){
|
||||
if (n == 1){
|
||||
t.pass('Eventually reaches 1');
|
||||
break;
|
||||
}
|
||||
n = collatz(n);
|
||||
}
|
||||
|
||||
//t.false(collatz(args..), 'Expected');
|
||||
//t.throws(collatz(args..), 'Expected');
|
||||
t.end();
|
||||
|
||||
Reference in New Issue
Block a user