Skip to content

Commit f312338

Browse files
committed
fix isProperFraction per reviewer feedback
1 parent 075e91a commit f312338

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test("Improper fraction (numerator > denominator)", () => {
88
});
99

1010
test("Zero cases", () => {
11-
assert.equal(isProperFraction(0, 1), true);
11+
assert.equal(isProperFraction(0, 1), false);
1212
assert.equal(isProperFraction(1, 0), false);
1313
assert.equal(isProperFraction(0, 0), false);
1414
});
@@ -18,12 +18,11 @@ test("Equal numerator and denominator", () => {
1818
});
1919

2020
test("Negative cases", () => {
21-
assert.equal(isProperFraction(-2, 1), true);
21+
assert.equal(isProperFraction(-2, 1), false);
2222
assert.equal(isProperFraction(1, -2), false);
23-
assert.equal(isProperFraction(-1, -2), false);
23+
assert.equal(isProperFraction(-1, -2), true);
2424
});
2525

2626
test("Basic proper fraction", () => {
27-
// Example: 1/2 is a proper fraction
2827
assert.equal(isProperFraction(1, 2), true);
2928
});
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export function isProperFraction(numerator, denominator) {
2-
return numerator < denominator;
2+
const value = numerator / denominator;
3+
return value > 0 && value < 1;
34
}

‎implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ test(`should return false when denominator is zero`, () => {
77
test("Basic proper fraction", () => {
88
expect(isProperFraction(1, 2)).toEqual(true);
99
expect(isProperFraction(2, 1)).toEqual(false);
10-
expect(isProperFraction(-2, 1)).toEqual(true);
10+
expect(isProperFraction(-2, 1)).toEqual(false);
1111
expect(isProperFraction(1, -2)).toEqual(false);
1212
});
1313

@@ -16,7 +16,7 @@ test("Improper fraction (numerator > denominator)", () => {
1616
});
1717

1818
test("Zero cases", () => {
19-
expect(isProperFraction(0, 1)).toEqual(true);
19+
expect(isProperFraction(0, 1)).toEqual(false);
2020
expect(isProperFraction(1, 0)).toEqual(false);
2121
expect(isProperFraction(0, 0)).toEqual(false);
2222
});
@@ -26,7 +26,7 @@ test("Equal numerator and denominator", () => {
2626
});
2727

2828
test("Negative cases", () => {
29-
expect(isProperFraction(-2, 1)).toEqual(true);
29+
expect(isProperFraction(-2, 1)).toEqual(false);
3030
expect(isProperFraction(1, -2)).toEqual(false);
31-
expect(isProperFraction(-1, -2)).toEqual(false);
31+
expect(isProperFraction(-1, -2)).toEqual(true);
3232
});

0 commit comments

Comments
 (0)