Tests for collatz()

This commit is contained in:
Oscar Shrimpton
2018-01-30 19:41:04 +00:00
parent 19003bde90
commit aa46883a4b

View File

@ -6,7 +6,18 @@ test('Testing collatz', (t) => {
//Please go to https://github.com/substack/tape //Please go to https://github.com/substack/tape
t.true(typeof collatz === 'function', 'collatz is a Function'); t.true(typeof collatz === 'function', 'collatz is a Function');
//t.deepEqual(collatz(args..), 'Expected'); //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.false(collatz(args..), 'Expected');
//t.throws(collatz(args..), 'Expected'); //t.throws(collatz(args..), 'Expected');
t.end(); t.end();