mirror of
https://github.com/pocketpy/pocketpy
synced 2025-12-06 18:20:17 +00:00
...
This commit is contained in:
parent
5e3572b32c
commit
f41368afbb
@ -146,6 +146,26 @@ struct SStream{
|
||||
return *this;
|
||||
}
|
||||
|
||||
SStream& operator<<(i64 val){
|
||||
// str(-2**64).__len__() == 21
|
||||
buffer.reserve(buffer.size() + 24);
|
||||
if(val == 0){
|
||||
buffer.push_back('0');
|
||||
return *this;
|
||||
}
|
||||
if(val < 0){
|
||||
buffer.push_back('-');
|
||||
val = -val;
|
||||
}
|
||||
char* begin = buffer.end();
|
||||
while(val){
|
||||
buffer.push_back('0' + val % 10);
|
||||
val /= 10;
|
||||
}
|
||||
std::reverse(begin, buffer.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
SStream& operator<<(const std::string& s){
|
||||
buffer.extend(s.data(), s.data() + s.size());
|
||||
return *this;
|
||||
|
||||
@ -4,10 +4,10 @@ a = {
|
||||
'c': None,
|
||||
'd': [1, 2, 3],
|
||||
'e': {
|
||||
'a': 1,
|
||||
'a': 100,
|
||||
'b': 2.5,
|
||||
'c': None,
|
||||
'd': [1, 2, 3],
|
||||
'd': [1425245, 278587578142, 397675452452452],
|
||||
},
|
||||
"f": 'This is a string',
|
||||
'g': [True, False, None],
|
||||
|
||||
@ -446,15 +446,6 @@ except:
|
||||
|
||||
|
||||
# 未完全测试准确性-----------------------------------------------
|
||||
# 116: 721: _vm->bind_method<1>("list", "__rmul__", [](VM* vm, ArgsView args) {
|
||||
# #####: 722: const List& self = _CAST(List&, args[0]);
|
||||
# #####: 723: if(!is_int(args[1])) return vm->NotImplemented;
|
||||
# #####: 724: int n = _CAST(int, args[1]);
|
||||
# #####: 725: List result;
|
||||
# #####: 726: result.reserve(self.size() * n);
|
||||
# #####: 727: for(int i = 0; i < n; i++) result.extend(self);
|
||||
# #####: 728: return VAR(std::move(result));
|
||||
# #####: 729: });
|
||||
# test list.__rmul__:
|
||||
assert type(12 * [12]) is list
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user