This commit is contained in:
blueloveTH 2023-10-15 22:08:41 +08:00
parent 5e3572b32c
commit f41368afbb
3 changed files with 22 additions and 11 deletions

View File

@ -146,6 +146,26 @@ struct SStream{
return *this; 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){ SStream& operator<<(const std::string& s){
buffer.extend(s.data(), s.data() + s.size()); buffer.extend(s.data(), s.data() + s.size());
return *this; return *this;

View File

@ -4,10 +4,10 @@ a = {
'c': None, 'c': None,
'd': [1, 2, 3], 'd': [1, 2, 3],
'e': { 'e': {
'a': 1, 'a': 100,
'b': 2.5, 'b': 2.5,
'c': None, 'c': None,
'd': [1, 2, 3], 'd': [1425245, 278587578142, 397675452452452],
}, },
"f": 'This is a string', "f": 'This is a string',
'g': [True, False, None], 'g': [True, False, None],

View File

@ -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__: # test list.__rmul__:
assert type(12 * [12]) is list assert type(12 * [12]) is list