Example #1
0
 def testParseObjectLiteralMultipleProperties(self):
     string = '{"foo": "bar", baz: quux, 0: 1}'
     parser = self.makeStringParser(string)
     result = parser.parse_object_literal()
     self.assertIsNode('ObjectLiteral', result)
     self.assertEqual(3, len(result.properties))
     for i in range(3):
         self.assertIsNode('ObjectProperty', result.properties[i])
Example #2
0
 def testParseObjectLiteralNumberLiteralKey(self):
     string = "{0:1}"
     parser = self.makeStringParser(string)
     result = parser.parse_object_literal()
     self.assertIsNode('ObjectLiteral', result)
     self.assertEquals(1, len(result.properties))
     property = result.properties[0]
     self.assertIsNode('ObjectProperty', property)
     self.assertIsNode('NumberLiteral', property.name)
     self.assertIsNode('NumberLiteral', property.value)