__result__ variable in bindings
This commit is contained in:
		
							parent
							
								
									82a4e52384
								
							
						
					
					
						commit
						7eef1d30f3
					
				|  | @ -16,7 +16,9 @@ let runFetchResult = (project, sourceId) => { | |||
| 
 | ||||
| let runFetchFlatBindings = (project, sourceId) => { | ||||
|   Project.run(project, sourceId) | ||||
|   Project.getBindings(project, sourceId)->InternalExpressionValue.toStringBindings | ||||
|   Project.getBindings(project, sourceId) | ||||
|   ->Bindings.removeResult | ||||
|   ->InternalExpressionValue.toStringBindings | ||||
| } | ||||
| 
 | ||||
| test("setting continuation", () => { | ||||
|  |  | |||
|  | @ -46,12 +46,12 @@ Case "Running a single source". | |||
|        Getting None means you have forgotten to run the source. | ||||
|  */ | ||||
|       let result = project->Project.getResult("main") | ||||
|       let bindings = project->Project.getBindings("main") | ||||
|       let bindings = project->Project.getBindings("main")->Bindings.removeResult | ||||
| 
 | ||||
|       /* Let's display the result and bindings */ | ||||
|       ( | ||||
|         result->InternalExpressionValue.toStringResult, | ||||
|         bindings->InternalExpressionValue.IEvBindings->InternalExpressionValue.toString, | ||||
|         bindings->InternalExpressionValue.toStringBindings, | ||||
|       )->expect == ("Ok(3)", "@{}") | ||||
|       /* You've got 3 with empty bindings. */ | ||||
|     }) | ||||
|  | @ -61,7 +61,7 @@ Case "Running a single source". | |||
|       Project.setSource(project, "main", "1 + 2") | ||||
|       Project.runAll(project) | ||||
|       let result = Project.getResult(project, "main") | ||||
|       let bindings = Project.getBindings(project, "main") | ||||
|       let bindings = Project.getBindings(project, "main")->Bindings.removeResult | ||||
|       /* Now you have external bindings and external result. */ | ||||
|       ( | ||||
|         result->InternalExpressionValue.toStringResult, | ||||
|  | @ -89,7 +89,7 @@ Case "Running a single source". | |||
|       let (result, bindings) = Project.evaluate("1+2") | ||||
|       ( | ||||
|         result->InternalExpressionValue.toStringResult, | ||||
|         bindings->InternalExpressionValue.IEvBindings->InternalExpressionValue.toString, | ||||
|         bindings->Bindings.removeResult->InternalExpressionValue.toStringBindings, | ||||
|       )->expect == ("Ok(3)", "@{}") | ||||
|     }) | ||||
|   }) | ||||
|  |  | |||
|  | @ -29,11 +29,11 @@ describe("ReducerProject Tutorial", () => { | |||
| 
 | ||||
|       /* And let's check the result and bindings of source3 */ | ||||
|       let result3 = Project.getResult(project, "source3") | ||||
|       let bindings3 = Project.getBindings(project, "source3") | ||||
|       let bindings3 = Project.getBindings(project, "source3")->Bindings.removeResult | ||||
| 
 | ||||
|       ( | ||||
|         result3->InternalExpressionValue.toStringResult, | ||||
|         bindings3->InternalExpressionValue.IEvBindings->InternalExpressionValue.toString, | ||||
|         bindings3->InternalExpressionValue.toStringBindings, | ||||
|       )->expect == ("Ok(())", "@{x: 1,y: 2,z: 3}") | ||||
|     }) | ||||
| 
 | ||||
|  | @ -55,11 +55,11 @@ describe("ReducerProject Tutorial", () => { | |||
| 
 | ||||
|       /* And let's check the result and bindings of source3 */ | ||||
|       let result3 = Project.getResult(project, "source3") | ||||
|       let bindings3 = Project.getBindings(project, "source3") | ||||
|       let bindings3 = Project.getBindings(project, "source3")->Bindings.removeResult | ||||
| 
 | ||||
|       ( | ||||
|         result3->InternalExpressionValue.toStringResult, | ||||
|         bindings3->InternalExpressionValue.IEvBindings->InternalExpressionValue.toString, | ||||
|         bindings3->InternalExpressionValue.toStringBindings, | ||||
|       )->expect == ("Ok(())", "@{x: 1,y: 2,z: 3}") | ||||
|     }) | ||||
| 
 | ||||
|  | @ -91,11 +91,11 @@ describe("ReducerProject Tutorial", () => { | |||
|       This time you are getting all the variables because we are including the other sources  | ||||
|       Behind the scenes parseIncludes is setting the dependencies */ | ||||
|       let result3 = Project.getResult(project, "source3") | ||||
|       let bindings3 = Project.getBindings(project, "source3") | ||||
|       let bindings3 = Project.getBindings(project, "source3")->Bindings.removeResult | ||||
| 
 | ||||
|       ( | ||||
|         result3->InternalExpressionValue.toStringResult, | ||||
|         bindings3->InternalExpressionValue.IEvBindings->InternalExpressionValue.toString, | ||||
|         bindings3->InternalExpressionValue.toStringBindings, | ||||
|       )->expect == ("Ok(())", "@{x: 1,y: 2,z: 3}") | ||||
|       /* | ||||
|       Doing it like this is too verbose for a storybook  | ||||
|  |  | |||
|  | @ -147,7 +147,7 @@ Here we will finally proceed to a real life scenario. */ | |||
|       test("recursive includes", () => { | ||||
|         ( | ||||
|           result->InternalExpressionValue.toStringResult, | ||||
|           bindings->InternalExpressionValue.IEvBindings->InternalExpressionValue.toString, | ||||
|           bindings->Bindings.removeResult->InternalExpressionValue.toStringBindings, | ||||
|         )->expect == ("Ok(6)", "@{doubleX: 2,x: 1,y: 2,z: 3}") | ||||
|         /* Everything as expected */ | ||||
|       }) | ||||
|  |  | |||
|  | @ -183,3 +183,7 @@ let chainTo = (nameSpace: t, previousNameSpaces: array<t>) => { | |||
|     mergeFrom(prevNameSpace, topNameSpace) | ||||
|   ) | ||||
| } | ||||
| 
 | ||||
| let removeResult = (NameSpace(container): t): t => { | ||||
|   container->Belt.Map.String.remove("__result__")->NameSpace | ||||
| } | ||||
|  |  | |||
|  | @ -104,7 +104,7 @@ let callInternal = ( | |||
| 
 | ||||
|   let doDumpBindings = (continuation: nameSpace, value: internalExpressionValue) => { | ||||
|     // let _ = Continuation.inspect(continuation, "doDumpBindings") | ||||
|     accessors.states.continuation = continuation | ||||
|     accessors.states.continuation = continuation->Bindings.set("__result__", value) | ||||
|     value->Ok | ||||
|   } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user