corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 var tap = require("tap")
2 , test = tap.test
3 , ProtoList = require("../proto-list.js")
4  
5 tap.plan(1)
6  
7 tap.test("protoList tests", function (t) {
8 var p = new ProtoList
9 p.push({foo:"bar"})
10 p.push({})
11 p.set("foo", "baz")
12 t.equal(p.get("foo"), "baz")
13  
14 var p = new ProtoList
15 p.push({foo:"bar"})
16 p.set("foo", "baz")
17 t.equal(p.get("foo"), "baz")
18 t.equal(p.length, 1)
19 p.pop()
20 t.equal(p.length, 0)
21 p.set("foo", "asdf")
22 t.equal(p.length, 1)
23 t.equal(p.get("foo"), "asdf")
24 p.push({bar:"baz"})
25 t.equal(p.length, 2)
26 t.equal(p.get("foo"), "asdf")
27 p.shift()
28 t.equal(p.length, 1)
29 t.equal(p.get("foo"), undefined)
30  
31  
32 p.unshift({foo:"blo", bar:"rab"})
33 p.unshift({foo:"boo"})
34 t.equal(p.length, 3)
35 t.equal(p.get("foo"), "boo")
36 t.equal(p.get("bar"), "rab")
37  
38 var ret = p.splice(1, 1, {bar:"bar"})
39 t.same(ret, [{foo:"blo", bar:"rab"}])
40 t.equal(p.get("bar"), "bar")
41  
42 // should not inherit default object properties
43 t.equal(p.get('hasOwnProperty'), undefined)
44  
45 // unless we give it those.
46 p.root = {}
47 t.equal(p.get('hasOwnProperty'), {}.hasOwnProperty)
48  
49 p.root = {default:'monkey'}
50 t.equal(p.get('default'), 'monkey')
51  
52 p.push({red:'blue'})
53 p.push({red:'blue'})
54 p.push({red:'blue'})
55 while (p.length) {
56 t.equal(p.get('default'), 'monkey')
57 p.shift()
58 }
59  
60 t.end()
61 })