t162.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 162
00015 # Implement builtin function dir()
00016 #
00017 
00018 
00019 # Check dir on globals
00020 print "dir() = ",dir()
00021 assert dir() == ["__bi"]
00022 
00023 
00024 # Check dir on a function
00025 def foo():
00026     pass
00027 d = dir()
00028 assert "__bi" in d and "foo" in d
00029 assert dir(foo) == []
00030 
00031 foo.bar = "bar"
00032 assert dir(foo) == ["bar"]
00033 
00034 
00035 # Check dir on a module
00036 import sys
00037 d = dir()
00038 assert "sys" in d
00039 d = dir(sys)
00040 print "dir(sys) = ",d
00041 assert "heap" in d

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