Skip to content

Commit ba56e2b

Browse files
committed
Refactor isProperFraction function logic and add tests for edge cases with mixed signs
1 parent 0a44277 commit ba56e2b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
return numerator > 0 && denominator > 0 && numerator < denominator;
14+
return Math.abs(numerator) < Math.abs(denominator);
1515
}
1616

1717
// The line below allows us to load the isProperFraction function into tests in other files.

Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,9 @@ test(`should evaluate correctly with various negative number combinations`, () =
3232
expect(isProperFraction(-5, 2)).toEqual(false);
3333
expect(isProperFraction(5, -2)).toEqual(false);
3434
});
35+
36+
test(`should handle edge cases with mixed signs correctly`, () => {
37+
expect(isProperFraction(4, -7)).toEqual(true);
38+
expect(isProperFraction(-4, -7)).toEqual(true);
39+
expect(isProperFraction(-4, 7)).toEqual(true);
40+
});

0 commit comments

Comments
 (0)