Commit e2a1eecc authored by Leandro Lameiro's avatar Leandro Lameiro

Add dict.has_key + tests

parent a89e4d16
...@@ -322,6 +322,7 @@ void setupDict() { ...@@ -322,6 +322,7 @@ void setupDict() {
dict_cls->giveAttr("clear", new BoxedFunction(boxRTFunction((void*)dictClear, NONE, 1))); dict_cls->giveAttr("clear", new BoxedFunction(boxRTFunction((void*)dictClear, NONE, 1)));
dict_cls->giveAttr("copy", new BoxedFunction(boxRTFunction((void*)dictCopy, DICT, 1))); dict_cls->giveAttr("copy", new BoxedFunction(boxRTFunction((void*)dictCopy, DICT, 1)));
dict_cls->giveAttr("has_key", new BoxedFunction(boxRTFunction((void*)dictContains, BOXED_BOOL, 2)));
dict_cls->giveAttr("fromkeys", dict_cls->giveAttr("fromkeys",
new BoxedFunction(boxRTFunction((void*)dictFromkeys, DICT, 3, 1, false, false), { None })); new BoxedFunction(boxRTFunction((void*)dictFromkeys, DICT, 3, 1, false, false), { None }));
dict_cls->giveAttr("items", new BoxedFunction(boxRTFunction((void*)dictItems, LIST, 1))); dict_cls->giveAttr("items", new BoxedFunction(boxRTFunction((void*)dictItems, LIST, 1)));
......
...@@ -138,3 +138,11 @@ try: ...@@ -138,3 +138,11 @@ try:
assert 0 assert 0
except TypeError, e: except TypeError, e:
print 'ok' print 'ok'
# has_key
d = {1:2, 3:4, 'a': 5}
print d.has_key(1)
print d.has_key(42)
print d.has_key('a')
print d.has_key('b')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment