t147.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 147
00015 # Support Boolean type and True/False constants
00016 #
00017 
00018 print "True == ", True
00019 print "False == ", False
00020 print "not True == ", not True
00021 print "not False == ", not False
00022 
00023 assert True
00024 assert not False
00025 
00026 assert not True == False
00027 assert not False == True
00028 
00029 assert True == (0 == 0)
00030 assert False == (0 == 1)
00031 
00032 assert True == 1
00033 assert 1 == True
00034 assert False == 0
00035 assert 0 == False
00036 
00037 assert ('f','t','z')[False] == 'f'
00038 assert ('f','t','z')[True] == 't'
00039 
00040 assert range(3)[True] == 1
00041 assert range(3)[False] == 0
00042 
00043 d = {}
00044 d[True] = "t"
00045 d[False] = "f"
00046 
00047 assert d[0] == "f"
00048 assert d[1] == "t"
00049 
00050 d = {}
00051 d[0] = "f"
00052 d[1] = "t"
00053 
00054 assert d[False] == "f"
00055 assert d[True] == "t"

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