Skip to content

Commit 7e99eac

Browse files
Update isProperFraction function
1 parent 8c8e6b1 commit 7e99eac

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

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

Lines changed: 4 additions & 4 deletions
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 numerator >= 0 && denominator > 0 && numerator < denominator;
1515
}
1616

1717
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -46,9 +46,9 @@ assertEquals(isProperFraction(4, 4), false);
4646
assertEquals(isProperFraction(10, 5), false);
4747
assertEquals(isProperFraction(100, 99), false);
4848

49-
// Edge cases with zero - should return false
50-
assertEquals(isProperFraction(0, 5), false);
51-
assertEquals(isProperFraction(0, 1), false);
49+
// Edge cases with zero numerator - should return true
50+
assertEquals(isProperFraction(0, 5), true);
51+
assertEquals(isProperFraction(0, 1), true);
5252

5353
// Negative numbers - should return false
5454
assertEquals(isProperFraction(-1, 2), false);

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
55
// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories.
66

77
// Proper fractions - should return true
8-
test(`should return true for proper fractions (0 < numerator < denominator)`, () => {
8+
test(`should return true for proper fractions (0 <= numerator < denominator)`, () => {
99
expect(isProperFraction(1, 2)).toEqual(true);
1010
expect(isProperFraction(3, 4)).toEqual(true);
1111
expect(isProperFraction(1, 5)).toEqual(true);
1212
expect(isProperFraction(2, 3)).toEqual(true);
1313
expect(isProperFraction(5, 8)).toEqual(true);
1414
expect(isProperFraction(1, 100)).toEqual(true);
15+
expect(isProperFraction(0, 5)).toEqual(true);
1516
});
1617

1718
// Improper fractions - should return false
@@ -23,11 +24,11 @@ test(`should return false for improper fractions (numerator >= denominator)`, ()
2324
expect(isProperFraction(100, 99)).toEqual(false);
2425
});
2526

26-
// Edge cases with zero - should return false
27-
test(`should return false when numerator is zero`, () => {
28-
expect(isProperFraction(0, 5)).toEqual(false);
29-
expect(isProperFraction(0, 1)).toEqual(false);
30-
expect(isProperFraction(0, 100)).toEqual(false);
27+
// Edge cases with zero numerator - should return true
28+
test(`should return true when numerator is zero and denominator is positive`, () => {
29+
expect(isProperFraction(0, 5)).toEqual(true);
30+
expect(isProperFraction(0, 1)).toEqual(true);
31+
expect(isProperFraction(0, 100)).toEqual(true);
3132
});
3233

3334
// Special case: denominator is zero

0 commit comments

Comments
 (0)