2022-07-25 14:34:33 +00:00
|
|
|
module Expression = Reducer_Expression
|
2022-04-28 16:35:09 +00:00
|
|
|
module ExpressionT = Reducer_Expression_T
|
2022-03-24 12:41:31 +00:00
|
|
|
|
|
|
|
open Jest
|
|
|
|
open Expect
|
|
|
|
|
2022-04-27 20:00:42 +00:00
|
|
|
let unwrapRecord = rValue =>
|
2022-04-27 20:24:06 +00:00
|
|
|
rValue->Belt.Result.flatMap(value =>
|
|
|
|
switch value {
|
2022-09-11 15:22:07 +00:00
|
|
|
| Reducer_T.IEvRecord(aRecord) => Ok(aRecord)
|
2022-09-26 00:44:08 +00:00
|
|
|
| _ => SqError.Message.RETodo("TODO: Internal bindings must be returned")->Error
|
2022-04-27 20:24:06 +00:00
|
|
|
}
|
|
|
|
)
|
2022-04-27 20:00:42 +00:00
|
|
|
|
2022-07-25 14:34:33 +00:00
|
|
|
let expectParseToBe = (code: string, answer: string) =>
|
|
|
|
Expression.BackCompatible.parse(code)->ExpressionT.toStringResult->expect->toBe(answer)
|
2022-04-17 17:24:39 +00:00
|
|
|
|
2022-07-25 14:34:33 +00:00
|
|
|
let expectEvalToBe = (code: string, answer: string) =>
|
2022-09-19 22:19:55 +00:00
|
|
|
Expression.BackCompatible.evaluateString(code)->Reducer_Value.toStringResult->expect->toBe(answer)
|
2022-04-15 06:56:48 +00:00
|
|
|
|
2022-07-25 14:34:33 +00:00
|
|
|
let expectEvalError = (code: string) =>
|
2022-08-19 18:56:45 +00:00
|
|
|
Expression.BackCompatible.evaluateString(code)
|
2022-09-19 19:10:09 +00:00
|
|
|
->Reducer_Value.toStringResult
|
2022-04-24 16:42:54 +00:00
|
|
|
->expect
|
2022-10-12 15:49:14 +00:00
|
|
|
->toMatch("Error\\(")
|
2022-04-17 17:24:39 +00:00
|
|
|
|
|
|
|
let testParseToBe = (expr, answer) => test(expr, () => expectParseToBe(expr, answer))
|
|
|
|
let testDescriptionParseToBe = (desc, expr, answer) =>
|
|
|
|
test(desc, () => expectParseToBe(expr, answer))
|
|
|
|
|
2022-05-05 19:45:25 +00:00
|
|
|
let testEvalError = expr => test(expr, () => expectEvalError(expr))
|
2022-04-17 17:24:39 +00:00
|
|
|
let testEvalToBe = (expr, answer) => test(expr, () => expectEvalToBe(expr, answer))
|
|
|
|
let testDescriptionEvalToBe = (desc, expr, answer) => test(desc, () => expectEvalToBe(expr, answer))
|
2022-04-17 18:07:21 +00:00
|
|
|
|
2022-04-17 17:24:39 +00:00
|
|
|
module MySkip = {
|
2022-04-17 18:32:47 +00:00
|
|
|
let testParseToBe = (expr, answer) => Skip.test(expr, () => expectParseToBe(expr, answer))
|
2022-04-17 18:07:21 +00:00
|
|
|
let testEvalToBe = (expr, answer) => Skip.test(expr, () => expectEvalToBe(expr, answer))
|
2022-04-17 17:24:39 +00:00
|
|
|
}
|
|
|
|
module MyOnly = {
|
2022-04-17 18:32:47 +00:00
|
|
|
let testParseToBe = (expr, answer) => Only.test(expr, () => expectParseToBe(expr, answer))
|
2022-04-17 18:07:21 +00:00
|
|
|
let testEvalToBe = (expr, answer) => Only.test(expr, () => expectEvalToBe(expr, answer))
|
2022-04-17 17:24:39 +00:00
|
|
|
}
|