summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2010-04-08 01:26:27 +0200
committerhut <hut@lavabit.com>2010-04-08 01:26:27 +0200
commitef011c914dcf6061af7b30c85db53336594cab81 (patch)
treed0a01beebfeac436e0dfacef4a27d51af454b5cd
parent4e9384fd9ebcf1c17909dbf2b1e94f0b3ec9100b (diff)
downloadranger-ef011c914dcf6061af7b30c85db53336594cab81.tar.gz
tc_newkey: added 2 failing test cases. Fix it!
-rw-r--r--test/tc_newkeys.py66
1 files changed, 53 insertions, 13 deletions
diff --git a/test/tc_newkeys.py b/test/tc_newkeys.py
index a79ba83f..fc17aeda 100644
--- a/test/tc_newkeys.py
+++ b/test/tc_newkeys.py
@@ -500,35 +500,75 @@ class Test(PressTestCase):
 
 		buffer = KeyBuffer(None, None)
 		press = self._mkpress(buffer)
-		kmc = KeyManager(buffer, ['foo', 'bar'])
+		keymanager = KeyManager(buffer, ['foo', 'bar'])
 
-		map = kmc.get_context('foo')
+		map = keymanager.get_context('foo')
 		map('a', func)
 		map('b', func)
-		map = kmc.get_context('bar')
+		map = keymanager.get_context('bar')
 		map('c', func)
 		map('<dir>', getdown)
 
-		kmc.map('directions', 'j', dir=Direction(down=1))
+		keymanager.map('directions', 'j', dir=Direction(down=1))
 
-		kmc.use_context('foo')
+		keymanager.use_context('foo')
 		self.assertEqual(5, press('a'))
 		self.assertEqual(5, press('b'))
 		self.assertPressFails(buffer, 'c')
 
-		kmc.use_context('bar')
+		keymanager.use_context('bar')
 		self.assertPressFails(buffer, 'a')
 		self.assertPressFails(buffer, 'b')
 		self.assertEqual(5, press('c'))
 		self.assertEqual(1, press('j'))
-		kmc.use_context('foo')
-		kmc.use_context('foo')
-		kmc.use_context('foo')
-		kmc.use_context('bar')
-		kmc.use_context('foo')
-		kmc.use_context('bar')
-		kmc.use_context('bar')
+		keymanager.use_context('foo')
+		keymanager.use_context('foo')
+		keymanager.use_context('foo')
+		keymanager.use_context('bar')
+		keymanager.use_context('foo')
+		keymanager.use_context('bar')
+		keymanager.use_context('bar')
 		self.assertEqual(1, press('j'))
 
+	def test_alias_to_direction(self):
+		def func(arg):
+			return arg.direction.down()
+
+		km = KeyMap()
+		directions = KeyMap()
+		kb = KeyBuffer(km, directions)
+		press = self._mkpress(kb)
+
+		km.map('<dir>', func)
+		directions.map('j', dir=Direction(down=42))
+		self.assertEqual(42, press('j'))
+
+		km.map('o', alias='j')
+		self.assertEqual(42, press('o'))
+
+	def test_both_directory_and_any_key(self):
+		def func(arg):
+			return arg.direction.down()
+		def func2(arg):
+			return "yay"
+
+		km = KeyMap()
+		directions = KeyMap()
+		kb = KeyBuffer(km, directions)
+		press = self._mkpress(kb)
+
+		km.map('abc<dir>', func)
+		directions.map('j', dir=Direction(down=42))
+		self.assertEqual(42, press('abcj'))
+
+		km.unmap('abc<dir>')
+
+		km.map('abc<any>', func2)
+		self.assertEqual("yay", press('abcd'))
+
+		km.map('abc<dir>', func)
+
+		km.map('abc<any>', func2)
+		self.assertEqual("yay", press('abcd'))
 
 if __name__ == '__main__': main()
/CLI.rakumod?id=02cd965f42d93e9951917d7a99d1d7e711f448d3'>02cd965 ^
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112