mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
9ff3417621
commit
e51e152b8c
@ -8,7 +8,6 @@ MAGIC_METHOD(__ge__)
|
|||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
MAGIC_METHOD(__neg__)
|
MAGIC_METHOD(__neg__)
|
||||||
MAGIC_METHOD(__abs__)
|
MAGIC_METHOD(__abs__)
|
||||||
MAGIC_METHOD(__int__)
|
|
||||||
MAGIC_METHOD(__round__)
|
MAGIC_METHOD(__round__)
|
||||||
MAGIC_METHOD(__divmod__)
|
MAGIC_METHOD(__divmod__)
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
@ -123,9 +123,7 @@ static bool number__pow__(int argc, py_Ref argv) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static py_i64 i64_abs(py_i64 x) {
|
static py_i64 i64_abs(py_i64 x) { return x < 0 ? -x : x; }
|
||||||
return x < 0 ? -x : x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static py_i64 cpy11__fast_floor_div(py_i64 a, py_i64 b) {
|
static py_i64 cpy11__fast_floor_div(py_i64 a, py_i64 b) {
|
||||||
assert(b != 0);
|
assert(b != 0);
|
||||||
@ -316,7 +314,7 @@ static bool int__new__(int argc, py_Ref argv) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case tp_str: break; // leave to the next block
|
case tp_str: break; // leave to the next block
|
||||||
default: return pk_callmagic(__int__, 1, argv + 1);
|
default: return TypeError("int() argument must be a string, number or boolean");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 2+ args -> error
|
// 2+ args -> error
|
||||||
|
@ -53,12 +53,6 @@ assert 2**2**3 == 256
|
|||||||
assert (2**2**3)**2 == 65536
|
assert (2**2**3)**2 == 65536
|
||||||
|
|
||||||
class Number:
|
class Number:
|
||||||
def __float__(self):
|
|
||||||
return 1.0
|
|
||||||
|
|
||||||
def __int__(self):
|
|
||||||
return 2
|
|
||||||
|
|
||||||
def __divmod__(self, other):
|
def __divmod__(self, other):
|
||||||
return 3, 4
|
return 3, 4
|
||||||
|
|
||||||
@ -66,9 +60,6 @@ class Number:
|
|||||||
return args
|
return args
|
||||||
|
|
||||||
assert divmod(Number(), 0) == (3, 4)
|
assert divmod(Number(), 0) == (3, 4)
|
||||||
assert float(Number()) == 1.0
|
|
||||||
assert int(Number()) == 2
|
|
||||||
|
|
||||||
assert round(Number()) == tuple()
|
assert round(Number()) == tuple()
|
||||||
assert round(Number(), 1) == (1,)
|
assert round(Number(), 1) == (1,)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user