Software /
code /
prosody
Annotate
tests/test_util_cache.lua @ 6987:06696882d972
mod_admin_telnet: Add http:list() command to get info about current HTTP endpoints on the server
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 10 Dec 2015 18:00:08 +0000 |
parent | 6946:31fb9eb9edce |
child | 7016:e0a0af42b09f |
rev | line source |
---|---|
6946
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 function new(new) |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 local c = new(5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 assert_equal(c:count(), 0); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 c:set("one", 1) |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 assert_equal(c:count(), 1); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 c:set("two", 2) |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 c:set("three", 3) |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 c:set("four", 4) |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 c:set("five", 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 c:set("foo", nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 assert_equal(c:get("one"), 1); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 assert_equal(c:get("two"), 2); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 assert_equal(c:get("three"), 3); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 assert_equal(c:get("five"), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 assert_equal(c:get("foo"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 assert_equal(c:get("bar"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 c:set("six", 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 assert_equal(c:get("two"), 2); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 assert_equal(c:get("three"), 3); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 assert_equal(c:get("five"), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 c:set("three", nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 assert_equal(c:count(), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 assert_equal(c:get("two"), 2); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 assert_equal(c:get("five"), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 c:set("seven", 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 assert_equal(c:get("two"), 2); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 assert_equal(c:get("five"), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 c:set("eight", 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 assert_equal(c:get("two"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 assert_equal(c:get("five"), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 assert_equal(c:get("eight"), 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 c:set("four", 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 assert_equal(c:get("two"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 assert_equal(c:get("five"), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 assert_equal(c:get("eight"), 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 c:set("nine", 9); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 assert_equal(c:get("two"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 assert_equal(c:get("four"), 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 assert_equal(c:get("five"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 assert_equal(c:get("eight"), 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 assert_equal(c:get("nine"), 9); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 local keys = { "nine", "four", "eight", "seven", "six" }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 local values = { 9, 4, 8, 7, 6 }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 local i = 0; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 for k, v in c:items() do |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 i = i + 1; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 assert_equal(k, keys[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 assert_equal(v, values[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 end |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 assert_equal(i, 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 c:set("four", "2+2"); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 assert_equal(c:get("two"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 assert_equal(c:get("four"), "2+2"); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 assert_equal(c:get("five"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 assert_equal(c:get("eight"), 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 assert_equal(c:get("nine"), 9); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 local keys = { "four", "nine", "eight", "seven", "six" }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 local values = { "2+2", 9, 8, 7, 6 }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 local i = 0; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 for k, v in c:items() do |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 i = i + 1; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 assert_equal(k, keys[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 assert_equal(v, values[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 end |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 assert_equal(i, 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 c:set("foo", nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 assert_equal(c:count(), 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 assert_equal(c:get("two"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 assert_equal(c:get("four"), "2+2"); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 assert_equal(c:get("five"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 assert_equal(c:get("eight"), 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 assert_equal(c:get("nine"), 9); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 local keys = { "four", "nine", "eight", "seven", "six" }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 local values = { "2+2", 9, 8, 7, 6 }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 local i = 0; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 for k, v in c:items() do |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 i = i + 1; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 assert_equal(k, keys[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 assert_equal(v, values[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 end |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 assert_equal(i, 5); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
151 c:set("four", nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
152 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
153 assert_equal(c:get("one"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
154 assert_equal(c:get("two"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
155 assert_equal(c:get("three"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
156 assert_equal(c:get("four"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
157 assert_equal(c:get("five"), nil); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
158 assert_equal(c:get("six"), 6); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
159 assert_equal(c:get("seven"), 7); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
160 assert_equal(c:get("eight"), 8); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
161 assert_equal(c:get("nine"), 9); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
162 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
163 local keys = { "nine", "eight", "seven", "six" }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
164 local values = { 9, 8, 7, 6 }; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
165 local i = 0; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
166 for k, v in c:items() do |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
167 i = i + 1; |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
168 assert_equal(k, keys[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
169 assert_equal(v, values[i]); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
170 end |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
171 assert_equal(i, 4); |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
172 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
173 |
31fb9eb9edce
tests: Add tests for util.cache
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
174 end |