00001 # 00002 # PyMite - A flyweight Python interpreter for 8-bit and larger microcontrollers. 00003 # Copyright 2002 Dean Hall. All rights reserved. 00004 # PyMite is offered through one of two licenses: commercial or open-source. 00005 # See the LICENSE file at the root of this package for licensing details. 00006 # 00007 00008 # 00009 # System Test 158 00010 # Fix builtin sum() to support float 00011 # 00012 00013 00014 l1 = [1, 2, 3] 00015 assert sum(l1) == 6 00016 print l1 00017 00018 l2 = [1, 2, 3, 4.0] 00019 assert sum(l2) == 10.0 00020 print l2 00021 00022 l3 = [1.0, 2.0, 3.0] 00023 assert sum(l3) == 6.0 00024 print l3 00025 00026 # PyMite VM uses float type, not double; so this test passes here, 00027 # but would fail if run on the CPython VM. 00028 l4 = [1.1, 2.2, 3.3] 00029 assert sum(l4) != 6.6 # Rounding issue causes not-equal 00030 print l4 00031 00032 l5 = [1.1, 2.2, 3.3, 4.4] 00033 assert sum(l5) == 11.0 00034 print l5