Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ test("should return false for an improper fraction (numerator > denominator)", (
expect(isProperFraction(5, 2)).toEqual(false);
});

// Case 3: Negative fraction
test("should return true for a negative proper fraction (numerator < denominator)", () => {
expect(isProperFraction(-4, 7)).toEqual(true);
});
// // Case 3: Negative fraction
// test("should return true for a negative proper fraction (numerator < denominator)", () => {
// expect(isProperFraction(-4, 7)).toEqual(true);
// });
Comment on lines +14 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code submitted to a PR should be free of any unused code. Keeping code clean makes code easier to review.

Should you ever need this code in the future, you can recover or access the code from previous commits. Whenever we make a commit, Git "save a copy of the whole repository" when the commit was made.


// Case 4: Numerator equal to denominator
test("should return false when numerator equals denominator", () => {
Expand All @@ -26,7 +26,29 @@ test("should return true when numerator is zero", () => {
expect(isProperFraction(0, 5)).toEqual(true);
});

// Case 5: Negative denominator
test("should return true when denominator is negative and proper", () => {
expect(isProperFraction(2, -5)).toEqual(true);
// // Case 5: Negative denominator
// test("should return true when denominator is negative and proper", () => {
// expect(isProperFraction(2, -5)).toEqual(true);
// });

//handle all negative number scenarios

test("should correctly handle all negative number scenarios", () => {
const cases = [
// Proper negatives (absolute numerator < absolute denominator)
[-4, 7, true, "-4/7 proper fraction"],
[4, -7, true, "4/-7 proper fraction"],
[-2, -5, true, "-2/-5 proper fraction"],

// Improper negatives (absolute numerator >= absolute denominator)
[-5, 2, false, "-5/2 improper fraction"],
[5, -2, false, "5/-2 improper fraction"],
[-7, -4, false, "-7/-4 improper fraction"],

// Edge equal case
[-3, -3, false, "-3/-3 equal fraction"],
];
Comment on lines +48 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also consider checking -3/3 and 3/-3.

for (const [num, den, expected, desc] of cases) {
expect(isProperFraction(num, den)).toBe(expected);
}
});