Skip to content

Commit

Permalink
copilot first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdralston committed Mar 11, 2024
1 parent ac436f7 commit f4126ea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions skills.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function calculateNumbers(a, b) {
if (typeof a !== 'number' || typeof b !== 'number') {
throw new Error('Both arguments must be numbers');
}

if (isNaN(a) || isNaN(b)) {
throw new Error('Arguments must not be NaN');
}

if (!isFinite(a) || !isFinite(b)) {
throw new Error('Arguments must be finite numbers');
}

return a + b;
}

module.exports = { calculateNumbers };
20 changes: 20 additions & 0 deletions skills.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Import the function from the module where it's defined
const { calculateNumbers } = require('./skills');

describe('calculateNumbers', () => {
test('adds positive numbers correctly', () => {
expect(calculateNumbers(1, 2)).toBe(3);
});

test('adds negative numbers correctly', () => {
expect(calculateNumbers(-1, -2)).toBe(-3);
});

test('adds zero correctly', () => {
expect(calculateNumbers(0, 2)).toBe(2);
});

test('adds floating point numbers correctly', () => {
expect(calculateNumbers(1.2, 3.4)).toBeCloseTo(4.6);
});
});

0 comments on commit f4126ea

Please sign in to comment.