mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
Sort names returned by the built-in dir method (#231)
* Sort names returned by the built-in dir method * some fix --------- Co-authored-by: blueloveTH <blueloveth@foxmail.com>
This commit is contained in:
parent
665fb04b8f
commit
142e4fd45f
@ -36,10 +36,10 @@ struct Str{
|
||||
bool empty() const { return size == 0; }
|
||||
size_t hash() const{ return std::hash<std::string_view>()(sv()); }
|
||||
|
||||
Str& operator=(const Str& other);
|
||||
Str operator+(const Str& other) const;
|
||||
friend Str operator+(const char* p, const Str& str);
|
||||
Str operator+(const char* p) const;
|
||||
Str& operator=(const Str&);
|
||||
Str operator+(const Str&) const;
|
||||
Str operator+(const char*) const;
|
||||
friend Str operator+(const char*, const Str&);
|
||||
|
||||
bool operator==(const std::string_view other) const;
|
||||
bool operator!=(const std::string_view other) const;
|
||||
@ -112,11 +112,11 @@ struct StrName {
|
||||
}
|
||||
|
||||
bool operator<(const StrName& other) const noexcept {
|
||||
return this->index < other.index;
|
||||
return sv() < other.sv();
|
||||
}
|
||||
|
||||
bool operator>(const StrName& other) const noexcept {
|
||||
return this->index > other.index;
|
||||
return sv() > other.sv();
|
||||
}
|
||||
|
||||
static bool is_valid(int index);
|
||||
|
@ -276,7 +276,7 @@ namespace pkpy{
|
||||
if(i != 0) ss << ".";
|
||||
ss << cpnts[i];
|
||||
}
|
||||
return Str(ss.str());
|
||||
return ss.str();
|
||||
};
|
||||
|
||||
if(path[0] == '.'){
|
||||
|
@ -630,3 +630,6 @@ def f(a, b):
|
||||
return sum([b, c])
|
||||
|
||||
assert f(1, 2) == 3
|
||||
|
||||
dir_int = dir(int)
|
||||
assert dir_int[:4] == ['__add__', '__and__', '__base__', '__eq__']
|
Loading…
x
Reference in New Issue
Block a user