All tests working again (including double-late-join)
This commit is contained in:
parent
a1b07f84ea
commit
ef9e183138
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
@ -68,7 +68,7 @@ gulp.task 'build_browser', ->
|
||||
debug: true
|
||||
.pipe rename
|
||||
extname: ".js"
|
||||
.pipe gulp.dest './build/test'
|
||||
.pipe gulp.dest './build/test/'
|
||||
|
||||
gulp.task 'watch', ['build_browser','mocha'], ->
|
||||
gulp.watch files.all, ['build_browser', 'mocha']
|
||||
|
@ -29,7 +29,7 @@ module.exports = (HB)->
|
||||
if uid?
|
||||
@uid = uid
|
||||
|
||||
type: "Insert"
|
||||
type: "Operation"
|
||||
|
||||
#
|
||||
# Add an event listener. It depends on the operation which events are supported.
|
||||
@ -284,13 +284,13 @@ module.exports = (HB)->
|
||||
|
||||
cleanup: ()->
|
||||
# TODO: Debugging
|
||||
if @next_cl?.isDeleted()
|
||||
if @next_cl.isDeleted()
|
||||
# delete all ops that delete this insertion
|
||||
for d in @deleted_by
|
||||
d.cleanup()
|
||||
|
||||
# throw new Error "left is not deleted. inconsistency!, wrararar"
|
||||
# delete origin references to the right
|
||||
# throw new Error "right is not deleted. inconsistency!, wrararar"
|
||||
# change origin references to the right
|
||||
o = @next_cl
|
||||
while o.type isnt "Delimiter"
|
||||
if o.origin is @
|
||||
@ -479,10 +479,10 @@ module.exports = (HB)->
|
||||
|
||||
applyDelete: ()->
|
||||
super()
|
||||
o = @next_cl
|
||||
o = @prev_cl
|
||||
while o?
|
||||
o.applyDelete()
|
||||
o = o.next_cl
|
||||
o = o.prev_cl
|
||||
undefined
|
||||
|
||||
cleanup: ()->
|
||||
|
@ -125,19 +125,15 @@ module.exports = (HB)->
|
||||
# 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
|
||||
#
|
||||
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
|
||||
val = @val()
|
||||
json = {}
|
||||
for name, o of val
|
||||
if not o?
|
||||
json[name] = o
|
||||
else if o.constructor is {}.constructor
|
||||
json[name] = @val(name).toJson()
|
||||
else if o instanceof types.Operation
|
||||
while o instanceof types.Operation
|
||||
o = o.val()
|
||||
json[name] = o
|
||||
if o instanceof JsonType
|
||||
json[name] = o.toJson(transform_to_value)
|
||||
else if transform_to_value and o instanceof types.Operation
|
||||
json[name] = o.val()
|
||||
else
|
||||
json[name] = o
|
||||
@bound_json = json
|
||||
|
@ -124,10 +124,10 @@ module.exports = (HB)->
|
||||
type: "WordType"
|
||||
|
||||
applyDelete: ()->
|
||||
o = @beginning
|
||||
o = @end
|
||||
while o?
|
||||
o.applyDelete()
|
||||
o = o.next_cl
|
||||
o = o.prev_cl
|
||||
super()
|
||||
|
||||
cleanup: ()->
|
||||
|
@ -37,7 +37,7 @@ class JsonTest extends Test
|
||||
@getRandomRoot user_num, p
|
||||
|
||||
getContent: (user_num)->
|
||||
@users[user_num].toJson()
|
||||
@users[user_num].toJson(true)
|
||||
|
||||
getGeneratingFunctions: (user_num)->
|
||||
types = @users[user_num].types
|
||||
@ -124,9 +124,11 @@ describe "JsonFramework", ->
|
||||
u2 = @yTest.users[1]
|
||||
ops1 = u1.HB._encode()
|
||||
ops2 = u2.HB._encode()
|
||||
u1.HB.renewStateVector u2.HB.getOperationCounter()
|
||||
u2.HB.renewStateVector u1.HB.getOperationCounter()
|
||||
u1.engine.applyOps ops2
|
||||
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)", ->
|
||||
@yTest.users[0].val('a', 'q')
|
||||
|
@ -194,6 +194,8 @@ module.exports = class Test
|
||||
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)
|
||||
@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()
|
||||
|
||||
#if @getContent(@users.length-1) isnt @getContent(0)
|
||||
|
@ -114,6 +114,7 @@ describe "TextFramework", ->
|
||||
u.unobserve observer2
|
||||
|
||||
it "can handle many engines, many operations, concurrently (random)", ->
|
||||
console.log("testiy deleted this TODO:dtrn")
|
||||
@yTest.run()
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user