-
-
Notifications
You must be signed in to change notification settings - Fork 239
Glasgow | 25-ITP-SEP | Alaa Tagi | Sprint 3 | Coursework/sprint 3 implement and rewrite #756
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?
Glasgow | 25-ITP-SEP | Alaa Tagi | Sprint 3 | Coursework/sprint 3 implement and rewrite #756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the Jest test scripts has not been updated accordingly.
| if (angle < 90 && angle > 0) { | ||
| return "Acute angle"; | ||
| } | ||
| if (angle > 90 && angle < 180) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checking angle > 90 is optional because previous if-statements can guarantee angle is always more than 90.
| if (numerator < denominator) { | ||
| return true; | ||
| } | ||
| if (numerator < 0 && Math.abs(numerator) < denominator) { | ||
| return false; | ||
| } | ||
| if (numerator >= denominator) { | ||
| return false; | ||
| } | ||
| // we could add more checks here for invalid input, but not required for this exercise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the definition of proper fraction in mathematics:
isProperFraction(-4, 3)should returnfalseisProperFraction(-2, 5)should returntrueisProperFraction(-1, 1)should returnfalseisProperFraction(-2, -3)should returntrue
Can you look up the definition of proper fraction and update your function accordingly?
| test("should return false for equal numerator and denominator", () => { | ||
| expect(isProperFraction(3, 3)).toEqual(false); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each test, we could include multiple test cases that belong to the same category to make the test more complete in the following way:
test("should return false for equal numerator and denominator", () => {
expect(isProperFraction(3, 3)).toEqual(false);
expect(isProperFraction(-3, 3)).toEqual(false);
expect(isProperFraction(3, -3)).toEqual(false);
expect(isProperFraction(-3, -3)).toEqual(false);
});| test("should return false for a negative fraction", () => { | ||
| expect(isProperFraction(-1, 2)).toEqual(true); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test description does not quite match the specified test.
|
Changes look good but not all comments had been addressed. |
Expanded test cases for isProperFraction function to include various scenarios such as negative fractions, zero numerator, negative denominator, and large numbers.
Refactor isProperFraction function to include input type checks and handle division by zero. Update logic to determine if a fraction is proper based on the value of the numerator and denominator.
Updated test cases for isProperFraction function to improve clarity and coverage. Added detailed descriptions for each test case.
|
There are three files in the "rewrite" folder and you updated only two of them. |
|
@cjyuan, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have face unusal issue. the third file was showing on my VScode but not on my PR. when back to check I had a conflict message. There were unstaged files that's why I had this issue.
Is a good opportunity to learn resolving conflict. :)
If you have backed up your files, then the worst that could happen is that you need to submit a new PR.
| test("should return 7 for 7 of Hearts", () => { | ||
| const sevenOfHearts = getCardValue("7♥"); | ||
| expect(sevenOfHearts).toEqual(7); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When preparing tests, we should ensure the tests cover all possible cases. If we specify a test for individual card, we will need about 53 tests to cover all possible cases. Instead, we could consider classifying all possible values into different categories, and then within each category we test some samples.
For example, one possible category for getCardValue() is, "should return the value of number cards (2-10)", and we can prepare the test as
test("should return the value of number cards (2-10)", () => {
expect(getCardValue("2♣︎")).toEqual(2);
expect(getCardValue("5♠")).toEqual(5);
expect(getCardValue("10♥")).toEqual(10);
// Note: We could also use a loop to check all values from 2 to 10.
});
| test("should return 10 for Jack of Diamonds", () => { | ||
| const jackOfDiamonds = getCardValue("J♦"); | ||
| expect(jackOfDiamonds).toEqual(10); | ||
| }); | ||
|
|
||
| //Case 4 | ||
| test("should return 10 for Queen of Clubs", () => { | ||
| const queenOfClubs = getCardValue("Q♣"); | ||
| expect(queenOfClubs).toEqual(10); | ||
| }); | ||
|
|
||
| test("should return 10 for King of Spades", () => { | ||
| const kingOfSpades = getCardValue("K♠"); | ||
| expect(kingOfSpades).toEqual(10); | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Face cards (J, Q, K) can also be considered a category
-
The function is not expected to check the suit character. Mentioning the suit character in the test description could send the wrong signal to the person implementing the function.
|
Have you double checked what you changed? |
| <<<<<<< HEAD | ||
| // Case 2: Improper fraction | ||
| // When numerator > denominator, it should return false. | ||
| test("should return false for an improper fraction", () => { | ||
| ======= | ||
| // Case 2: Improper Fraction | ||
| // Given a numerator greater than denominator (5/2), | ||
| // When the function is called, | ||
| // Then it should return false because it's an improper fraction. | ||
| test("should return false for an improper fraction (5/2)", () => { | ||
| >>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The <<<<<<< HEAD, =======, and >>>>>>> are markers added by Git to show the difference between two versions of a conflicting file.
The difference between the two versions of the conflicting file are indicated by these markers as:
<<<<<<< HEAD
Content from version A
=======
Content from version B
>>>>>>> 52740052fb0ad97a2c7253a04978b14a15b9e763
Note: In your file, the long hexadecimal number following >>>>>>>> is probably the commit SHA of version B.
To resolve the conflict, you will need to manually delete all the unwanted content and the markers in an editor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cjyuan, I have delete it
Learners, PR Template
Self checklist
Changelist
I have created a PR with completed tasks as required.
Questions
No questions.