Skip to content

Commit

Permalink
Add float comparison to test file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferri committed Jan 24, 2018
1 parent 9721d38 commit 1ed2b17
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_ObjectPath.py
Expand Up @@ -68,8 +68,27 @@
}
}

object3={
"item_1": {
"value": "foo",
"x": 5.6,
"y": 9
},
"item_2": {
"value": "bar",
"x": 5.6,
"y": 9.891
},
"item_3": {
"value": "foobar",
"x": 5.6,
"y": 9.8
}
}

tree1=Tree(object1)
tree2=Tree(object2)
tree3=Tree(object3)

def execute_raw(expr):
return tree1.execute(expr)
Expand All @@ -93,6 +112,13 @@ def execute2(expr):
else:
return r

def execute3(expr):
r=tree3.execute(expr)
if isinstance(r, TYPES):
return list(r)
else:
return r

class ObjectPath(unittest.TestCase):
def test_simple_types(self):
self.assertEqual(execute("null"), None)
Expand Down Expand Up @@ -424,6 +450,7 @@ def test_selectors(self):
self.assertEqual(execute("$..*[@._id>1 and @._id<3][0]"), {'_id': 2})
# very bad syntax!!!
self.assertEqual(sorted(execute2("$.store.book[@.price]")), sorted([8.95,12.99,8.99,22.99]))
self.assertEqual(execute3("$..*[@.x is 5.6 and @.y is 9.891].value"), ['bar'])

#testcase2=unittest.FunctionTestCase(test_efficiency(2))
testcase1=unittest.TestLoader().loadTestsFromTestCase(ObjectPath)
Expand Down

0 comments on commit 1ed2b17

Please sign in to comment.