Everything is working smoothly again. Execution speed increased by 10x. Cleaned up the code and unused stuff.

This commit is contained in:
DadaMonad
2014-12-16 18:01:33 +00:00
parent 2cf899418a
commit 584964153c
68 changed files with 188 additions and 3434 deletions

View File

@@ -13,7 +13,8 @@ Yatta = require "../lib/Yatta.coffee"
Test = require "./TestSuite"
class JsonTest extends Test
makeNewUser: (user, conn)->
makeNewUser: (userId)->
conn = new Connector userId
super new Yatta conn
type: "JsonTest"
@@ -59,15 +60,13 @@ class JsonTest extends Test
types: [types.JsonType]
]
describe "JsonFramework", ->
beforeEach (done)->
@timeout 50000
@yTest = new JsonTest()
@users = @yTest.users
@test_user = @yTest.makeNewUser 0, (new Connector 0, [])
@test_user = @yTest.makeNewUser "test_user"
done()
it "can handle many engines, many operations, concurrently (random)", ->
@@ -96,7 +95,6 @@ describe "JsonFramework", ->
expect(change).to.be.ok
expect(change2).to.equal 8
it "has a JsonTypeWrapper", ->
y = this.yTest.getSomeUser().getSharedObject()
y.val('x',"dtrn", 'immutable')
@@ -112,7 +110,10 @@ describe "JsonFramework", ->
y.value.x = {q:4}
expect(y.value.x.q).to.equal(4)
### TODO: Handle this test
it "has a working test suite", ->
@yTest.compareAll()
it "handles double-late-join", ->
test = new JsonTest("double")
test.run()
@@ -123,14 +124,18 @@ describe "JsonFramework", ->
ops2 = u2.HB._encode()
u1.engine.applyOps ops2
u2.engine.applyOps ops1
expect(u2.value.name.val()).to.equal(u2.value.name.val())
###
it "has a working test suite", ->
expect(test.getContent(0)).to.equal(@yTest.getContent(1))
it "can handle creaton of complex json (1)", ->
@yTest.users[0].val('a', 'q')
@yTest.users[2].val('a', 't')
@yTest.compareAll()
q = @yTest.users[1].val('a')
q.insertText(0,'A')
@yTest.compareAll()
expect(@yTest.getSomeUser().value.a.val()).to.equal("At")
it "can handle creaton of complex json", ->
it "can handle creaton of complex json (2)", ->
@yTest.getSomeUser().val('x', {'a':'b'})
@yTest.getSomeUser().val('a', {'a':{q:"dtrndtrtdrntdrnrtdnrtdnrtdnrtdnrdnrdt"}})
@yTest.getSomeUser().val('b', {'a':{}})
@@ -154,4 +159,3 @@ describe "JsonFramework", ->
expect(@yTest.getSomeUser().val('null') is null).to.be.ok

View File

@@ -13,9 +13,9 @@ module.exports = class Test
constructor: (@name_suffix = "")->
@number_of_test_cases_multiplier = 1
@repeat_this = 1 * @number_of_test_cases_multiplier
@doSomething_amount = 400 + @number_of_test_cases_multiplier
@doSomething_amount = 50 + @number_of_test_cases_multiplier
@number_of_engines = 5 + @number_of_test_cases_multiplier - 1
@time = 0
@ops = 0
@time_now = 0
@@ -27,14 +27,13 @@ module.exports = class Test
reinitialize: ()->
@users = []
for i in [0...@number_of_engines]
connector = new Connector i
if @users.length > 0
connector.join @users[0].connector
u = @makeNewUser (i+@name_suffix), connector
u = @makeNewUser (i+@name_suffix)
for user in @users
u.getConnector().join(user.getConnector()) # TODO: change the test-connector to make this more convenient
@users.push u
#@users[0].val('name',"i")
@flushAll()
# is called by implementing class
makeNewUser: (user)->
user.HB.setManualGarbageCollect()
user
@@ -199,7 +198,7 @@ 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), (new Connector (-1), [])
@users[@users.length] = @makeNewUser (-1) # this does not want to join with anymody
@users[@users.length-1].engine.applyOps @users[0].HB._encode()
#if @getContent(@users.length-1) isnt @getContent(0)