Skip to content

Commit

Permalink
Merge pull request beeware#682 from onyb/add-sum-builtin-tests
Browse files Browse the repository at this point in the history
Add more tests for the sum builtin
  • Loading branch information
freakboy3742 authored Oct 26, 2017
2 parents 613023c + cd1eac1 commit 7513088
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/builtins/test_sum.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class SumTests(TranspileTestCase):
def test_sum_list(self):
self.assertCodeExecution("""
print(sum([1, 2, 3, 4, 5, 6, 7]))
print(sum([[1, 2], [3, 4], [5, 6]], []))
""")

def test_sum_tuple(self):
Expand All @@ -24,10 +25,29 @@ def test_sum_mix_floats_and_ints(self):
print(sum([1, 1.414, 2, 3.14159]))
""")

def test_sum_frozenset(self):
self.assertCodeExecution("""
print(sum(frozenset([1, 1.414, 2, 3.14159])))
""")

def test_sum_set(self):
self.assertCodeExecution("""
print(sum({1, 1.414, 2, 3.14159}))
""")

def test_sum_dict(self):
self.assertCodeExecution("""
print(sum({1: 1.414, 2: 3.14159}))
""")

def test_sum_generator_expressions(self):
self.assertCodeExecution("""
print(sum(x ** 2 for x in [3, 4]))
""")


class BuiltinSumFunctionTests(BuiltinFunctionTestCase, TranspileTestCase):
functions = ["sum"]

not_implemented = [
'test_frozenzet',
]

0 comments on commit 7513088

Please sign in to comment.