Skip to content

London | 26-ITP-SEPT | Carol Nassuna | Sprint 2 | Implement and rewrite tests - #1692

Open
Mugs3 wants to merge 3 commits into
CodeYourFuture:mainfrom
Mugs3:Sprint-2
Open

Mugs3 wants to merge 3 commits into
CodeYourFuture:mainfrom
Mugs3:Sprint-2

Conversation

@Mugs3

@Mugs3 Mugs3 commented Oct 13, 2026 •

Copy link
Copy Markdown
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1059

Changelist

19/11 - updated the declaration proper fraction file with a maths method to accommodate more test cases. Also updated the respective test files
21/10 - updated invalid range and description in the get and angle file and reworked negative case in the proper fraction file

Uploaded implement and rewrite tests coursework

@github-actions

This comment has been minimized.

@Mugs3 Mugs3 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 13, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good.

It seems you might have misunderstood the definition of proper fraction.

Comment on lines +45 to +50
test(`should return "Invalid angle" when (angle === Invalid)`, () => {
// Test various invalid angles, including boundary cases
expect(getAngleType(361)).toEqual("Invalid angle");
expect(getAngleType(0)).toEqual("Invalid angle");
expect(getAngleType(-181)).toEqual("Invalid angle");
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • "(angle === Invalid)" does not quite tell which angles are considered invalid.

  • 0 is a good boundary case to check. Could you think of the other boundary case?

Comment on lines +20 to +23
// Special case: numerator is negative number
test(`should return true when denominator is 1`, () => {
expect(isProperFraction(-1, 1)).toEqual(false);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 / 1, which is equal to -1, is not a proper fraction.

Could you look up the definition of "proper fraction" and then update the tests and your function implementation?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 19, 2026
…eworked negative case in the proper fraction file
@Mugs3 Mugs3 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 21, 2026
@cjyuan

cjyuan commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

May I ask which authoritative source you used for the definition of a proper fraction?

Are $\frac{-2}{3}$, $\frac{2}{-3}$ (which equals to $-\frac{2}{3}$) and $\frac{-2}{-3}$ (which equals to $\frac{2}{3}$) proper fractions?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 23, 2026
@Mugs3

Mugs3 commented Oct 29, 2026 via email

Copy link
Copy Markdown
Author

@cjyuan

cjyuan commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

the negative sign is ignored and only numbers are compared in which case

Yes. That's the way to determine if a fraction involving negative numbers is proper or not.

I raised the question because your implementation does not agree with your tests.


Also, the test description "should return true when denominator is two" could be misleading because
1/2 is a proper fraction but 3/2 is not a proper fraction. Instead, you could describe the condition in terms of numerator and denominator.

@Mugs3

Mugs3 commented Oct 29, 2026 via email

Copy link
Copy Markdown
Author

@cjyuan

cjyuan commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

The description "should return true when denominator is two" is misleading because it could describe any of these fractions, 1/2, 3/2, -2/2, -3/2, -1/2, etc.

A more specific description could be "should return true for 1/2".

Alternatively, you could consider classifying test cases into categories and test samples in each category. For example,

// Note: abs(x) means absolute value of x.
test(`should return true when abs(numerator) < abs(denominator)`, () => {
  expect(isProperFraction(1, 2)).toEqual(true);
  expect(isProperFraction(-1, 2)).toEqual(true);
  expect(isProperFraction(1, -2)).toEqual(true);
  expect(isProperFraction(-1, -2)).toEqual(true);      
});

@Mugs3

Mugs3 commented Nov 2, 2026 via email

Copy link
Copy Markdown
Author

@cjyuan

cjyuan commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

If the tests do not pass, that means either the test or the function implementation, or both are incorrect.

Have you checked if your function works as expected?

@Mugs3 Mugs3 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 18, 2026
@Mugs3

Mugs3 commented Nov 18, 2026 via email

Copy link
Copy Markdown
Author

@cjyuan

cjyuan commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

What's wrong about this test? If this test is correct, that would mean the function is wrong.

test(`should return true when abs(numerator) < abs(denominator)`, () => {
  expect(isProperFraction(1, 2)).toEqual(true);
  expect(isProperFraction(-1, 2)).toEqual(true);
  expect(isProperFraction(1, -2)).toEqual(true);
  expect(isProperFraction(-1, -2)).toEqual(true);
});

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 19, 2026
@cjyuan

cjyuan commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Still waiting for you to respond to the latest comment.

@Mugs3 Mugs3 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 19, 2026
@Mugs3

Mugs3 commented Nov 19, 2026 via email

Copy link
Copy Markdown
Author

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants