00001 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall. 00002 # 00003 # This file is part of the Python-on-a-Chip program. 00004 # Python-on-a-Chip is free software: you can redistribute it and/or modify 00005 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1. 00006 # 00007 # Python-on-a-Chip is distributed in the hope that it will be useful, 00008 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00010 # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1 00011 # is seen in the file COPYING up one directory from this. 00012 00013 # 00014 # System Test 160 00015 # Add support for string and tuple replication 00016 # 00017 00018 # Test string replication 00019 s = "farley" * 3 00020 print s 00021 assert s == "farleyfarleyfarley" 00022 assert len(s) == 6*3 00023 assert s*0 == "" 00024 assert s*-42 == "" 00025 00026 # Test tuple replication 00027 t = (2,5,6) * 3 00028 print t 00029 assert t == (2,5,6, 2,5,6, 2,5,6) 00030 assert len(t) == 3*3 00031 assert t*0 == () 00032 assert t*-42 == () 00033 00034 # Also ensure list replication works 00035 r = range(3) * 3 00036 assert r == [0,1,2,0,1,2,0,1,2] 00037 assert len(r) == 3*3 00038 assert r*0 == [] 00039 assert r*-42 == [] 00040 00041 # Just for fun 00042 print [[3,]*3, "three"*3, ('e',)*3]*3