8810783b9cbf8a0a9de18dbc7d4a03727cfa80b9.svn-base
2.14 KB
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
'use strict'
// A list of all the synonyms of assert methods.
// In addition to these, multi-word camelCase are also synonymized to
// all lowercase and snake_case
const multiword = obj =>
Object.keys(obj).reduce((s, i) =>
(s[i] = [ multiword_(i) ]
.concat(obj[i].map(multiword_))
.reduce((s, i) => (s.push.apply(s, i), s), []), s), obj)
const multiword_ = str =>
str.match(/[A-Z]/) ? [
str,
str.toLowerCase(),
str.replace(/[A-Z]/g, $0 => '_' + $0.toLowerCase())
] : [str]
module.exports = multiword({
ok: ['true', 'assert'],
notOk: ['false', 'assertNot'],
error: ['ifError', 'ifErr'],
throws: ['throw'],
doesNotThrow: ['notThrow'],
// exactly the same. ===
equal: [
'equals', 'isEqual', 'is', 'strictEqual', 'strictEquals', 'strictIs',
'isStrict', 'isStrictly', 'identical'
],
// not equal. !==
not: [
'inequal', 'notEqual', 'notEquals', 'notStrictEqual', 'notStrictEquals',
'isNotEqual', 'isNot', 'doesNotEqual', 'isInequal'
],
// deep equivalence. == for scalars
same: [
'equivalent', 'looseEqual', 'looseEquals', 'deepEqual',
'deepEquals', 'isLoose', 'looseIs', 'isEquivalent'
],
// deep inequivalence. != for scalars
notSame: [
'inequivalent', 'looseInequal', 'notDeep', 'deepInequal',
'notLoose', 'looseNot', 'notEquivalent', 'isNotDeepEqual',
'isNotDeeply', 'notDeepEqual', 'isInequivalent',
'isNotEquivalent'
],
// deep equivalence, === for scalars
strictSame: [
'strictEquivalent', 'strictDeepEqual', 'sameStrict', 'deepIs',
'isDeeply', 'isDeep', 'strictDeepEquals'
],
// deep inequivalence, !== for scalars
strictNotSame: [
'strictInequivalent', 'strictDeepInequal', 'notSameStrict', 'deepNot',
'notDeeply', 'strictDeepInequals', 'notStrictSame'
],
// found has the fields in wanted, string matches regexp
match: [
'has', 'hasFields', 'matches', 'similar', 'like', 'isLike',
'includes', 'include', 'isSimilar', 'contains'
],
notMatch: [
'dissimilar', 'unsimilar', 'notSimilar', 'unlike', 'isUnlike',
'notLike', 'isNotLike', 'doesNotHave', 'isNotSimilar', 'isDissimilar'
],
type: [
'isa', 'isA'
]
})