Commit 89723dc5 authored by Robert Bradshaw's avatar Robert Bradshaw

Add some more typeid tests.

Adds support for simple FakeReference equality testing.
parent defb269d
......@@ -344,6 +344,9 @@ class __Pyx_FakeReference {
__Pyx_FakeReference(const T& ref) : ptr(const_cast<T*>(&ref)) { }
T *operator->() { return ptr; }
operator T&() { return *ptr; }
// TODO(robertwb): Delegate all operators (or auto-generate unwrapping code where needed).
template<typename U> bool operator ==(U other) { return *ptr == other; };
template<typename U> bool operator !=(U other) { return *ptr != other; };
private:
T *ptr;
};
......
......@@ -187,6 +187,9 @@ def test_bool_cond():
assert (TruthClass(True) and TruthClass(False)).value == False
assert (TruthClass(True) and TruthClass(True)).value == True
ctypedef int* int_ptr
def test_typeid_op():
"""
>>> test_typeid_op()
......@@ -198,12 +201,19 @@ def test_typeid_op():
assert typeid(TruthClass).name()
assert typeid(test_1).name()
assert typeid(TruthClass) == typeid(deref(test_1))
assert typeid(TruthSubClass).name()
assert typeid(test_2).name()
assert typeid(TruthSubClass) == typeid(deref(test_2))
assert typeid(TruthSubClass) == typeid(deref(test_3))
assert typeid(TruthClass) != typeid(deref(test_3))
assert typeid(TruthClass).name()
assert typeid(test_3).name()
assert typeid(TruthSubClass).name()
assert typeid(deref(test_2)).name()
assert typeid(int_ptr).name()
try:
typeid(deref(test_4))
......
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