parse partial tested
This commit is contained in:
parent
6b800c498e
commit
46f3ee3d2c
|
@ -1,34 +1,34 @@
|
||||||
open Jest
|
open Jest
|
||||||
open Reducer_TestHelpers
|
open Reducer_TestHelpers
|
||||||
|
|
||||||
Skip.describe("Parse for Bindings", () => {
|
Only.describe("Parse for Bindings", () => {
|
||||||
testParseOuterToBe(
|
testParseOuterToBe(
|
||||||
"x",
|
"x",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindings) :x))",
|
||||||
)
|
)
|
||||||
testParseOuterToBe(
|
testParseOuterToBe(
|
||||||
"x+1",
|
"x+1",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindings) (:add :x 1)))",
|
||||||
)
|
)
|
||||||
testParseOuterToBe(
|
testParseOuterToBe(
|
||||||
"y = x+1; y",
|
"y = x+1; y",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindStatement (:$$bindings) (:$let :y (:add :x 1))) :y))",
|
||||||
)
|
)
|
||||||
testParsePartialToBe(
|
testParsePartialToBe(
|
||||||
"x",
|
"x",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindStatement (:$$bindings) :x) (:$exportVariablesExpression)))",
|
||||||
)
|
)
|
||||||
testParsePartialToBe(
|
testParsePartialToBe(
|
||||||
"y=x",
|
"y=x",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindStatement (:$$bindings) (:$let :y :x)) (:$exportVariablesExpression)))",
|
||||||
)
|
)
|
||||||
testParsePartialToBe(
|
testParsePartialToBe(
|
||||||
"y=x+1",
|
"y=x+1",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindStatement (:$$bindings) (:$let :y (:add :x 1))) (:$exportVariablesExpression)))",
|
||||||
)
|
)
|
||||||
testParsePartialToBe(
|
testParsePartialToBe(
|
||||||
"y = x+1; z = y",
|
"y = x+1; z = y",
|
||||||
"????",
|
"Ok((:$$bindExpression (:$$bindStatement (:$$bindStatement (:$$bindings) (:$let :y (:add :x 1))) (:$let :z :y)) (:$exportVariablesExpression)))",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -155,18 +155,17 @@ let fromPartialNode = (mathJsNode: Parse.node): result<expression, errorValue> =
|
||||||
Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => {
|
Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => {
|
||||||
let casePartialBlockNode = (bNode: Parse.blockNode) => {
|
let casePartialBlockNode = (bNode: Parse.blockNode) => {
|
||||||
let blocksOrTags = bNode["blocks"]->Belt.Array.map(toTagOrNode)
|
let blocksOrTags = bNode["blocks"]->Belt.Array.map(toTagOrNode)
|
||||||
let completed = Js.Array2.concatMany(
|
let completed = Js.Array2.concat(
|
||||||
[BlockTag(ImportVariablesStatement)],
|
blocksOrTags,
|
||||||
[blocksOrTags, [BlockTag(ExportVariablesExpression)]],
|
[BlockTag(ExportVariablesExpression)]
|
||||||
)
|
)
|
||||||
completed->caseTagOrNodes
|
completed->caseTagOrNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
let casePartialExpression = (node: Parse.node) => {
|
let casePartialExpression = (node: Parse.node) => {
|
||||||
let completed = Js.Array2.concatMany(
|
let completed =
|
||||||
[BlockTag(ImportVariablesStatement)],
|
[BlockNode(node), BlockTag(ExportVariablesExpression)]
|
||||||
[[BlockNode(node)], [BlockTag(ExportVariablesExpression)]],
|
|
||||||
)
|
|
||||||
completed->caseTagOrNodes
|
completed->caseTagOrNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,15 +181,12 @@ let fromOuterNode = (mathJsNode: Parse.node): result<expression, errorValue> =>
|
||||||
Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => {
|
Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => {
|
||||||
let casePartialBlockNode = (bNode: Parse.blockNode) => {
|
let casePartialBlockNode = (bNode: Parse.blockNode) => {
|
||||||
let blocksOrTags = bNode["blocks"]->Belt.Array.map(toTagOrNode)
|
let blocksOrTags = bNode["blocks"]->Belt.Array.map(toTagOrNode)
|
||||||
let completed = Js.Array2.concatMany([BlockTag(ImportVariablesStatement)], [blocksOrTags])
|
let completed = blocksOrTags
|
||||||
completed->caseTagOrNodes
|
completed->caseTagOrNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
let casePartialExpression = (node: Parse.node) => {
|
let casePartialExpression = (node: Parse.node) => {
|
||||||
let completed = Js.Array2.concatMany(
|
let completed = [BlockNode(node)]
|
||||||
[BlockTag(ImportVariablesStatement)],
|
|
||||||
[[BlockNode(node)]],
|
|
||||||
)
|
|
||||||
completed->caseTagOrNodes
|
completed->caseTagOrNodes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user