Here the code :)
ZestStructuredConditional manages Structured conditionals.
How does it work?
The main idea was to create a load of expression types (based on REGEX, status code, URL, ...). Each ZestElement which needs to evaluate a list of expression build a StructuredExpression (which is an AND/OR of a list of other expressions). The mechanism is very simple: once the StructuredExpression had been built, the evaluation calls the method evaluate for each sub-expression. In this way an Expression Tree is built, and the evaluation mechanism works recalling the evaluation for each leaf; each internal node, which is an AND/OR expression, collect all the results of the children and compute an AND/OR evaluation of the boolean received by the children; the root will then return the value of the whole expression.
All tests of this work can be found in the official repo.
All tests of this work can be found in the official repo.
ZestLoop
Next task is a bit more tricky. Now Zest does not allow to use loop... I started developing this feature creating a new class: ZestLoop. This class should represent a particular statement which is a container of other statements.
I created a first draft of design and I started implementing how it should work. All the code I'm writing can be found in my repo.
I created a first draft of design and I started implementing how it should work. All the code I'm writing can be found in my repo.
By the way, the current implementation is not really good. The biggest problem I found is that this does not separate the runner from the code: the current realization must have a reference to the whole Script and to the Runner. Loops are still under design phase, so I plan to solve this issue next week and, maybe, to make another pull request. :)
Here a snapshot of the UML of the current implementation:
Here a snapshot of the UML of the current implementation:
Here you can find the update of the UML of the latest realization of ZestLoop:
ReplyDeletehttps://dl.dropboxusercontent.com/u/5100168/ZestLoop.png