All tests working again (including double-late-join)

This commit is contained in:
DadaMonad 2015-01-08 15:08:44 +00:00
parent a1b07f84ea
commit ef9e183138
13 changed files with 106 additions and 108 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -68,7 +68,7 @@ gulp.task 'build_browser', ->
debug: true debug: true
.pipe rename .pipe rename
extname: ".js" extname: ".js"
.pipe gulp.dest './build/test' .pipe gulp.dest './build/test/'
gulp.task 'watch', ['build_browser','mocha'], -> gulp.task 'watch', ['build_browser','mocha'], ->
gulp.watch files.all, ['build_browser', 'mocha'] gulp.watch files.all, ['build_browser', 'mocha']

View File

@ -29,7 +29,7 @@ module.exports = (HB)->
if uid? if uid?
@uid = uid @uid = uid
type: "Insert" type: "Operation"
# #
# Add an event listener. It depends on the operation which events are supported. # Add an event listener. It depends on the operation which events are supported.
@ -284,13 +284,13 @@ module.exports = (HB)->
cleanup: ()-> cleanup: ()->
# TODO: Debugging # TODO: Debugging
if @next_cl?.isDeleted() if @next_cl.isDeleted()
# delete all ops that delete this insertion # delete all ops that delete this insertion
for d in @deleted_by for d in @deleted_by
d.cleanup() d.cleanup()
# throw new Error "left is not deleted. inconsistency!, wrararar" # throw new Error "right is not deleted. inconsistency!, wrararar"
# delete origin references to the right # change origin references to the right
o = @next_cl o = @next_cl
while o.type isnt "Delimiter" while o.type isnt "Delimiter"
if o.origin is @ if o.origin is @
@ -479,10 +479,10 @@ module.exports = (HB)->
applyDelete: ()-> applyDelete: ()->
super() super()
o = @next_cl o = @prev_cl
while o? while o?
o.applyDelete() o.applyDelete()
o = o.next_cl o = o.prev_cl
undefined undefined
cleanup: ()-> cleanup: ()->

View File

@ -125,19 +125,15 @@ module.exports = (HB)->
# TODO: at the moment you don't consider changing of properties. # TODO: at the moment you don't consider changing of properties.
# E.g.: let x = {a:[]}. Then x.a.push 1 wouldn't change anything # E.g.: let x = {a:[]}. Then x.a.push 1 wouldn't change anything
# #
toJson: ()-> toJson: (transform_to_value = false)->
if not @bound_json? or not Object.observe? or true # TODO: currently, you are not watching mutable strings for changes, and, therefore, the @bound_json is not updated. TODO TODO wuawuawua easy if not @bound_json? or not Object.observe? or true # TODO: currently, you are not watching mutable strings for changes, and, therefore, the @bound_json is not updated. TODO TODO wuawuawua easy
val = @val() val = @val()
json = {} json = {}
for name, o of val for name, o of val
if not o? if o instanceof JsonType
json[name] = o json[name] = o.toJson(transform_to_value)
else if o.constructor is {}.constructor else if transform_to_value and o instanceof types.Operation
json[name] = @val(name).toJson() json[name] = o.val()
else if o instanceof types.Operation
while o instanceof types.Operation
o = o.val()
json[name] = o
else else
json[name] = o json[name] = o
@bound_json = json @bound_json = json

View File

@ -124,10 +124,10 @@ module.exports = (HB)->
type: "WordType" type: "WordType"
applyDelete: ()-> applyDelete: ()->
o = @beginning o = @end
while o? while o?
o.applyDelete() o.applyDelete()
o = o.next_cl o = o.prev_cl
super() super()
cleanup: ()-> cleanup: ()->

View File

@ -37,7 +37,7 @@ class JsonTest extends Test
@getRandomRoot user_num, p @getRandomRoot user_num, p
getContent: (user_num)-> getContent: (user_num)->
@users[user_num].toJson() @users[user_num].toJson(true)
getGeneratingFunctions: (user_num)-> getGeneratingFunctions: (user_num)->
types = @users[user_num].types types = @users[user_num].types
@ -124,9 +124,11 @@ describe "JsonFramework", ->
u2 = @yTest.users[1] u2 = @yTest.users[1]
ops1 = u1.HB._encode() ops1 = u1.HB._encode()
ops2 = u2.HB._encode() ops2 = u2.HB._encode()
u1.HB.renewStateVector u2.HB.getOperationCounter()
u2.HB.renewStateVector u1.HB.getOperationCounter()
u1.engine.applyOps ops2 u1.engine.applyOps ops2
u2.engine.applyOps ops1 u2.engine.applyOps ops1
expect(test.getContent(0)).to.equal(@yTest.getContent(1)) expect(test.getContent(0)).to.deep.equal(@yTest.getContent(1))
it "can handle creaton of complex json (1)", -> it "can handle creaton of complex json (1)", ->
@yTest.users[0].val('a', 'q') @yTest.users[0].val('a', 'q')

View File

@ -194,6 +194,8 @@ module.exports = class Test
testHBencoding: ()-> testHBencoding: ()->
# in case of JsonFramework, every user will create its JSON first! therefore, the testusers id must be small than all the others (see InsertType) # in case of JsonFramework, every user will create its JSON first! therefore, the testusers id must be small than all the others (see InsertType)
@users[@users.length] = @makeNewUser (-1) # this does not want to join with anymody @users[@users.length] = @makeNewUser (-1) # this does not want to join with anymody
@users[@users.length-1].HB.renewStateVector @users[0].HB.getOperationCounter()
@users[@users.length-1].engine.applyOps @users[0].HB._encode() @users[@users.length-1].engine.applyOps @users[0].HB._encode()
#if @getContent(@users.length-1) isnt @getContent(0) #if @getContent(@users.length-1) isnt @getContent(0)

View File

@ -114,6 +114,7 @@ describe "TextFramework", ->
u.unobserve observer2 u.unobserve observer2
it "can handle many engines, many operations, concurrently (random)", -> it "can handle many engines, many operations, concurrently (random)", ->
console.log("testiy deleted this TODO:dtrn")
@yTest.run() @yTest.run()

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long