2022-09-11 15:22:07 +00:00
|
|
|
// open Jest
|
|
|
|
// open Expect
|
2022-04-28 16:35:09 +00:00
|
|
|
|
2022-09-11 15:22:07 +00:00
|
|
|
// module BindingsReplacer = Reducer_Expression_BindingsReplacer
|
|
|
|
// module Expression = Reducer_Expression
|
|
|
|
// module ExpressionWithContext = Reducer_ExpressionWithContext
|
|
|
|
// module InternalExpressionValue = ReducerInterface.InternalExpressionValue
|
|
|
|
// module Macro = Reducer_Expression_Macro
|
|
|
|
// module ProjectAccessorsT = ReducerProject_ProjectAccessors_T
|
|
|
|
// module T = Reducer_Expression_T
|
2022-04-28 16:35:09 +00:00
|
|
|
|
2022-09-11 15:22:07 +00:00
|
|
|
// let testMacro_ = (
|
|
|
|
// tester,
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedCode: string,
|
|
|
|
// ) => {
|
2022-09-14 11:15:03 +00:00
|
|
|
// let bindings = Bindings.fromArray(bindArray)
|
|
|
|
// tester(expr->T.toString, () =>
|
|
|
|
// expr
|
|
|
|
// ->Macro.expandMacroCallRs(
|
2022-09-11 15:22:07 +00:00
|
|
|
// bindings,
|
|
|
|
// ProjectAccessorsT.identityAccessors,
|
|
|
|
// Expression.reduceExpressionInProject,
|
2022-09-14 11:15:03 +00:00
|
|
|
// )
|
|
|
|
// ->ExpressionWithContext.toStringResult
|
|
|
|
// ->expect
|
|
|
|
// ->toEqual(expectedCode)
|
|
|
|
// )
|
2022-09-11 15:22:07 +00:00
|
|
|
// }
|
2022-04-28 16:35:09 +00:00
|
|
|
|
2022-09-11 15:22:07 +00:00
|
|
|
// let testMacroEval_ = (
|
|
|
|
// tester,
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedValue: string,
|
|
|
|
// ) => {
|
|
|
|
// let bindings = Reducer_Bindings.fromArray(bindArray)
|
|
|
|
// tester(expr->T.toString, () =>
|
|
|
|
// expr
|
|
|
|
// ->Macro.doMacroCall(
|
|
|
|
// bindings,
|
|
|
|
// ProjectAccessorsT.identityAccessors,
|
|
|
|
// Expression.reduceExpressionInProject,
|
|
|
|
// )
|
|
|
|
// ->Ok
|
|
|
|
// ->InternalExpressionValue.toStringResult
|
|
|
|
// ->expect
|
|
|
|
// ->toEqual(expectedValue)
|
|
|
|
// )
|
|
|
|
// }
|
2022-04-28 16:35:09 +00:00
|
|
|
|
2022-09-11 15:22:07 +00:00
|
|
|
// let testMacro = (
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedExpr: string,
|
|
|
|
// ) => testMacro_(test, bindArray, expr, expectedExpr)
|
|
|
|
// let testMacroEval = (
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedValue: string,
|
|
|
|
// ) => testMacroEval_(test, bindArray, expr, expectedValue)
|
2022-04-28 16:35:09 +00:00
|
|
|
|
2022-09-11 15:22:07 +00:00
|
|
|
// module MySkip = {
|
|
|
|
// let testMacro = (
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedExpr: string,
|
|
|
|
// ) => testMacro_(Skip.test, bindArray, expr, expectedExpr)
|
|
|
|
// let testMacroEval = (
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedValue: string,
|
|
|
|
// ) => testMacroEval_(Skip.test, bindArray, expr, expectedValue)
|
|
|
|
// }
|
2022-04-28 16:35:09 +00:00
|
|
|
|
2022-09-11 15:22:07 +00:00
|
|
|
// module MyOnly = {
|
|
|
|
// let testMacro = (
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedExpr: string,
|
|
|
|
// ) => testMacro_(Only.test, bindArray, expr, expectedExpr)
|
|
|
|
// let testMacroEval = (
|
|
|
|
// bindArray: array<(string, InternalExpressionValue.t)>,
|
|
|
|
// expr: T.expression,
|
|
|
|
// expectedValue: string,
|
|
|
|
// ) => testMacroEval_(Only.test, bindArray, expr, expectedValue)
|
|
|
|
// }
|