Repository navigation
Expand file tree
/
Copy pathhashtable.js
More file actions
57 lines (44 loc) · 1.51 KB
/
Copy pathhashtable.js
File metadata and controls
57 lines (44 loc) · 1.51 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
var HashMap = require('..'),
test = require('test-more')();
var hashmap = new HashMap();
test.ok(hashmap, 'new HashMap()')
.test('put/set', function(test) {
test
.is(function() {
hashmap.put('42', 42);
return hashmap.get('42');
}, 42, 'integer')
.is(function() {
hashmap.put('str', 'hello world');
return hashmap.get('str');
}, 'hello world', 'string')
.is(function() {
hashmap.put('decimal', 0.5);
return hashmap.get('decimal');
}, 0.5, 'decimal')
.done();
})
.test('max_load_factor', function(test) {
test
.is(function() {
hashmap.max_load_factor(0.75);
return hashmap.max_load_factor();
}, 0.75, 'set/get 0.75')
.more(function() {
hashmap.max_load_factor(0);
return hashmap.max_load_factor();
}, 0, 'cannot set to 0')
.done();
})
.is(function() {
hashmap.max_load_factor(0.75);
return hashmap.max_load_factor();
}, 0.75, 'set/get max_load_factor 0.75')
.test("object identity", function(test) {
var obj = { hello: 'world' };
hashmap.put('obj', obj);
test.is(hashmap.get('obj'), obj, 'same object')
.isnt(hashmap.get('obj'), { hello: 'world' }, 'different objects, same deep value')
.done();
})
.done();