diff options
author | hut <hut@lavabit.com> | 2010-03-09 12:40:51 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2010-03-09 14:40:24 +0100 |
commit | efbde17048b14d43895e4cf91e798fb97702b68f (patch) | |
tree | e3abf4aea43ac6d615003534c3e152278cb17b65 /test/tc_newkeys.py | |
parent | 4a435286452a8a0177994a6f27f3806cdb74fa82 (diff) | |
download | ranger-efbde17048b14d43895e4cf91e798fb97702b68f.tar.gz |
keyparser: test for collisions with directories of a lenght > 1
Diffstat (limited to 'test/tc_newkeys.py')
-rw-r--r-- | test/tc_newkeys.py | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/test/tc_newkeys.py b/test/tc_newkeys.py index 92bfb513..0c810af5 100644 --- a/test/tc_newkeys.py +++ b/test/tc_newkeys.py @@ -83,6 +83,31 @@ class Test(PressTestCase): self.assert_(match.function) self.assertEqual(8, match.function(args)) + def test_map_collision(self): + def add_dirs(arg): + return sum(dir.down for dir in arg.directions) + def return5(_): + return 5 + + + directions = KeyMap() + directions.map('gg', dir=Direction(down=1)) + + + km = KeyMap() + km.map('gh', return5) + km.map('agh', return5) + km.map('a<dir>', add_dirs) + + kb = KeyBuffer(km, directions) + press = self._mkpress(kb, km) + + self.assertEqual(5, press('gh')) + self.assertEqual(5, press('agh')) +# self.assertPressFails(kb, 'agh') + self.assertEqual(1, press('agg')) + + def test_translate_keys(self): def test(string, *args): if not args: @@ -120,10 +145,7 @@ class Test(PressTestCase): def test_alias(self): def add_dirs(arg): - n = 0 - for dir in arg.directions: - n += dir.down - return n + return sum(dir.down for dir in arg.directions) def return5(_): return 5 @@ -379,10 +401,7 @@ class Test(PressTestCase): directions.map('k', dir=Direction(down=-1)) def add_dirs(arg): - n = 0 - for dir in arg.directions: - n += dir.down - return n + return sum(dir.down for dir in arg.directions) km.map('x<dir>y<dir>', add_dirs) km.map('four<dir><dir><dir><dir>', add_dirs) |