2022-04-23 19:13:43 +00:00
|
|
|
open Jest
|
|
|
|
open Reducer_TestHelpers
|
|
|
|
|
|
|
|
describe("Parse function assignment", () => {
|
2022-09-19 11:00:38 +00:00
|
|
|
testParseToBe("f(x)=x", "Ok(f = {|x| {x}})")
|
|
|
|
testParseToBe("f(x)=2*x", "Ok(f = {|x| {(multiply)(2, x)}})")
|
2022-04-23 19:13:43 +00:00
|
|
|
//MathJs does not allow blocks in function definitions
|
|
|
|
})
|
|
|
|
|
2022-04-25 00:37:35 +00:00
|
|
|
describe("Evaluate function assignment", () => {
|
|
|
|
testEvalToBe("f(x)=x; f(1)", "Ok(1)")
|
|
|
|
})
|
2022-09-19 17:46:37 +00:00
|
|
|
|
|
|
|
describe("Shadowing", () => {
|
|
|
|
testEvalToBe("x = 5; f(y) = x*y; x = 6; f(2)", "Ok(10)")
|
|
|
|
})
|