Skip to content

Commit

Permalink
test(evaluator): Add more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Myzel394 <[email protected]>
  • Loading branch information
Myzel394 committed Jul 21, 2024
1 parent 84ddb6b commit b53a0b1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,47 +60,4 @@ class ExpressionComplexTest {

@Test
fun shouldDivideRootAndDivideInCorrectOrder() = assertExpr("(√9)÷6", "0.5")

@Test
fun singleNumber() = assertExpr("42", "42")

@Test(expected = NumberFormatException::class)
fun divisionByZero() = assertExpr("1÷0", "")

@Test(expected = NumberFormatException::class)
fun invalidExpressionMissingOperand() = assertExpr("42+", "")

@Test
fun largeNumbers() = assertExpr("9999999999*9999999999", "99999999980000000001")

@Test
fun highPrecision() = assertExpr("1÷3", "0.3333333333")

@Test
fun deeplyNestedParentheses() = assertExpr("((((((42))))))", "42")

@Test
fun constantsAndFunctions() = assertExpr("π+e", "${Math.PI + Math.E}")

@Test
fun edgeMathematicalCases() =
assertExpr("0^0", "1") // Depending on the mathematical interpretation used

@Test
fun trigonometricLimits() = assertExpr("sin(0)", "0")

@Test
fun sinAtPi() = assertExpr("sin(π)", "0")

@Test
fun sinAtHalfPi() = assertExpr("sin(π÷2)", "1")

@Test
fun cosAtPi() = assertExpr("cos(π)", "-1")

@Test
fun cosAtHalfPi() = assertExpr("cos(π÷2)", "0")

@Test
fun cosAtPiOverThree() = assertExpr("cos(π÷3)", "0.5")
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,55 @@ class ExpressionSimpleTest {

@Test
fun expression29() = assertExpr("0!", "1")

@Test
fun factorial() = assertExpr("5!", "120")

@Test
fun singleNumber() = assertExpr("42", "42")

@Test(expected = NumberFormatException::class)
fun divisionByZero() = assertExpr("1÷0", "")

@Test(expected = NumberFormatException::class)
fun invalidExpressionMissingOperand() = assertExpr("42+", "")

@Test
fun largeNumbers() = assertExpr("9999999999*9999999999", "99999999980000000001")

@Test
fun highPrecision() = assertExpr("1÷3", "0.3333333333")

@Test
fun deeplyNestedParentheses() = assertExpr("((((((42))))))", "42")

@Test
fun constantsAndFunctions() = assertExpr("π+e", "${Math.PI + Math.E}")

@Test(expected = NumberFormatException::class)
fun edgeMathematicalCases() = assertExpr("0^0", "")

@Test
fun zeroExponent() = assertExpr("5^0", "1")

@Test
fun negativeExponent() = assertExpr("5^-1", "0.2")

@Test
fun trigonometricLimits() = assertExpr("sin(0)", "0")

@Test
fun sinAtPi() = assertExpr("sin(π)", "0")

@Test
fun sinAtHalfPi() = assertExpr("sin(π÷2)", "1")

@Test
fun cosAtPi() = assertExpr("cos(π)", "-1")

@Test
fun cosAtHalfPi() = assertExpr("cos(π÷2)", "0")

@Test
fun cosAtPiOverThree() = assertExpr("cos(π÷3)", "0.5")
}

0 comments on commit b53a0b1

Please sign in to comment.