diff --git a/include/boost/python/suite/indexing/testarray.py b/include/boost/python/suite/indexing/testarray.py new file mode 100755 index 00000000..ca85654f --- /dev/null +++ b/include/boost/python/suite/indexing/testarray.py @@ -0,0 +1,35 @@ +#!/usr/bin/python +# -*- mode:python -*- +# +# Python module testarray.py +# +# Copyright (c) 2003 Raoul M. Gough +# +# This material is provided "as is", with absolutely no warranty expressed +# or implied. Any use is at your own risk. +# +# Permission to use or copy this material for any purpose is hereby +# granted without fee, provided the above notices are retained on all +# copies. Permission to modify the material and to distribute modified +# versions is granted, provided the above notices are retained, and a +# notice that the material was modified is included with the above +# copyright notice. +# +# History +# ======= +# 2003/ 9/ 9 rmg File creation +# +# $Id$ +# + +from testsuite import Array, getArray + +a = getArray() + +print a[0], a[1], a[2], [x for x in a], a[0:-2], a[-1:-3:-1], a[0:54:0] + +a[1] = 4 + +print a[0], a[1], a[2], [x for x in a], a[0:-2], a[-1:-3:-1] + +print a[0:43] diff --git a/include/boost/python/suite/indexing/testmap.py b/include/boost/python/suite/indexing/testmap.py new file mode 100755 index 00000000..79e12d9b --- /dev/null +++ b/include/boost/python/suite/indexing/testmap.py @@ -0,0 +1,54 @@ +#!/usr/bin/python +# -*- mode:python -*- +# +# Python module testmap.py +# +# Copyright (c) 2003 Raoul M. Gough +# +# This material is provided "as is", with absolutely no warranty expressed +# or implied. Any use is at your own risk. +# +# Permission to use or copy this material for any purpose is hereby +# granted without fee, provided the above notices are retained on all +# copies. Permission to modify the material and to distribute modified +# versions is granted, provided the above notices are retained, and a +# notice that the material was modified is included with the above +# copyright notice. +# +# History +# ======= +# 2003/ 9/ 9 rmg File creation +# +# $Id$ +# + +from testsuite import Map + +m = Map() + +m["hello"] = 1 +m["there"] = 2 + +print m["hello"], m["there"] + +m["there"] = 3 + +print m["hello"], m["there"] + +try: + print [x for x in m] + +except TypeError, e: + print "Got semi-expected type error:", e + pass + +try: + print m["nonesuch"] + +except KeyError, e: + print "Got expected exception:", e + pass + +except Exception, e: + print "Got semi-expected exception:", e + pass diff --git a/include/boost/python/suite/indexing/testvector.py b/include/boost/python/suite/indexing/testvector.py new file mode 100755 index 00000000..4e4b161f --- /dev/null +++ b/include/boost/python/suite/indexing/testvector.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# -*- mode:python -*- +# +# Python module testvector.py +# +# Copyright (c) 2003 Raoul M. Gough +# +# This material is provided "as is", with absolutely no warranty expressed +# or implied. Any use is at your own risk. +# +# Permission to use or copy this material for any purpose is hereby +# granted without fee, provided the above notices are retained on all +# copies. Permission to modify the material and to distribute modified +# versions is granted, provided the above notices are retained, and a +# notice that the material was modified is included with the above +# copyright notice. +# +# History +# ======= +# 2003/ 9/ 9 rmg File creation +# +# $Id$ +# + +from testsuite import Vector + +v = Vector() + +v.append(1) +v.append(2) +v.append(3) + +print v[0], v[1], v[2], [x for x in v] + +v[1] = 4 + +print v[0], v[1], v[2], [x for x in v] + +print v[0:2]