1# mode: run
2# tag: cpp, werror
3
4from libcpp cimport bool
5
6def test_bool(bool a):
7    """
8    >>> test_bool(True)
9    True
10    >>> test_bool(1)
11    True
12    >>> test_bool(0)
13    False
14    >>> test_bool(100)
15    True
16    >>> test_bool(None)
17    False
18    >>> test_bool([])
19    False
20    """
21    return a
22
23
24cdef bool may_raise_exception(bool value, exception) except *:
25    if exception:
26        raise exception
27    else:
28        return value
29
30def test_may_raise_exception(bool value, exception=None):
31    """
32    >>> test_may_raise_exception(False)
33    False
34    >>> test_may_raise_exception(True)
35    True
36    >>> test_may_raise_exception(True, RuntimeError)
37    Traceback (most recent call last):
38    ...
39    RuntimeError
40    """
41    return may_raise_exception(value, exception)
42