Commits

adamschmideg committed f4dc0a4

recursive resolution works for a simple fibonacci @0.2

Comments (0)

Files changed (2)

   sortedUPs = depGraph.resolutionOrder wantedUPs
   fun = (db, up) ->
     current = db.value up
-    console.log 'current', up, current
+    #console.log 'current', up, current
     if _.isNull(current) or _.isUndefined(current)
       dep = pathStrToDep[up.asString()]
       value = dep.calculateValue db, up
-      console.log 'value', value
-      temp = db.setValue up, value
-      #console.log 'calculateValue', value, JSON.stringify(temp,null,2)
-      temp
+      result = db.setValue up, value
+      #console.log 'value', result
+      result
     else
       db
   db = _(sortedUPs).reduce fun, db

test/resolve.coffee

   assert.deepEqual expected, result
   assert.done()
 
-@recursive = (assert) ->
-  data = nums: []
-  _(5).times -> data.nums.push {}
-  data.nums[0].index = 0
+@fibonacci = (assert) ->
+  data = nums: [{},{}]
+  data.nums[0].index = 1
+  data.nums[1].index = 1
   deps = [
     target: '/nums/*/index'
     depends:
       prev: '../</index'
+      prev2: '../</</index'
     calculate: ->
-      @prev + 1
+      @prev + @prev2 
   ]
-  result = resolve data, deps, '/nums/0/index', '/nums/1/index', '/nums/2/index'
-  assert.deepEqual result.nums[1].index, 1
+  result = resolve data, deps, '/nums/6/index'
+  assert.deepEqual [1,1,2,3,5,8,13], _(result.nums).map (x) -> x.index
   assert.done()