I created a successful bothC function that looks more like the simplified version of seqC, calling fC first. But when I switch to calling gC first, I get the following failures. Am I missing something, or is this a bug in the unit test?
PASSED No JSLint errors
PASSED bothC(S, S, A, B) === undefined
PASSED output === "SSA"
PASSED bothC(S, F, A, B) === undefined
FAILED output === "SSASFB"
PASSED bothC(F, S, A, B) === undefined
FAILED output === "SSASFBFSB"
PASSED bothC(F, F, A, B) === undefined
FAILED output === "SSASFBFSBFFB"
For me, the trick here was to forget about the words "success" and "failure" because they have too much semantics embedded. I had to re-word the problem like this: call f3, if first argument of f1 and f2 are called. All other roads lead to f4. Both f1 and f2 has to be called in the chain no matter what.
Also, this is the first time I've seen such a pattern. Is there a practical application of such pattern? I think it's ok to have a single level of closure to continue execution, but if it goes to that many levels like the sample problem, it'll be a nightmare to maintain for people who have not seen your code yet.
I created a successful bothC function that looks more like the simplified version of seqC, calling fC first. But when I switch to calling gC first, I get the following failures. Am I missing something, or is this a bug in the unit test?