fix PR#333 - kill W in evalaluateWBindings
renamed to evaluateUsingExternalBindings
This commit is contained in:
parent
a4aee41aa4
commit
2c7e6c750b
|
@ -17,7 +17,7 @@ let expectEvalToBe = (expr: string, answer: string) =>
|
|||
Reducer.evaluate(expr)->ExpressionValue.toStringResult->expect->toBe(answer)
|
||||
|
||||
let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) =>
|
||||
Reducer.evaluateWBindings(expr, bindings)->ExpressionValue.toStringResult->expect->toBe(answer)
|
||||
Reducer.evaluateUsingExternalBindings(expr, bindings)->ExpressionValue.toStringResult->expect->toBe(answer)
|
||||
|
||||
let expectEvalPartialBindingsToBe = (
|
||||
expr: string,
|
||||
|
|
|
@ -8,7 +8,7 @@ module MathJs = Reducer_MathJs
|
|||
type expressionValue = Reducer_Expression.expressionValue
|
||||
type externalBindings = Expression.externalBindings
|
||||
let evaluate = Expression.eval
|
||||
let evaluateWBindings = Expression.evalWBindings
|
||||
let evaluateUsingExternalBindings = Expression.evalUsingExternalBindings
|
||||
let evaluatePartialWBindings = Expression.evalPartialWBindings
|
||||
let parse = Expression.parse
|
||||
let parseOuter = Expression.parseOuter
|
||||
|
|
|
@ -12,7 +12,7 @@ type externalBindings = ReducerInterface_ExpressionValue.externalBindings
|
|||
@genType
|
||||
let evaluate: string => result<expressionValue, Reducer_ErrorValue.errorValue>
|
||||
@genType
|
||||
let evaluateWBindings: (
|
||||
let evaluateUsingExternalBindings: (
|
||||
string,
|
||||
externalBindings,
|
||||
) => result<expressionValue, Reducer_ErrorValue.errorValue>
|
||||
|
|
|
@ -116,7 +116,7 @@ let rec reduceExpression = (expression: t, bindings: T.bindings): result<express
|
|||
)
|
||||
}
|
||||
|
||||
let evalWBindingsExpression_ = (aExpression, bindings): result<expressionValue, 'e> =>
|
||||
let evalUsingExternalBindingsExpression_ = (aExpression, bindings): result<expressionValue, 'e> =>
|
||||
reduceExpression(aExpression, bindings)
|
||||
|
||||
/*
|
||||
|
@ -126,7 +126,7 @@ let evalWBindingsExpression_ = (aExpression, bindings): result<expressionValue,
|
|||
*/
|
||||
let evalPartialWBindings_ = (codeText: string, bindings: T.bindings) => {
|
||||
parsePartial(codeText)->Result.flatMap(expression =>
|
||||
expression->evalWBindingsExpression_(bindings)
|
||||
expression->evalUsingExternalBindingsExpression_(bindings)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ let evalPartialWBindings_ = (codeText: string, bindings: T.bindings) => {
|
|||
Therefore all statments are assignments.
|
||||
*/
|
||||
let evalOuterWBindings_ = (codeText: string, bindings: T.bindings) => {
|
||||
parseOuter(codeText)->Result.flatMap(expression => expression->evalWBindingsExpression_(bindings))
|
||||
parseOuter(codeText)->Result.flatMap(expression => expression->evalUsingExternalBindingsExpression_(bindings))
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -144,7 +144,7 @@ let evalOuterWBindings_ = (codeText: string, bindings: T.bindings) => {
|
|||
*/
|
||||
let eval = (codeText: string) => {
|
||||
parse(codeText)->Result.flatMap(expression =>
|
||||
expression->evalWBindingsExpression_(defaultBindings)
|
||||
expression->evalUsingExternalBindingsExpression_(defaultBindings)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ let externalBindingsToBindings = (externalBindings: externalBindings): T.binding
|
|||
/*
|
||||
Evaluates code with external bindings. External bindings are a record of expression values.
|
||||
*/
|
||||
let evalWBindings = (code: string, externalBindings: externalBindings) => {
|
||||
let evalUsingExternalBindings = (code: string, externalBindings: externalBindings) => {
|
||||
let bindings = externalBindings->externalBindingsToBindings
|
||||
evalOuterWBindings_(code, bindings)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user