Merged pull request #12 from bhy/T423.
[cython.git] / tests / run / bint_binop_T145.pyx
1 # ticket: 145
2
3 cimport cython
4
5 @cython.test_fail_if_path_exists('//BoolBinopNode')
6 def or_literal_bint():
7     """
8     >>> True or 5
9     True
10     >>> or_literal_bint()
11     True
12     """
13     return True or 5
14
15 @cython.test_fail_if_path_exists('//BoolBinopNode')
16 def and_literal_bint():
17     """
18     >>> 5 and True
19     True
20     >>> and_literal_bint()
21     True
22     """
23     return 5 and True
24
25 @cython.test_fail_if_path_exists('//BoolBinopNode')
26 def False_and_True_or_0():
27     """
28     >>> False and True or 0
29     0
30     >>> False_and_True_or_0()
31     0
32     """
33     return False and True or 0
34
35 @cython.test_fail_if_path_exists('//BoolBinopNode')
36 def True_and_True_or_0():
37     """
38     >>> True and True or 0
39     True
40     >>> True_and_True_or_0()
41     True
42     """
43     return True and True or 0
44
45 def x_and_True_or_False(x):
46     """
47     >>> x_and_True_or_False(0)
48     False
49     >>> x_and_True_or_False(1)
50     True
51     >>> x_and_True_or_False('abc')
52     True
53     >>> x_and_True_or_False([])
54     False
55     """
56     return x and True or False
57
58 def x_and_True_or_0(x):
59     """
60     >>> 0 and True or 0
61     0
62     >>> x_and_True_or_0(0)
63     0
64
65     >>> 1 and True or 0
66     True
67     >>> x_and_True_or_0(1)
68     True
69
70     >>> x_and_True_or_0('abc')
71     True
72     >>> x_and_True_or_0([])
73     0
74     """
75     return x and True or 0
76
77 def x_and_True_or_1(x):
78     """
79     >>> 0 and True or 1
80     1
81     >>> x_and_True_or_1(0)
82     1
83
84     >>> 1 and True or 1
85     True
86     >>> x_and_True_or_1(1)
87     True
88
89     >>> x_and_True_or_1('abc')
90     True
91     >>> x_and_True_or_1([])
92     1
93     """
94     return x and True or 1
95
96 def x_and_1_or_False(x):
97     """
98     >>> 0 and 1 or False
99     False
100     >>> x_and_1_or_False(0)
101     False
102
103     >>> 1 and 1 or False
104     1
105     >>> x_and_1_or_False(1)
106     1
107
108     >>> x_and_1_or_False('abc')
109     1
110     >>> x_and_1_or_False([])
111     False
112     """
113     return x and 1 or False