always merge stdlib
This commit is contained in:
parent
f406ae9053
commit
28938adf53
|
@ -25,7 +25,7 @@ let expectToExpressionToBe = (expr, answer, ~v="_", ()) => {
|
||||||
->Result.flatMap(expr =>
|
->Result.flatMap(expr =>
|
||||||
Expression.reduceExpression(
|
Expression.reduceExpression(
|
||||||
expr,
|
expr,
|
||||||
ReducerInterface_DefaultExternalBindings.defaultInternalBindings,
|
ReducerInterface_StdLib.internalStdLib,
|
||||||
ExpressionValue.defaultEnvironment,
|
ExpressionValue.defaultEnvironment,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -29,6 +29,7 @@ let expectEvalError = (expr: string) =>
|
||||||
|
|
||||||
let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) =>
|
let expectEvalBindingsToBe = (expr: string, bindings: Reducer.externalBindings, answer: string) =>
|
||||||
Reducer.evaluateUsingOptions(expr, ~externalBindings=Some(bindings), ~environment=None)
|
Reducer.evaluateUsingOptions(expr, ~externalBindings=Some(bindings), ~environment=None)
|
||||||
|
->Reducer_Helpers.rRemoveDefaults
|
||||||
->ExpressionValue.toStringResult
|
->ExpressionValue.toStringResult
|
||||||
->expect
|
->expect
|
||||||
->toBe(answer)
|
->toBe(answer)
|
||||||
|
|
|
@ -24,4 +24,4 @@ let foreignFunctionInterface = (
|
||||||
|
|
||||||
let defaultEnvironment = ExpressionValue.defaultEnvironment
|
let defaultEnvironment = ExpressionValue.defaultEnvironment
|
||||||
|
|
||||||
let defaultExternalBindings = ReducerInterface_DefaultExternalBindings.defaultExternalBindings
|
let defaultExternalBindings = ReducerInterface_StdLib.externalStdLib
|
||||||
|
|
|
@ -116,14 +116,20 @@ let evaluateUsingOptions = (
|
||||||
~externalBindings: option<ReducerInterface_ExpressionValue.externalBindings>,
|
~externalBindings: option<ReducerInterface_ExpressionValue.externalBindings>,
|
||||||
code: string,
|
code: string,
|
||||||
): result<expressionValue, errorValue> => {
|
): result<expressionValue, errorValue> => {
|
||||||
let anEnvironment = switch environment {
|
let anEnvironment = Belt.Option.getWithDefault(
|
||||||
| Some(env) => env
|
environment,
|
||||||
| None => ReducerInterface_ExpressionValue.defaultEnvironment
|
ReducerInterface_ExpressionValue.defaultEnvironment,
|
||||||
}
|
)
|
||||||
|
|
||||||
let anExternalBindings = switch externalBindings {
|
let anExternalBindings = switch externalBindings {
|
||||||
| Some(bindings) => bindings
|
| Some(bindings) => {
|
||||||
| None => ReducerInterface_DefaultExternalBindings.defaultExternalBindings
|
let cloneLib = ReducerInterface_StdLib.externalStdLib->Reducer_Category_Bindings.cloneRecord
|
||||||
|
Js.Dict.entries(bindings)->Js.Array2.reduce((acc, (key, value)) => {
|
||||||
|
acc->Js.Dict.set(key, value)
|
||||||
|
acc
|
||||||
|
}, cloneLib)
|
||||||
|
}
|
||||||
|
| None => ReducerInterface_StdLib.externalStdLib
|
||||||
}
|
}
|
||||||
|
|
||||||
let bindings = anExternalBindings->Bindings.fromExternalBindings
|
let bindings = anExternalBindings->Bindings.fromExternalBindings
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
module Bindings = Reducer_Category_Bindings
|
|
||||||
|
|
||||||
let defaultInternalBindings = Bindings.emptyBindings->SquiggleLibrary_Math.makeBindings
|
|
||||||
|
|
||||||
@genType
|
|
||||||
let defaultExternalBindings = defaultInternalBindings->Bindings.toRecord
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
module Bindings = Reducer_Category_Bindings
|
||||||
|
|
||||||
|
let internalStdLib = Bindings.emptyBindings->SquiggleLibrary_Math.makeBindings
|
||||||
|
|
||||||
|
@genType
|
||||||
|
let externalStdLib = internalStdLib->Bindings.toRecord
|
Loading…
Reference in New Issue
Block a user