Skip to content

Commit 96e7825

Browse files
committed
Add failing test for eval'd numeric array keys
1 parent 47df850 commit 96e7825

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

tests/test_dbgp_eval_property.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
if __name__ == "__main__":
2+
import sys
3+
sys.path.append('../plugin/python/')
4+
import unittest2 as unittest
5+
import vdebug.dbgp
6+
import xml.etree.ElementTree as ET
7+
8+
class EvalPropertyTest(unittest.TestCase):
9+
def __get_eval_property(self,xml_string,code,lang):
10+
xml = ET.fromstring(xml_string)
11+
firstnode = xml[0]
12+
return vdebug.dbgp.EvalProperty(firstnode,code,lang)
13+
14+
def test_numeric_keys(self):
15+
prop = self.__get_eval_property(\
16+
"""<?xml version="1.0" encoding="iso-8859-1"?>
17+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="13">
18+
<property
19+
address="140722906708544" type="array"
20+
children="1" numchildren="2" page="0" pagesize="32">
21+
<property
22+
name="0" address="140022315302704"
23+
type="array" children="1" numchildren="1"></property>
24+
<property
25+
name="key" address="140022315307008"
26+
type="array" children="1" numchildren="1"></property>
27+
</property>
28+
</response>
29+
""", '$testarr', 'php')
30+
31+
self.assertEqual(prop.display_name,'$testarr')
32+
self.assertEqual(prop.value,'')
33+
self.assertEqual(prop.type,'array')
34+
self.assertEqual(prop.depth,0)
35+
self.assertTrue(prop.has_children)
36+
self.assertEqual(prop.child_count(),2)
37+
38+
self.assertEqual(prop.children[0].type,'array')
39+
self.assertEqual(prop.children[0].display_name,'$testarr[0]')
40+
41+
self.assertEqual(prop.children[1].type,'array')
42+
self.assertEqual(prop.children[1].display_name,"$testarr['key']")

0 commit comments

Comments
 (0)