Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
duplicate
https://www.codewars.com/kata/5260074c9a0022f83e0009da
This kata is not Python 3 compliant.
The argument name of
Fraction.fromDecimal
shouldn't really befraction
, it should bedecimal
.No random test of JS/Python/Java.
Needs random tests.
Getting an error saying that numerator or denominator cannot be 0 but I already have an if-statement that throws an exception if either of them are 0's in the constructor. Why doesn't this work? What are you looking for to happen in this case??
// The test I wrote just to see if the program throws an exception, and it does. Still won't let me submit though
assertEquals("Numerator or Denominator cannot be zero", null, new Fraction(0,1));
JavaScript: Could do with test cases for the type of the return values of the arithmetic methods.
I glimpsed a solution that returned
String
s instead ofFraction
s. This passed because return values are only testedtoString()
ed, andString.toString()
returns the sameString
.I would like to see more specific test cases. Sometimes I was sitting there trying to analyze a failing test just to notice that it was actually some other test that failed. I think it's best practice to have one assertion per test. Thus I would like to see methods like:
@Test
public void testWithNegativeNumbers() {
assertEquals("-1/2", Fraction.new(1, -2));
}
and so on. Also I think a fraction class like this would benefit of methods to compare two fractions. Maybe that's too annoyingly borring but I already thought that after the add() method.
Hi, I've added a Python translation, if you want to approve it, instructions for the approval process are here.