                     @live = result
                     cb()
 
-
-test0 = (client, server) ->
-    client.live = "sage"
-    server.live = "my\nsage"
+    _checksum: (doc) =>
+        return @opts.checksum(doc)
+
+test0 = (client, server, DocClass, Doc_equal, Doc_str) ->
+    if DocClass?
+        client.live = new DocClass("sage")
+        server.live = new DocClass("my\nsage")
+    else
+        client.live = "sage"
+        server.live = "my\nsage"
+
+    if not Doc_equal?
+        Doc_equal = (s,t) -> s==t
+    if not Doc_str?
+        Doc_print = (s) -> s
+
     status = () ->
         #console.log("------------------------")
         #console.log(misc.to_json(client.status()))
         #console.log(misc.to_json(server.status()))
         console.log("------------------------")
-        console.log("'#{client.live}'")
-        console.log("'#{server.live}'")
+        console.log("'#{Doc_str(client.live)}'")
+        console.log("'#{Doc_str(server.live)}'")
 
     pusher = undefined
     go = () ->


class CustomDiffSync extends DiffSync
    constructor: (opts) ->
        #IMPORTANT: None of the custom functions below take callbacks
        # as the last argument!
        opts = defaults opts,
            id       : undefined   # anything you want; or leave empty to have a uuid randomly assigned
            doc      : required    # the starting live document

        console.log(misc.to_json(server.status()))

exports.test4 = (n=1) ->
    # Just use the standard dmp functions on strings again.
    copy      = (s) -> s
    diff      = (v0,v1)  -> dmp.patch_make(v0,v1)
    patch     = (d, doc) -> dmp.patch_apply(d, doc)[0]
