Mercurial > prosody-hg
comparison tests/test_util_multitable.lua @ 7472:8965ad0aed2c
test_util_multitable: make mt variable local [luacheck]
| author | Anton Shestakov <av6@dwimlabs.net> |
|---|---|
| date | Sat, 09 Jul 2016 00:53:46 +0800 |
| parents | bd0ff8ae98a8 |
| children | ef6505962351 |
comparison
equal
deleted
inserted
replaced
| 7471:3631d259bb85 | 7472:8965ad0aed2c |
|---|---|
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 | 9 |
| 10 function new(new, multitable) | 10 function new(new, multitable) |
| 11 mt = new(); | 11 local mt = new(); |
| 12 assert_table(mt, "Multitable is a table"); | 12 assert_table(mt, "Multitable is a table"); |
| 13 assert_function(mt.add, "Multitable has method add"); | 13 assert_function(mt.add, "Multitable has method add"); |
| 14 assert_function(mt.get, "Multitable has method get"); | 14 assert_function(mt.get, "Multitable has method get"); |
| 15 assert_function(mt.remove, "Multitable has method remove"); | 15 assert_function(mt.remove, "Multitable has method remove"); |
| 16 | 16 |
| 38 end | 38 end |
| 39 local function assert_has_all(message, list, ...) | 39 local function assert_has_all(message, list, ...) |
| 40 return assert_equal(select(2, has_items(list, ...)), "has-all", message or "List has all expected items, and no more", 2); | 40 return assert_equal(select(2, has_items(list, ...)), "has-all", message or "List has all expected items, and no more", 2); |
| 41 end | 41 end |
| 42 | 42 |
| 43 mt = multitable.new(); | 43 local mt = multitable.new(); |
| 44 | 44 |
| 45 local trigger1, trigger2, trigger3 = {}, {}, {}; | 45 local trigger1, trigger2, trigger3 = {}, {}, {}; |
| 46 local item1, item2, item3 = {}, {}, {}; | 46 local item1, item2, item3 = {}, {}, {}; |
| 47 | 47 |
| 48 assert_has_all("Has no items with trigger1", mt:get(trigger1)); | 48 assert_has_all("Has no items with trigger1", mt:get(trigger1)); |
