mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
replace unneeded eval() call and support negative versionCodes
This commit is contained in:
parent
f0d27e1fa5
commit
4503e7a92a
2 changed files with 23 additions and 6 deletions
|
|
@ -800,13 +800,26 @@ class CommonTest(unittest.TestCase):
|
|||
fdroidserver.common.parse_androidmanifests(paths, app))
|
||||
|
||||
def test_calculate_math_string(self):
|
||||
self.assertEqual(1234, fdroidserver.common.calculate_math_string('1234'))
|
||||
self.assertEqual(4, fdroidserver.common.calculate_math_string('(1+1)*2'))
|
||||
self.assertEqual(2, fdroidserver.common.calculate_math_string('(1-1)*2+3*1-1'))
|
||||
self.assertEqual(1234,
|
||||
fdroidserver.common.calculate_math_string('1234'))
|
||||
self.assertEqual((1 + 1) * 2,
|
||||
fdroidserver.common.calculate_math_string('(1 + 1) * 2'))
|
||||
self.assertEqual((1 - 1) * 2 + 3 * 1 - 1,
|
||||
fdroidserver.common.calculate_math_string('(1 - 1) * 2 + 3 * 1 - 1'))
|
||||
self.assertEqual(0 - 12345,
|
||||
fdroidserver.common.calculate_math_string('0 - 12345'))
|
||||
self.assertEqual(0xffff,
|
||||
fdroidserver.common.calculate_math_string('0xffff'))
|
||||
self.assertEqual(0xcafe * 123,
|
||||
fdroidserver.common.calculate_math_string('0xcafe * 123'))
|
||||
self.assertEqual(-1,
|
||||
fdroidserver.common.calculate_math_string('-1'))
|
||||
with self.assertRaises(SyntaxError):
|
||||
fdroidserver.common.calculate_math_string('__import__("urllib")')
|
||||
with self.assertRaises(SyntaxError):
|
||||
fdroidserver.common.calculate_math_string('self')
|
||||
with self.assertRaises(SyntaxError):
|
||||
fdroidserver.common.calculate_math_string('Ox9()')
|
||||
with self.assertRaises(SyntaxError):
|
||||
fdroidserver.common.calculate_math_string('1+1; print(1)')
|
||||
with self.assertRaises(SyntaxError):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue