mixinv2-library 0.4.0.post22.dev0__tar.gz → 0.4.0.post31.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/PKG-INFO +2 -2
- mixinv2_library-0.4.0.post31.dev0/src/mixinv2_library/Builtin/PythonOperator/__init__.py +307 -0
- mixinv2_library-0.4.0.post31.dev0/tests/PythonOperatorTest.mixin.yaml +126 -0
- mixinv2_library-0.4.0.post31.dev0/tests/test_python_operator.py +136 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/.gitignore +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/pyproject.toml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BinNatData.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BinNatDecrement.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BinNatEquality.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BinNatIncrement.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BinNatPlus.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BinNatVisitor.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BooleanAnd.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BooleanData.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BooleanEquality.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BooleanNegation.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BooleanOr.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/BooleanVisitor.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/NatData.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/NatDecrement.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/NatEquality.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/NatPlus.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/NatVisitor.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/NumberIsZero.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/Builtin/__init__.py +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/src/mixinv2_library/__init__.py +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/ArithmeticTest.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/BigNatTest.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/BinNatArithmeticTest.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/CartesianProductTest.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/ChurchBooleanTest.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/NatConstants.mixin.yaml +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/test_bin_nat_arithmetic.py +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/test_cartesian_product.py +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/test_church_boolean.py +0 -0
- {mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/test_nat_arithmetic.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mixinv2-library
|
|
3
|
-
Version: 0.4.0.
|
|
3
|
+
Version: 0.4.0.post31.dev0
|
|
4
4
|
Summary: The MIXINv2 standard library — built-in definitions for MIXINv2
|
|
5
5
|
Project-URL: Repository, https://github.com/Atry/MIXINv2
|
|
6
6
|
Author-email: "Yang, Bo" <yang-bo@yang-bo.com>
|
|
@@ -10,4 +10,4 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.13
|
|
11
11
|
Classifier: Programming Language :: Python :: 3.14
|
|
12
12
|
Requires-Python: >=3.13
|
|
13
|
-
Requires-Dist: mixinv2==0.4.0.
|
|
13
|
+
Requires-Dist: mixinv2==0.4.0.post31.dev0
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"""All Python operator module FFI wrappers, generated programmatically.
|
|
2
|
+
|
|
3
|
+
Covers every public function in Python's operator module:
|
|
4
|
+
- Binary (operand0, operand1 -> result): arithmetic, comparison, bitwise, sequence
|
|
5
|
+
- Unary (operand -> result): neg, pos, abs, invert, not_, truth, index
|
|
6
|
+
- In-place (operand0, operand1 -> result): iadd, isub, etc. (mutate + return)
|
|
7
|
+
- Ternary (target, key, value -> result): setitem
|
|
8
|
+
- Higher-order (target + params -> result): attrgetter, itemgetter, methodcaller, call
|
|
9
|
+
- Special: length_hint, delitem
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
import operator
|
|
13
|
+
|
|
14
|
+
from mixinv2 import extern, public, resource
|
|
15
|
+
from mixinv2._core import MappingScopeDefinition
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _make_binary_operator(operation):
|
|
19
|
+
@extern
|
|
20
|
+
def operand0() -> object: ...
|
|
21
|
+
|
|
22
|
+
@extern
|
|
23
|
+
def operand1() -> object: ...
|
|
24
|
+
|
|
25
|
+
@public
|
|
26
|
+
@resource
|
|
27
|
+
def result(operand0: object, operand1: object) -> object:
|
|
28
|
+
return operation(operand0, operand1)
|
|
29
|
+
|
|
30
|
+
return MappingScopeDefinition(
|
|
31
|
+
inherits=(),
|
|
32
|
+
is_public=True,
|
|
33
|
+
underlying={"operand0": operand0, "operand1": operand1, "result": result},
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _make_unary_operator(operation):
|
|
38
|
+
@extern
|
|
39
|
+
def operand() -> object: ...
|
|
40
|
+
|
|
41
|
+
@public
|
|
42
|
+
@resource
|
|
43
|
+
def result(operand: object) -> object:
|
|
44
|
+
return operation(operand)
|
|
45
|
+
|
|
46
|
+
return MappingScopeDefinition(
|
|
47
|
+
inherits=(),
|
|
48
|
+
is_public=True,
|
|
49
|
+
underlying={"operand": operand, "result": result},
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# --- Binary operators (operand0, operand1 -> result) ---
|
|
54
|
+
_BINARY_OPERATORS = {
|
|
55
|
+
# Arithmetic
|
|
56
|
+
"Add": operator.add,
|
|
57
|
+
"Subtract": operator.sub,
|
|
58
|
+
"Multiply": operator.mul,
|
|
59
|
+
"TrueDivide": operator.truediv,
|
|
60
|
+
"FloorDivide": operator.floordiv,
|
|
61
|
+
"Modulo": operator.mod,
|
|
62
|
+
"Power": operator.pow,
|
|
63
|
+
"MatrixMultiply": operator.matmul,
|
|
64
|
+
# Comparison
|
|
65
|
+
"Equal": operator.eq,
|
|
66
|
+
"NotEqual": operator.ne,
|
|
67
|
+
"LessThan": operator.lt,
|
|
68
|
+
"LessThanOrEqual": operator.le,
|
|
69
|
+
"GreaterThan": operator.gt,
|
|
70
|
+
"GreaterThanOrEqual": operator.ge,
|
|
71
|
+
"Is": operator.is_,
|
|
72
|
+
"IsNot": operator.is_not,
|
|
73
|
+
# Bitwise
|
|
74
|
+
"BitwiseAnd": operator.and_,
|
|
75
|
+
"BitwiseOr": operator.or_,
|
|
76
|
+
"BitwiseXor": operator.xor,
|
|
77
|
+
"LeftShift": operator.lshift,
|
|
78
|
+
"RightShift": operator.rshift,
|
|
79
|
+
# Sequence
|
|
80
|
+
"Concatenate": operator.concat,
|
|
81
|
+
"Contains": operator.contains,
|
|
82
|
+
"GetItem": operator.getitem,
|
|
83
|
+
"CountOf": operator.countOf,
|
|
84
|
+
"IndexOf": operator.indexOf,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# --- Unary operators (operand -> result) ---
|
|
88
|
+
_UNARY_OPERATORS = {
|
|
89
|
+
"Negate": operator.neg,
|
|
90
|
+
"Positive": operator.pos,
|
|
91
|
+
"Absolute": operator.abs,
|
|
92
|
+
"BitwiseInvert": operator.invert,
|
|
93
|
+
"Invert": operator.inv,
|
|
94
|
+
"LogicalNot": operator.not_,
|
|
95
|
+
"Truth": operator.truth,
|
|
96
|
+
"Index": operator.index,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# --- In-place operators (operand0, operand1 -> result) ---
|
|
100
|
+
_INPLACE_OPERATORS = {
|
|
101
|
+
"InplaceAdd": operator.iadd,
|
|
102
|
+
"InplaceSubtract": operator.isub,
|
|
103
|
+
"InplaceMultiply": operator.imul,
|
|
104
|
+
"InplaceTrueDivide": operator.itruediv,
|
|
105
|
+
"InplaceFloorDivide": operator.ifloordiv,
|
|
106
|
+
"InplaceModulo": operator.imod,
|
|
107
|
+
"InplacePower": operator.ipow,
|
|
108
|
+
"InplaceMatrixMultiply": operator.imatmul,
|
|
109
|
+
"InplaceBitwiseAnd": operator.iand,
|
|
110
|
+
"InplaceBitwiseOr": operator.ior,
|
|
111
|
+
"InplaceBitwiseXor": operator.ixor,
|
|
112
|
+
"InplaceLeftShift": operator.ilshift,
|
|
113
|
+
"InplaceRightShift": operator.irshift,
|
|
114
|
+
"InplaceConcatenate": operator.iconcat,
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
for _name, _operation in _BINARY_OPERATORS.items():
|
|
118
|
+
globals()[_name] = _make_binary_operator(_operation)
|
|
119
|
+
|
|
120
|
+
for _name, _operation in _UNARY_OPERATORS.items():
|
|
121
|
+
globals()[_name] = _make_unary_operator(_operation)
|
|
122
|
+
|
|
123
|
+
for _name, _operation in _INPLACE_OPERATORS.items():
|
|
124
|
+
globals()[_name] = _make_binary_operator(_operation)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# --- Special operators (hand-written, unique signatures) ---
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _make_set_item():
|
|
131
|
+
"""operator.setitem(target, key, value) -> None"""
|
|
132
|
+
|
|
133
|
+
@extern
|
|
134
|
+
def target() -> object: ...
|
|
135
|
+
|
|
136
|
+
@extern
|
|
137
|
+
def key() -> object: ...
|
|
138
|
+
|
|
139
|
+
@extern
|
|
140
|
+
def value() -> object: ...
|
|
141
|
+
|
|
142
|
+
@public
|
|
143
|
+
@resource
|
|
144
|
+
def result(target: object, key: object, value: object) -> None:
|
|
145
|
+
operator.setitem(target, key, value)
|
|
146
|
+
|
|
147
|
+
return MappingScopeDefinition(
|
|
148
|
+
inherits=(),
|
|
149
|
+
is_public=True,
|
|
150
|
+
underlying={"target": target, "key": key, "value": value, "result": result},
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
SetItem = _make_set_item()
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _make_delete_item():
|
|
158
|
+
"""operator.delitem(target, key) -> None"""
|
|
159
|
+
|
|
160
|
+
@extern
|
|
161
|
+
def target() -> object: ...
|
|
162
|
+
|
|
163
|
+
@extern
|
|
164
|
+
def key() -> object: ...
|
|
165
|
+
|
|
166
|
+
@public
|
|
167
|
+
@resource
|
|
168
|
+
def result(target: object, key: object) -> None:
|
|
169
|
+
operator.delitem(target, key)
|
|
170
|
+
|
|
171
|
+
return MappingScopeDefinition(
|
|
172
|
+
inherits=(),
|
|
173
|
+
is_public=True,
|
|
174
|
+
underlying={"target": target, "key": key, "result": result},
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
DeleteItem = _make_delete_item()
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def _make_length_hint():
|
|
182
|
+
"""operator.length_hint(target) -> result"""
|
|
183
|
+
|
|
184
|
+
@extern
|
|
185
|
+
def target() -> object: ...
|
|
186
|
+
|
|
187
|
+
@public
|
|
188
|
+
@resource
|
|
189
|
+
def result(target: object) -> int:
|
|
190
|
+
return operator.length_hint(target)
|
|
191
|
+
|
|
192
|
+
return MappingScopeDefinition(
|
|
193
|
+
inherits=(),
|
|
194
|
+
is_public=True,
|
|
195
|
+
underlying={"target": target, "result": result},
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
LengthHint = _make_length_hint()
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _make_call():
|
|
203
|
+
"""operator.call(target, *arguments) -> result"""
|
|
204
|
+
|
|
205
|
+
@extern
|
|
206
|
+
def target() -> object: ...
|
|
207
|
+
|
|
208
|
+
@extern
|
|
209
|
+
def arguments() -> tuple: ...
|
|
210
|
+
|
|
211
|
+
@public
|
|
212
|
+
@resource
|
|
213
|
+
def result(target: object, arguments: tuple) -> object:
|
|
214
|
+
return operator.call(target, *arguments)
|
|
215
|
+
|
|
216
|
+
return MappingScopeDefinition(
|
|
217
|
+
inherits=(),
|
|
218
|
+
is_public=True,
|
|
219
|
+
underlying={"target": target, "arguments": arguments, "result": result},
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
Call = _make_call()
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def _make_method_call():
|
|
227
|
+
"""operator.methodcaller(methodName, *arguments)(target) -> result"""
|
|
228
|
+
|
|
229
|
+
@extern
|
|
230
|
+
def target() -> object: ...
|
|
231
|
+
|
|
232
|
+
@extern
|
|
233
|
+
def methodName() -> str: ...
|
|
234
|
+
|
|
235
|
+
@extern
|
|
236
|
+
def arguments() -> tuple: ...
|
|
237
|
+
|
|
238
|
+
@public
|
|
239
|
+
@resource
|
|
240
|
+
def result(target: object, methodName: str, arguments: tuple) -> object:
|
|
241
|
+
return operator.methodcaller(methodName, *arguments)(target)
|
|
242
|
+
|
|
243
|
+
return MappingScopeDefinition(
|
|
244
|
+
inherits=(),
|
|
245
|
+
is_public=True,
|
|
246
|
+
underlying={
|
|
247
|
+
"target": target,
|
|
248
|
+
"methodName": methodName,
|
|
249
|
+
"arguments": arguments,
|
|
250
|
+
"result": result,
|
|
251
|
+
},
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
MethodCall = _make_method_call()
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def _make_attribute_get():
|
|
259
|
+
"""operator.attrgetter(attributeName)(target) -> result"""
|
|
260
|
+
|
|
261
|
+
@extern
|
|
262
|
+
def target() -> object: ...
|
|
263
|
+
|
|
264
|
+
@extern
|
|
265
|
+
def attributeName() -> str: ...
|
|
266
|
+
|
|
267
|
+
@public
|
|
268
|
+
@resource
|
|
269
|
+
def result(target: object, attributeName: str) -> object:
|
|
270
|
+
return operator.attrgetter(attributeName)(target)
|
|
271
|
+
|
|
272
|
+
return MappingScopeDefinition(
|
|
273
|
+
inherits=(),
|
|
274
|
+
is_public=True,
|
|
275
|
+
underlying={
|
|
276
|
+
"target": target,
|
|
277
|
+
"attributeName": attributeName,
|
|
278
|
+
"result": result,
|
|
279
|
+
},
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
AttributeGet = _make_attribute_get()
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def _make_item_get():
|
|
287
|
+
"""operator.itemgetter(key)(target) -> result"""
|
|
288
|
+
|
|
289
|
+
@extern
|
|
290
|
+
def target() -> object: ...
|
|
291
|
+
|
|
292
|
+
@extern
|
|
293
|
+
def key() -> object: ...
|
|
294
|
+
|
|
295
|
+
@public
|
|
296
|
+
@resource
|
|
297
|
+
def result(target: object, key: object) -> object:
|
|
298
|
+
return operator.itemgetter(key)(target)
|
|
299
|
+
|
|
300
|
+
return MappingScopeDefinition(
|
|
301
|
+
inherits=(),
|
|
302
|
+
is_public=True,
|
|
303
|
+
underlying={"target": target, "key": key, "result": result},
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
ItemGet = _make_item_get()
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Binary arithmetic
|
|
2
|
+
_threeAddFour:
|
|
3
|
+
- [Builtin, PythonOperator, Add]
|
|
4
|
+
- operand0: 3
|
|
5
|
+
operand1: 4
|
|
6
|
+
addResult: [_threeAddFour, result]
|
|
7
|
+
|
|
8
|
+
_tenSubtractThree:
|
|
9
|
+
- [Builtin, PythonOperator, Subtract]
|
|
10
|
+
- operand0: 10
|
|
11
|
+
operand1: 3
|
|
12
|
+
subtractResult: [_tenSubtractThree, result]
|
|
13
|
+
|
|
14
|
+
_fiveMultiplySix:
|
|
15
|
+
- [Builtin, PythonOperator, Multiply]
|
|
16
|
+
- operand0: 5
|
|
17
|
+
operand1: 6
|
|
18
|
+
multiplyResult: [_fiveMultiplySix, result]
|
|
19
|
+
|
|
20
|
+
_sevenTrueDivideTwo:
|
|
21
|
+
- [Builtin, PythonOperator, TrueDivide]
|
|
22
|
+
- operand0: 7
|
|
23
|
+
operand1: 2
|
|
24
|
+
trueDivideResult: [_sevenTrueDivideTwo, result]
|
|
25
|
+
|
|
26
|
+
_sevenFloorDivideTwo:
|
|
27
|
+
- [Builtin, PythonOperator, FloorDivide]
|
|
28
|
+
- operand0: 7
|
|
29
|
+
operand1: 2
|
|
30
|
+
floorDivideResult: [_sevenFloorDivideTwo, result]
|
|
31
|
+
|
|
32
|
+
_sevenModuloThree:
|
|
33
|
+
- [Builtin, PythonOperator, Modulo]
|
|
34
|
+
- operand0: 7
|
|
35
|
+
operand1: 3
|
|
36
|
+
moduloResult: [_sevenModuloThree, result]
|
|
37
|
+
|
|
38
|
+
_twoPowerThree:
|
|
39
|
+
- [Builtin, PythonOperator, Power]
|
|
40
|
+
- operand0: 2
|
|
41
|
+
operand1: 3
|
|
42
|
+
powerResult: [_twoPowerThree, result]
|
|
43
|
+
|
|
44
|
+
# Comparison
|
|
45
|
+
_threeEqualThree:
|
|
46
|
+
- [Builtin, PythonOperator, Equal]
|
|
47
|
+
- operand0: 3
|
|
48
|
+
operand1: 3
|
|
49
|
+
equalTrueResult: [_threeEqualThree, result]
|
|
50
|
+
|
|
51
|
+
_threeEqualFour:
|
|
52
|
+
- [Builtin, PythonOperator, Equal]
|
|
53
|
+
- operand0: 3
|
|
54
|
+
operand1: 4
|
|
55
|
+
equalFalseResult: [_threeEqualFour, result]
|
|
56
|
+
|
|
57
|
+
_threeLessThanFour:
|
|
58
|
+
- [Builtin, PythonOperator, LessThan]
|
|
59
|
+
- operand0: 3
|
|
60
|
+
operand1: 4
|
|
61
|
+
lessThanTrueResult: [_threeLessThanFour, result]
|
|
62
|
+
|
|
63
|
+
_fourLessThanThree:
|
|
64
|
+
- [Builtin, PythonOperator, LessThan]
|
|
65
|
+
- operand0: 4
|
|
66
|
+
operand1: 3
|
|
67
|
+
lessThanFalseResult: [_fourLessThanThree, result]
|
|
68
|
+
|
|
69
|
+
# Unary
|
|
70
|
+
_negateFive:
|
|
71
|
+
- [Builtin, PythonOperator, Negate]
|
|
72
|
+
- operand: 5
|
|
73
|
+
negateResult: [_negateFive, result]
|
|
74
|
+
|
|
75
|
+
_absoluteNegativeSeven:
|
|
76
|
+
- [Builtin, PythonOperator, Absolute]
|
|
77
|
+
- operand: -7
|
|
78
|
+
absoluteResult: [_absoluteNegativeSeven, result]
|
|
79
|
+
|
|
80
|
+
_truthZero:
|
|
81
|
+
- [Builtin, PythonOperator, Truth]
|
|
82
|
+
- operand: 0
|
|
83
|
+
truthFalseResult: [_truthZero, result]
|
|
84
|
+
|
|
85
|
+
_truthOne:
|
|
86
|
+
- [Builtin, PythonOperator, Truth]
|
|
87
|
+
- operand: 1
|
|
88
|
+
truthTrueResult: [_truthOne, result]
|
|
89
|
+
|
|
90
|
+
_logicalNotTrue:
|
|
91
|
+
- [Builtin, PythonOperator, LogicalNot]
|
|
92
|
+
- operand: true
|
|
93
|
+
logicalNotResult: [_logicalNotTrue, result]
|
|
94
|
+
|
|
95
|
+
# Bitwise
|
|
96
|
+
_bitwiseAndResult:
|
|
97
|
+
- [Builtin, PythonOperator, BitwiseAnd]
|
|
98
|
+
- operand0: 0b1100
|
|
99
|
+
operand1: 0b1010
|
|
100
|
+
bitwiseAndResult: [_bitwiseAndResult, result]
|
|
101
|
+
|
|
102
|
+
_bitwiseOrResult:
|
|
103
|
+
- [Builtin, PythonOperator, BitwiseOr]
|
|
104
|
+
- operand0: 0b1100
|
|
105
|
+
operand1: 0b1010
|
|
106
|
+
bitwiseOrResult: [_bitwiseOrResult, result]
|
|
107
|
+
|
|
108
|
+
_leftShiftResult:
|
|
109
|
+
- [Builtin, PythonOperator, LeftShift]
|
|
110
|
+
- operand0: 1
|
|
111
|
+
operand1: 4
|
|
112
|
+
leftShiftResult: [_leftShiftResult, result]
|
|
113
|
+
|
|
114
|
+
# Sequence
|
|
115
|
+
_concatResult:
|
|
116
|
+
- [Builtin, PythonOperator, Concatenate]
|
|
117
|
+
- operand0: "hello "
|
|
118
|
+
operand1: "world"
|
|
119
|
+
concatResult: [_concatResult, result]
|
|
120
|
+
|
|
121
|
+
# Higher-order: AttributeGet
|
|
122
|
+
_attributeGetResult:
|
|
123
|
+
- [Builtin, PythonOperator, AttributeGet]
|
|
124
|
+
- target: "hello"
|
|
125
|
+
attributeName: "__class__"
|
|
126
|
+
attributeGetResult: [_attributeGetResult, result]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""Tests for Builtin.PythonOperator FFI wrappers.
|
|
2
|
+
|
|
3
|
+
Verifies that the programmatically generated operator FFI scopes
|
|
4
|
+
correctly wrap Python's operator module functions.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
import mixinv2_library
|
|
12
|
+
from mixinv2._mixin_directory import DirectoryMixinDefinition
|
|
13
|
+
from mixinv2._runtime import Scope, evaluate
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
TESTS_PATH = Path(__file__).parent
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@pytest.fixture
|
|
20
|
+
def operator_scope() -> Scope:
|
|
21
|
+
"""Load and evaluate the PythonOperator test fixture."""
|
|
22
|
+
tests_definition = DirectoryMixinDefinition(
|
|
23
|
+
inherits=(), is_public=True, underlying=TESTS_PATH
|
|
24
|
+
)
|
|
25
|
+
root = evaluate(mixinv2_library, tests_definition, modules_public=True)
|
|
26
|
+
result = root.PythonOperatorTest
|
|
27
|
+
assert isinstance(result, Scope)
|
|
28
|
+
return result
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class TestBinaryArithmetic:
|
|
32
|
+
"""Test binary arithmetic operators."""
|
|
33
|
+
|
|
34
|
+
def test_add(self, operator_scope: Scope) -> None:
|
|
35
|
+
"""3 + 4 = 7"""
|
|
36
|
+
assert operator_scope.addResult == 7
|
|
37
|
+
|
|
38
|
+
def test_subtract(self, operator_scope: Scope) -> None:
|
|
39
|
+
"""10 - 3 = 7"""
|
|
40
|
+
assert operator_scope.subtractResult == 7
|
|
41
|
+
|
|
42
|
+
def test_multiply(self, operator_scope: Scope) -> None:
|
|
43
|
+
"""5 * 6 = 30"""
|
|
44
|
+
assert operator_scope.multiplyResult == 30
|
|
45
|
+
|
|
46
|
+
def test_true_divide(self, operator_scope: Scope) -> None:
|
|
47
|
+
"""7 / 2 = 3.5"""
|
|
48
|
+
assert operator_scope.trueDivideResult == 3.5
|
|
49
|
+
|
|
50
|
+
def test_floor_divide(self, operator_scope: Scope) -> None:
|
|
51
|
+
"""7 // 2 = 3"""
|
|
52
|
+
assert operator_scope.floorDivideResult == 3
|
|
53
|
+
|
|
54
|
+
def test_modulo(self, operator_scope: Scope) -> None:
|
|
55
|
+
"""7 % 3 = 1"""
|
|
56
|
+
assert operator_scope.moduloResult == 1
|
|
57
|
+
|
|
58
|
+
def test_power(self, operator_scope: Scope) -> None:
|
|
59
|
+
"""2 ** 3 = 8"""
|
|
60
|
+
assert operator_scope.powerResult == 8
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class TestComparison:
|
|
64
|
+
"""Test comparison operators."""
|
|
65
|
+
|
|
66
|
+
def test_equal_true(self, operator_scope: Scope) -> None:
|
|
67
|
+
"""3 == 3 is True"""
|
|
68
|
+
assert operator_scope.equalTrueResult is True
|
|
69
|
+
|
|
70
|
+
def test_equal_false(self, operator_scope: Scope) -> None:
|
|
71
|
+
"""3 == 4 is False"""
|
|
72
|
+
assert operator_scope.equalFalseResult is False
|
|
73
|
+
|
|
74
|
+
def test_less_than_true(self, operator_scope: Scope) -> None:
|
|
75
|
+
"""3 < 4 is True"""
|
|
76
|
+
assert operator_scope.lessThanTrueResult is True
|
|
77
|
+
|
|
78
|
+
def test_less_than_false(self, operator_scope: Scope) -> None:
|
|
79
|
+
"""4 < 3 is False"""
|
|
80
|
+
assert operator_scope.lessThanFalseResult is False
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class TestUnary:
|
|
84
|
+
"""Test unary operators."""
|
|
85
|
+
|
|
86
|
+
def test_negate(self, operator_scope: Scope) -> None:
|
|
87
|
+
"""neg(5) = -5"""
|
|
88
|
+
assert operator_scope.negateResult == -5
|
|
89
|
+
|
|
90
|
+
def test_absolute(self, operator_scope: Scope) -> None:
|
|
91
|
+
"""abs(-7) = 7"""
|
|
92
|
+
assert operator_scope.absoluteResult == 7
|
|
93
|
+
|
|
94
|
+
def test_truth_false(self, operator_scope: Scope) -> None:
|
|
95
|
+
"""truth(0) is False"""
|
|
96
|
+
assert operator_scope.truthFalseResult is False
|
|
97
|
+
|
|
98
|
+
def test_truth_true(self, operator_scope: Scope) -> None:
|
|
99
|
+
"""truth(1) is True"""
|
|
100
|
+
assert operator_scope.truthTrueResult is True
|
|
101
|
+
|
|
102
|
+
def test_logical_not(self, operator_scope: Scope) -> None:
|
|
103
|
+
"""not_(True) is False"""
|
|
104
|
+
assert operator_scope.logicalNotResult is False
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class TestBitwise:
|
|
108
|
+
"""Test bitwise operators."""
|
|
109
|
+
|
|
110
|
+
def test_bitwise_and(self, operator_scope: Scope) -> None:
|
|
111
|
+
"""0b1100 & 0b1010 = 0b1000 = 8"""
|
|
112
|
+
assert operator_scope.bitwiseAndResult == 0b1000
|
|
113
|
+
|
|
114
|
+
def test_bitwise_or(self, operator_scope: Scope) -> None:
|
|
115
|
+
"""0b1100 | 0b1010 = 0b1110 = 14"""
|
|
116
|
+
assert operator_scope.bitwiseOrResult == 0b1110
|
|
117
|
+
|
|
118
|
+
def test_left_shift(self, operator_scope: Scope) -> None:
|
|
119
|
+
"""1 << 4 = 16"""
|
|
120
|
+
assert operator_scope.leftShiftResult == 16
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class TestSequence:
|
|
124
|
+
"""Test sequence operators."""
|
|
125
|
+
|
|
126
|
+
def test_concatenate(self, operator_scope: Scope) -> None:
|
|
127
|
+
"""'hello ' + 'world' = 'hello world'"""
|
|
128
|
+
assert operator_scope.concatResult == "hello world"
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class TestHigherOrder:
|
|
132
|
+
"""Test higher-order operators."""
|
|
133
|
+
|
|
134
|
+
def test_attribute_get(self, operator_scope: Scope) -> None:
|
|
135
|
+
"""'hello'.__class__ is str"""
|
|
136
|
+
assert operator_scope.attributeGetResult is str
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/BigNatTest.mixin.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/test_church_boolean.py
RENAMED
|
File without changes
|
{mixinv2_library-0.4.0.post22.dev0 → mixinv2_library-0.4.0.post31.dev0}/tests/test_nat_arithmetic.py
RENAMED
|
File without changes
|