Migrated tests to jest

Used jest-codemods to migrate, will have to pass everything by hand before we can merge.
This commit is contained in:
Angelos Chalaris
2018-06-18 14:18:25 +03:00
parent 63ec2596cf
commit a59af893bf
890 changed files with 6950 additions and 6921 deletions

View File

@ -1,29 +0,0 @@
const solveRPN = rpn => {
const OPERATORS = {
'*': (a, b) => a * b,
'+': (a, b) => a + b,
'-': (a, b) => a - b,
'/': (a, b) => a / b,
'**': (a, b) => a ** b
};
const [stack, solve] = [
[],
rpn
.replace(/\^/g, '**')
.split(/\s+/g)
.filter(el => !/\s+/.test(el) && el !== '')
];
solve.forEach(symbol => {
if (!isNaN(parseFloat(symbol)) && isFinite(symbol)) {
stack.push(symbol);
} else if (Object.keys(OPERATORS).includes(symbol)) {
const [a, b] = [stack.pop(), stack.pop()];
stack.push(OPERATORS[symbol](parseFloat(b), parseFloat(a)));
} else {
throw `${symbol} is not a recognized symbol`;
}
});
if (stack.length === 1) return stack.pop();
else throw `${rpn} is not a proper RPN. Please check it and try again`;
};
module.exports = solveRPN;

View File

@ -1,13 +0,0 @@
const test = require('tape');
const solveRPN = require('./solveRPN.js');
test('Testing solveRPN', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof solveRPN === 'function', 'solveRPN is a Function');
//t.deepEqual(solveRPN(args..), 'Expected');
//t.equal(solveRPN(args..), 'Expected');
//t.false(solveRPN(args..), 'Expected');
//t.throws(solveRPN(args..), 'Expected');
t.end();
});