t205.py

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 205
00015 # Add support for string format operation
00016 #
00017 
00018 i = 4
00019 s1 = "test %d" % i
00020 s2 = "test %d" % (i,)
00021 assert s1 == s2 == "test 4"
00022 
00023 i = 205
00024 s1 = "test t%03d" % i
00025 s2 = "test t%03d" % (i,)
00026 print s1
00027 assert s1 == s2 == "test t205"
00028 
00029 f = -3.14
00030 s1 = "test %f this" % f
00031 s2 = "test %f this" % (f,)
00032 assert s1 == s2 == "test -3.140000 this"
00033 
00034 f = -3.14
00035 s1 = "test %1.2f" % f
00036 s2 = "test %1.2f" % (f,)
00037 assert s1 == s2 == "test -3.14"
00038 
00039 s = "this"
00040 s1 = "test %s string" % s
00041 s2 = "test %s string" % (s,)
00042 assert s1 == s2 == "test this string"
00043 
00044 d = 4
00045 s = "score"
00046 f = 7.0
00047 s = "%d %s and %.0f years ago" % (d,s,f,)
00048 print s
00049 assert s == "4 score and 7 years ago"

Generated on Mon Oct 18 07:40:47 2010 for Python-on-a-chip by  doxygen 1.5.9