qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r894161 - in /qpid/branches/qpid.rnr/python/qpid: address.py tests/address.py
Date Mon, 28 Dec 2009 12:43:51 GMT
Author: rhs
Date: Mon Dec 28 12:43:50 2009
New Revision: 894161

URL: http://svn.apache.org/viewvc?rev=894161&view=rev
Log:
allow any value as a map key

Modified:
    qpid/branches/qpid.rnr/python/qpid/address.py
    qpid/branches/qpid.rnr/python/qpid/tests/address.py

Modified: qpid/branches/qpid.rnr/python/qpid/address.py
URL: http://svn.apache.org/viewvc/qpid/branches/qpid.rnr/python/qpid/address.py?rev=894161&r1=894160&r2=894161&view=diff
==============================================================================
--- qpid/branches/qpid.rnr/python/qpid/address.py (original)
+++ qpid/branches/qpid.rnr/python/qpid/address.py Mon Dec 28 12:43:50 2009
@@ -102,8 +102,8 @@
 
     result = {}
     while True:
-      if self.matches(ID):
-        n, v = self.nameval()
+      if self.matches(NUMBER, STRING, ID, LBRACE, LBRACK):
+        n, v = self.keyval()
         result[n] = v
         if self.matches(COMMA):
           self.eat(COMMA)
@@ -114,16 +114,17 @@
       elif self.matches(RBRACE):
         break
       else:
-        raise ParseError(self.next(), ID, RBRACE)
+        raise ParseError(self.next(), NUMBER, STRING, ID, LBRACE, LBRACK,
+                         RBRACE)
 
     self.eat(RBRACE)
     return result
 
-  def nameval(self):
-    name = self.eat(ID).value
+  def keyval(self):
+    key = self.value()
     self.eat(COLON)
     val = self.value()
-    return (name, val)
+    return (key, val)
 
   def value(self):
     if self.matches(NUMBER, STRING, ID):

Modified: qpid/branches/qpid.rnr/python/qpid/tests/address.py
URL: http://svn.apache.org/viewvc/qpid/branches/qpid.rnr/python/qpid/tests/address.py?rev=894161&r1=894160&r2=894161&view=diff
==============================================================================
--- qpid/branches/qpid.rnr/python/qpid/tests/address.py (original)
+++ qpid/branches/qpid.rnr/python/qpid/tests/address.py Mon Dec 28 12:43:50 2009
@@ -136,12 +136,13 @@
 
   def testBadOptions1(self):
     self.invalid("name/subject; {",
-                 "expecting (ID, RBRACE), got EOF line:1,15:name/subject; {")
+                 "expecting (NUMBER, STRING, ID, LBRACE, LBRACK, RBRACE), "
+                 "got EOF line:1,15:name/subject; {")
 
   def testBadOptions2(self):
     self.invalid("name/subject; { 3",
-                 "expecting (ID, RBRACE), got NUMBER('3') "
-                 "line:1,16:name/subject; { 3")
+                 "expecting COLON, got EOF "
+                 "line:1,17:name/subject; { 3")
 
   def testBadOptions3(self):
     self.invalid("name/subject; { key:",
@@ -160,7 +161,7 @@
 
   def testBadOptions6(self):
     self.invalid("name/subject; { key: value,",
-                 "expecting (ID, RBRACE), got EOF "
+                 "expecting (NUMBER, STRING, ID, LBRACE, LBRACK, RBRACE), got EOF "
                  "line:1,27:name/subject; { key: value,")
 
   def testBadOptions7(self):
@@ -197,3 +198,14 @@
   def testBadList4(self):
     self.invalid("name/subject; { key: [ 1 2 ] }", "expecting (COMMA, RBRACK), "
                  "got NUMBER('2') line:1,25:name/subject; { key: [ 1 2 ] }")
+
+  def testMap1(self):
+    self.valid("name/subject; { 'key': value }",
+               "name", "subject", {"key": "value"})
+
+  def testMap2(self):
+    self.valid("name/subject; { 1: value }", "name", "subject", {1: "value"})
+
+  def testMap3(self):
+    self.valid('name/subject; { "foo.bar": value }',
+               "name", "subject", {"foo.bar": "value"})



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message