t157.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 157
00015 # Support default args
00016 #
00017 
00018 def foo1(a=42, b=6, c=7):
00019     return (a, b, c)
00020 
00021 print "foo1()=", foo1()
00022 assert foo1() == (42, 6, 7)
00023 assert foo1("forty two") == ("forty two", 6, 7)
00024 assert foo1("forty two", 9) == ("forty two", 9, 7)
00025 assert foo1("forty two", 9, ("test",)) == ("forty two", 9, ("test",))
00026 #assert foo1("forty two", 9, ("test",), "TypeError (0xED") == ("forty two", 9, ("test",))
00027 
00028 
00029 def foo2(a, b=6, c=7):
00030     return (a, b, c)
00031 
00032 print "foo2(42)=", foo2(42)
00033 #assert foo2() == (42, 6, 7) # Expect TypeError (0xED) too few args
00034 assert foo2("forty two") == ("forty two", 6, 7)
00035 assert foo2("forty two", 9) == ("forty two", 9, 7)
00036 assert foo2("forty two", 9, ("test",)) == ("forty two", 9, ("test",))
00037 #assert foo2("forty two", 9, ("test",), "TypeError (0xED)") == ("forty two", 9, ("test",))
00038 
00039 
00040 def foo3(a, b, c=7):
00041     return (a, b, c)
00042 
00043 print "foo3(42, 6)=", foo2(42, 6)
00044 #assert foo3() == (42, 6, 7) # Expect TypeError (0xED) too few args
00045 assert foo3("forty two", 6) == ("forty two", 6, 7)
00046 assert foo3("forty two", 6, 9) == ("forty two", 6, 9)
00047 assert foo3("forty two", 6, ("test",)) == ("forty two", 6, ("test",))
00048 #assert foo3("forty two", 9, ("test",), "TypeError (0xED)") == ("forty two", 9, ("test",))

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