-
-
Notifications
You must be signed in to change notification settings - Fork 335
London | 26-ITP-January | Khaliun Baatarkhuu | Sprint 3 | Implement and rewrite tests. #1171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 6 commits
e59bc4c
2ccb877
ea57d66
3a4fd15
f6b6ecb
060fc0d
a4e8008
42e1a89
15f3044
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,37 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); | |
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 0)).toEqual(false); | ||
| }); | ||
|
|
||
| // Proper fractions (positive numbers | ||
| test(`should return true when numerator is smaller than denominator`, () => { | ||
| expect(isProperFraction(1, 2)).toEqual(true); | ||
| expect(isProperFraction(3, 4)).toEqual(true); | ||
| }); | ||
|
|
||
| // Equal numbers → not proper | ||
| test(`should return false when numerator equals denominator`, () => { | ||
| expect(isProperFraction(2, 2)).toEqual(false); | ||
| }); | ||
|
|
||
| // Improper fractions | ||
| test(`should return false when numerator is greater than denominator`, () => { | ||
| expect(isProperFraction(5, 4)).toEqual(false); | ||
| expect(isProperFraction(10, 3)).toEqual(false); | ||
| }); | ||
|
|
||
| // Zero numerator | ||
| test(`should return true when numerator is zero and denominator is non-zero`, () => { | ||
| expect(isProperFraction(0, 5)).toEqual(true); | ||
| }); | ||
|
|
||
| // Negative numbers | ||
| test(`should handle negative numbers correctly`, () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| expect(isProperFraction(1, -2)).toEqual(true); | ||
| expect(isProperFraction(-3, -2)).toEqual(false); | ||
| }); | ||
|
Comment on lines
+13
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use pseudo-code and notations like
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test("|n| < |d| with negative signs → true, |n| > |d| → false", () => {
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this category, when one of the tests fail, it may not be easy to find out whether the function fails to identify proper fraction or improper fraction.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test("|n| < |d| with mixed negative signs → true", () => { test("|n| > |d| with both negative → false", () => { A strategy of separating tests by logic as much as possible helps pinpoint the test failure point better?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| // Both zero | ||
| test(`should return false when both numerator and denominator are zero`, () => { | ||
| expect(isProperFraction(0, 0)).toEqual(false); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.