This commit is contained in:
Umur Ozkul 2022-04-24 18:42:54 +02:00
parent 88b6d49ad3
commit fe4e355fbe
5 changed files with 14 additions and 11 deletions

View File

@ -17,7 +17,10 @@ let expectEvalToBe = (expr: string, answer: string) =>
Reducer.evaluate(expr)->ExpressionValue.toStringResult->expect->toBe(answer)
let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) =>
Reducer.evaluateUsingExternalBindings(expr, bindings)->ExpressionValue.toStringResult->expect->toBe(answer)
Reducer.evaluateUsingExternalBindings(expr, bindings)
->ExpressionValue.toStringResult
->expect
->toBe(answer)
let expectEvalPartialBindingsToBe = (
expr: string,

View File

@ -10,8 +10,8 @@ open Reducer_TestHelpers
inpsectPerformace(expr, label) will print out the value of expr, the label, and the time it took to evaluate expr.
*/
describe("Debugging", () => {
testEvalToBe("inspect(1)", "Ok(1)")
testEvalToBe("inspect(1, \"one\")", "Ok(1)")
testEvalToBe("inspect(1, \"one\")", "Ok(1)")
testEvalToBe("inspectPerformance(1, \"one\")", "Ok(1)")
testEvalToBe("inspect(1)", "Ok(1)")
testEvalToBe("inspect(1, \"one\")", "Ok(1)")
testEvalToBe("inspect(1, \"one\")", "Ok(1)")
testEvalToBe("inspectPerformance(1, \"one\")", "Ok(1)")
})

View File

@ -44,7 +44,7 @@ let callInternal = (call: functionCall): result<'b, errorValue> => {
}
let inspect = (value: expressionValue) => {
Js.log(`${value->toString}`)
Js.log(value->toString)
value->Ok
}

View File

@ -32,7 +32,7 @@ external castAssignmentNodeWAccessor: node => assignmentNodeWAccessor = "%identi
external castAssignmentNodeWIndex: node => assignmentNodeWIndex = "%identity"
external castBlockNode: node => blockNode = "%identity"
external castConstantNode: node => constantNode = "%identity"
external castFunctionAssignmentNode: node => functionAssignmentNode ="%identity"
external castFunctionAssignmentNode: node => functionAssignmentNode = "%identity"
external castFunctionNode: node => functionNode = "%identity"
external castIndexNode: node => indexNode = "%identity"
external castObjectNode: node => objectNode = "%identity"

View File

@ -106,7 +106,7 @@ let rec fromNode = (mathJsNode: Parse.node): result<expression, errorValue> =>
rValueExpression->Result.flatMap(valueExpression => {
let lispParams = faNode["params"]->Belt.List.fromArray->ExpressionT.EParameters
let rLambda = passToFunction("$lambda", list{lispParams, valueExpression}->Ok)
rLambda -> Result.flatMap( lambda => {
rLambda->Result.flatMap(lambda => {
passToFunction("$let", list{symbol, lambda}->Ok)
})
})