summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python/py-value.exp
diff options
context:
space:
mode:
authorpmuldoon <pmuldoon>2010-05-14 11:11:25 +0000
committerpmuldoon <pmuldoon>2010-05-14 11:11:25 +0000
commit0bd6c4c5348c22cd439a4ccfea82f2b9396689f1 (patch)
tree761891570ce61b87c57f55e63ea33e1f44bf50c8 /gdb/testsuite/gdb.python/py-value.exp
parent37fa870f3822cb3ad1f3a62a0b57d007aead9f4a (diff)
downloadgdb-0bd6c4c5348c22cd439a4ccfea82f2b9396689f1.tar.gz
2010-05-14 Phil Muldoon <pmuldoon@redhat.com>
PR python/11482 * python/py-value.c (valpy_hash): New function. (value_object_type): Register valpy_hash. 2010-05-14 Phil Muldoon <pmuldoon@redhat.com> PR python/11482 * gdb.python/py-value.exp (test_value_hash): New function
Diffstat (limited to 'gdb/testsuite/gdb.python/py-value.exp')
-rw-r--r--gdb/testsuite/gdb.python/py-value.exp18
1 files changed, 18 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp
index 3bfa17317cc..67a2ff9d147 100644
--- a/gdb/testsuite/gdb.python/py-value.exp
+++ b/gdb/testsuite/gdb.python/py-value.exp
@@ -393,6 +393,23 @@ proc test_parse_and_eval {} {
"parse_and_eval type test"
}
+# Test that values are hashable.
+proc test_value_hash {} {
+ gdb_py_test_multiple "Simple Python value dictionary" \
+ "python" "" \
+ "one = gdb.Value(1)" "" \
+ "two = gdb.Value(2)" "" \
+ "three = gdb.Value(3)" "" \
+ "vdict = {one:\"one str\",two:\"two str\",three:\"three str\"}" "" \
+ "end"
+ gdb_test "python print vdict\[one\]" "one str" "Test dictionary hash"
+ gdb_test "python print vdict\[two\]" "two str" "Test dictionary hash"
+ gdb_test "python print vdict\[three\]" "three str" "Test dictionary hash"
+ gdb_test "python print one.__hash__() == hash(one)" "True" "Test inbuilt hash"
+ gdb_test "python print one.__hash__() == id(one)" "True" "Test inbuilt id"
+}
+
+
# Start with a fresh gdb.
gdb_exit
@@ -409,6 +426,7 @@ test_value_boolean
test_value_compare
test_objfiles
test_parse_and_eval
+test_value_hash
# The following tests require execution.