wk5: Tests finished and check with screenshot
Co-authored-by: Dimitar Byalkov <CapitalRhino@users.noreply.github.com>
This commit is contained in:
@@ -90,4 +90,44 @@ simplifyHelp func =
|
||||
Minus left right ->
|
||||
Minus (simplify left) (simplify right)
|
||||
_ ->
|
||||
func
|
||||
func
|
||||
|
||||
-- Tests
|
||||
testPrintFunc: Bool
|
||||
testPrintFunc = print f == "(((3+x)*(x-(x^5)))+2)"
|
||||
|
||||
testPrintDerivFunc: Bool
|
||||
testPrintDerivFunc = print (derivative f) ==
|
||||
"((((0+1)*(x-(x^5)))+((3+x)*(1-(5*(x^4)))))+0)"
|
||||
|
||||
testPrintSimplifyDerivFunc: Bool
|
||||
testPrintSimplifyDerivFunc = print (simplify (derivative f)) ==
|
||||
"((x-(x^5))+((3+x)*(1-(5*(x^4)))))"
|
||||
|
||||
testDerivX: Bool
|
||||
testDerivX = derivative X == Const 1
|
||||
|
||||
testDerivConst: Bool
|
||||
testDerivConst = derivative (Const 5) == Const 0
|
||||
|
||||
testDerivPlus: Bool
|
||||
testDerivPlus = derivative (Plus X (Const 9)) == Plus (Const 1) (Const 0)
|
||||
|
||||
testDerivMult: Bool
|
||||
testDerivMult = derivative (Mult (Const 4) X) ==
|
||||
Plus (Mult (Const 0) X) (Mult (Const 4) (Const 1))
|
||||
|
||||
testDerivPolyX: Bool
|
||||
testDerivPolyX = derivative (Poly X 3) == Mult (Const 3) (Poly X 2)
|
||||
|
||||
testDerivPoly: Bool
|
||||
testDerivPoly = derivative (Poly (Const 4) 3) == (Poly (Const 0) 3)
|
||||
|
||||
testSimplePoly: Bool
|
||||
testSimplePoly = simplify (Poly (Const 0) 3) == Const 0
|
||||
|
||||
testSimpleRecursivePlus: Bool
|
||||
testSimpleRecursivePlus = simplify (Plus ((Mult (Const 1) X)) (Minus X (Const 0))) == (Plus X X)
|
||||
|
||||
allModelling2Tests: List Bool
|
||||
allModelling2Tests = [testPrintFunc, testPrintDerivFunc, testPrintSimplifyDerivFunc, testDerivX, testDerivConst, testDerivPlus, testDerivMult, testDerivPolyX, testDerivPoly, testSimplePoly, testSimpleRecursivePlus]
|
||||
|
Reference in New Issue
Block a user