Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When branching within contest, the path of the solution doesn't contain the name of the subLeaf #4

Closed
cbchouinard opened this issue Feb 27, 2015 · 4 comments

Comments

@cbchouinard
Copy link
Contributor

I think we should add the name of the subLeaf that resolved in the path of the solution. With this spec:

it 'should resolve', (done) ->
      multiply = (multiplier, c, data) ->
        tree = c.tree 'a'
        tree.deliver data
        tree.then "#{multiplier}", (c, d) ->
          c.branch 'doubled', (b, data) ->
            data * 2
          c.branch 'tripled', (b, data) ->
            data * 3
      t = Root()
      t.deliver 5
      .contest "contest-multiply", [
        multiply.bind @, 2
        multiply.bind @, 3
      ], (c, results) ->
        results[1]
      .finally 'end',   (c, res) ->
        console.log 'fini'
        console.log c
        chai.expect(res).to.eql [15]
        done()

I get the path: [ 'root', 'contest_multiply', 'end' ]

Shouldn't it be: [ 'root', 'contest_multiply', 'tripled', 'end' ]

@bergie
Copy link
Contributor

bergie commented Feb 27, 2015

Good question. Currently for non continuation subtrees that doesn't happen. Instead, it is available via choice.toSong() on the contest node

@d4tocchini what do you think?

@d4tocchini
Copy link
Member

Looking at just path is dangerous, we really should be focusing more on the solution tree where each node in the tree has paths. I'd expect a branch to be like a continue that adds to the nearest parent tree, so this is what I'd expect:

solutionTree =
  path: [ 'root', 'contest_multiply', 'end' ]
  children: [
      path: ['a','3', 'tripled']
  ]

In that example, if the the subTree was used c.continue instead of c.tree, then I'd expect:

solutionTree =
  path: [ 'root', 'contest_multiply', 'a','3', 'tripled', 'end' ]

@bergie branches are treated as continuations, yes? With that in consideration, we definitely should be able to do promise chains from a branch as @cbchouinard requested.

@d4tocchini
Copy link
Member

@bergie how do we get the sane & clean solution tree (#9) ? Would be best if we start using that in our specs and in Taylor, as that's what Fletcher will use to grade the solutions...

@bergie
Copy link
Contributor

bergie commented Mar 6, 2015

@d4tocchini use Choice.toSong()

@bergie bergie closed this as completed Mar 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants