forked from snowyu/nosql-memdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
80 lines (64 loc) · 2.91 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var test = require('tape')
, util = require('abstract-object')
, testCommon = require('abstract-nosql/testCommon')
, MemDOWN = require('./')
//, Encoding = require('nosql-encoding')
//, AbstractIterator = require('./').AbstractIterator
, testBuffer = require('./testdata_b64')
//MemDOWN=Encoding(MemDOWN)
/*** compatibility with basic LevelDOWN API ***/
// meh require('abstract-nosql/abstract/leveldown-test').args(MemDOWN, test, testCommon)
if (!test.Test.prototype.type) {
test.Test.prototype.type = function(thing, t, message, extra) {
var name = t
if (typeof name === "function") name = name.name || "(anonymous ctor)"
//console.error("name=%s", name)
message = message || "type is "+name
var type = typeof thing
//console.error("type=%s", type)
if (!thing && type === "object") type = "null"
if (type === "object" && t !== "object") {
if (typeof t === "function") {
//console.error("it is a function!")
extra = extra || {}
extra.found = Object.getPrototypeOf(thing).constructor.name
extra.wanted = name
//console.error(thing instanceof t, name)
return assert.ok(thing instanceof t, message, extra)
}
//console.error("check prototype chain")
// check against classnames or objects in prototype chain, as well.
// type(new Error("asdf"), "Error")
// type(Object.create(foo), foo)
var p = thing
while (p = Object.getPrototypeOf(p)) {
if (p === t || p.constructor && p.constructor.name === t) {
type = name
break
}
}
}
this._assert(type === name, {
message : message,
operator : 'type',
expected : name,
actual : type,
extra : extra
});
}
}
require('abstract-nosql/abstract/open-test').args(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/open-test').open(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/del-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/isExists-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/get-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/getbuffer-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/mget-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/put-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/put-get-del-test').all(MemDOWN, test, testCommon, testBuffer)
require('abstract-nosql/abstract/batch-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/chained-batch-test').all(MemDOWN, test, testCommon)
require('abstract-nosql/abstract/close-test').close(MemDOWN, test, testCommon)
require('abstract-iterator/abstract/iterator-test').all(MemDOWN, test, testCommon)
require('abstract-iterator/abstract/ranges-test').all(MemDOWN, test, testCommon)
require('./test-memDOWN.js').all(test, testCommon)