|
3 | 3 | const isProperFraction = require("../implement/2-is-proper-fraction"); |
4 | 4 |
|
5 | 5 |
|
6 | | -// Special case: numerator is zero |
7 | | -test(`should return false when denominator is zero`, () => { |
8 | | - expect(isProperFraction(1,2 )).toEqual(true); |
9 | | - expect(isProperFraction(2,1)).toEqual(false); |
10 | | - expect(isProperFraction(5,5)).toEqual(false); |
11 | | - expect(isProperFraction(0,5)).toEqual(true); |
12 | | - expect(isProperFraction(5,0)).toEqual(false); |
13 | | - expect(isProperFraction(0,0)).toEqual(false); |
14 | | - expect(isProperFraction(-1,2)).toEqual(true); |
15 | | - expect(isProperFraction(1,-2)).toEqual(false); |
16 | | - expect(isProperFraction(-2,-1)).toEqual(true); |
17 | | - expect(isProperFraction(-1,-2)).toEqual(false); |
18 | | - expect(isProperFraction(0.5,1)).toEqual(true); |
19 | | - expect(isProperFraction(1.5,1)).toEqual(false); |
20 | | - expect(isProperFraction(Infinity,2)).toEqual(false); |
21 | | - expect(isProperFraction(2,Infinity)).toEqual(false); |
22 | | - expect(isProperFraction(NaN,2)).toEqual(false) |
23 | | - expect(isProperFraction(2,NaN)).toEqual(false); |
24 | | - expect(isProperFraction(999999999, 1000000000)).toEqual(true) |
25 | | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | | - |
31 | | - |
32 | | - |
| 6 | +test("should correctly identify proper fractions", () => { |
| 7 | + // Whole number fractions |
| 8 | + expect(isProperFraction(1, 2)).toEqual(true); |
| 9 | + expect(isProperFraction(2, 1)).toEqual(false); |
| 10 | + expect(isProperFraction(5, 5)).toEqual(false); |
| 11 | + |
| 12 | + // Zero |
| 13 | + expect(isProperFraction(0, 5)).toEqual(true); |
| 14 | + expect(isProperFraction(5, 0)).toEqual(false); |
| 15 | + expect(isProperFraction(0, 0)).toEqual(false); |
| 16 | + |
| 17 | + // Negative numbers |
| 18 | + expect(isProperFraction(-1, 2)).toEqual(true); |
| 19 | + expect(isProperFraction(1, -2)).toEqual(false); |
| 20 | + expect(isProperFraction(-2, -1)).toEqual(true); |
| 21 | + expect(isProperFraction(-1, -2)).toEqual(false); |
| 22 | + |
| 23 | + // Decimal numbers |
| 24 | + expect(isProperFraction(0.5, 1)).toEqual(true); |
| 25 | + expect(isProperFraction(1.5, 1)).toEqual(false); |
| 26 | + |
| 27 | + // Infinity |
| 28 | + expect(isProperFraction(Infinity, 2)).toEqual(false); |
| 29 | + expect(isProperFraction(2, Infinity)).toEqual(false); |
| 30 | + |
| 31 | + // NaN |
| 32 | + expect(isProperFraction(NaN, 2)).toEqual(false); |
| 33 | + expect(isProperFraction(2, NaN)).toEqual(false); |
| 34 | + |
| 35 | + // Large numbers |
| 36 | + expect(isProperFraction(999999999, 1000000000)).toEqual(true); |
33 | 37 | }); |
0 commit comments