From 46f3ee3d2ca5bb05d96a8f1f0b3dd3e3b574810b Mon Sep 17 00:00:00 2001 From: Umur Ozkul Date: Thu, 21 Apr 2022 19:05:03 +0200 Subject: [PATCH] parse partial tested --- .../Reducer/Reducer_externalBindings_test.res | 16 +++++++-------- .../Reducer_MathJs_ToExpression.res | 20 ++++++++----------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res b/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res index 844eba69..1ae7e1e3 100644 --- a/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res +++ b/packages/squiggle-lang/__tests__/Reducer/Reducer_externalBindings_test.res @@ -1,34 +1,34 @@ open Jest open Reducer_TestHelpers -Skip.describe("Parse for Bindings", () => { +Only.describe("Parse for Bindings", () => { testParseOuterToBe( "x", - "????", + "Ok((:$$bindExpression (:$$bindings) :x))", ) testParseOuterToBe( "x+1", - "????", + "Ok((:$$bindExpression (:$$bindings) (:add :x 1)))", ) testParseOuterToBe( "y = x+1; y", - "????", + "Ok((:$$bindExpression (:$$bindStatement (:$$bindings) (:$let :y (:add :x 1))) :y))", ) testParsePartialToBe( "x", - "????", + "Ok((:$$bindExpression (:$$bindStatement (:$$bindings) :x) (:$exportVariablesExpression)))", ) testParsePartialToBe( "y=x", - "????", + "Ok((:$$bindExpression (:$$bindStatement (:$$bindings) (:$let :y :x)) (:$exportVariablesExpression)))", ) testParsePartialToBe( "y=x+1", - "????", + "Ok((:$$bindExpression (:$$bindStatement (:$$bindings) (:$let :y (:add :x 1))) (:$exportVariablesExpression)))", ) testParsePartialToBe( "y = x+1; z = y", - "????", + "Ok((:$$bindExpression (:$$bindStatement (:$$bindStatement (:$$bindings) (:$let :y (:add :x 1))) (:$let :z :y)) (:$exportVariablesExpression)))", ) }) diff --git a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res index 2810b2f1..c05fb6c2 100644 --- a/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res +++ b/packages/squiggle-lang/src/rescript/Reducer/Reducer_MathJs/Reducer_MathJs_ToExpression.res @@ -155,18 +155,17 @@ let fromPartialNode = (mathJsNode: Parse.node): result = Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => { let casePartialBlockNode = (bNode: Parse.blockNode) => { let blocksOrTags = bNode["blocks"]->Belt.Array.map(toTagOrNode) - let completed = Js.Array2.concatMany( - [BlockTag(ImportVariablesStatement)], - [blocksOrTags, [BlockTag(ExportVariablesExpression)]], + let completed = Js.Array2.concat( + blocksOrTags, + [BlockTag(ExportVariablesExpression)] ) completed->caseTagOrNodes } let casePartialExpression = (node: Parse.node) => { - let completed = Js.Array2.concatMany( - [BlockTag(ImportVariablesStatement)], - [[BlockNode(node)], [BlockTag(ExportVariablesExpression)]], - ) + let completed = + [BlockNode(node), BlockTag(ExportVariablesExpression)] + completed->caseTagOrNodes } @@ -182,15 +181,12 @@ let fromOuterNode = (mathJsNode: Parse.node): result => Parse.castNodeType(mathJsNode)->Result.flatMap(typedMathJsNode => { let casePartialBlockNode = (bNode: Parse.blockNode) => { let blocksOrTags = bNode["blocks"]->Belt.Array.map(toTagOrNode) - let completed = Js.Array2.concatMany([BlockTag(ImportVariablesStatement)], [blocksOrTags]) + let completed = blocksOrTags completed->caseTagOrNodes } let casePartialExpression = (node: Parse.node) => { - let completed = Js.Array2.concatMany( - [BlockTag(ImportVariablesStatement)], - [[BlockNode(node)]], - ) + let completed = [BlockNode(node)] completed->caseTagOrNodes }