@@ -11,10 +11,10 @@ test("should return false for an improper fraction (numerator > denominator)", (
1111 expect ( isProperFraction ( 5 , 2 ) ) . toEqual ( false ) ;
1212} ) ;
1313
14- // Case 3: Negative fraction
15- test ( "should return true for a negative proper fraction (numerator < denominator)" , ( ) => {
16- expect ( isProperFraction ( - 4 , 7 ) ) . toEqual ( true ) ;
17- } ) ;
14+ // // Case 3: Negative fraction
15+ // test("should return true for a negative proper fraction (numerator < denominator)", () => {
16+ // expect(isProperFraction(-4, 7)).toEqual(true);
17+ // });
1818
1919// Case 4: Numerator equal to denominator
2020test ( "should return false when numerator equals denominator" , ( ) => {
@@ -26,7 +26,29 @@ test("should return true when numerator is zero", () => {
2626 expect ( isProperFraction ( 0 , 5 ) ) . toEqual ( true ) ;
2727} ) ;
2828
29- // Case 5: Negative denominator
30- test ( "should return true when denominator is negative and proper" , ( ) => {
31- expect ( isProperFraction ( 2 , - 5 ) ) . toEqual ( true ) ;
29+ // // Case 5: Negative denominator
30+ // test("should return true when denominator is negative and proper", () => {
31+ // expect(isProperFraction(2, -5)).toEqual(true);
32+ // });
33+
34+ //handle all negative number scenarios
35+
36+ test ( "should correctly handle all negative number scenarios" , ( ) => {
37+ const cases = [
38+ // Proper negatives (absolute numerator < absolute denominator)
39+ [ - 4 , 7 , true , "-4/7 proper fraction" ] ,
40+ [ 4 , - 7 , true , "4/-7 proper fraction" ] ,
41+ [ - 2 , - 5 , true , "-2/-5 proper fraction" ] ,
42+
43+ // Improper negatives (absolute numerator >= absolute denominator)
44+ [ - 5 , 2 , false , "-5/2 improper fraction" ] ,
45+ [ 5 , - 2 , false , "5/-2 improper fraction" ] ,
46+ [ - 7 , - 4 , false , "-7/-4 improper fraction" ] ,
47+
48+ // Edge equal case
49+ [ - 3 , - 3 , false , "-3/-3 equal fraction" ] ,
50+ ] ;
51+ for ( const [ num , den , expected , desc ] of cases ) {
52+ expect ( isProperFraction ( num , den ) ) . toBe ( expected ) ;
53+ }
3254} ) ;
0 commit comments