blueloveTH 2 роки тому
батько
коміт
fba9d87ccd
3 змінених файлів з 5 додано та 5 видалено
  1. 0 1
      include/pocketpy/str.h
  2. 0 4
      src/str.cpp
  3. 5 0
      tests/04_str.py

+ 0 - 1
include/pocketpy/str.h

@@ -98,7 +98,6 @@ struct StrName {
     const char* c_str() const;
     bool empty() const { return index == 0; }
 
-    friend std::ostream& operator<<(std::ostream& os, const StrName& sn);
     Str escape() const;
 
     bool operator==(const StrName& other) const noexcept {

+ 0 - 4
src/str.cpp

@@ -388,10 +388,6 @@ int utf8len(unsigned char c, bool suppress){
         return cnt;
     }
 
-    std::ostream& operator<<(std::ostream& os, const StrName& sn){
-        return os << sn.sv();
-    }
-
     std::map<std::string, uint16_t, std::less<>>& StrName::_interned(){
         static std::map<std::string, uint16_t, std::less<>> interned;
         return interned;

+ 5 - 0
tests/04_str.py

@@ -180,3 +180,8 @@ assert list(a) == ['测']
 
 assert '\b\b\b' == '\x08\x08\x08'
 stack=[1,2,3,4]; assert f"{stack[2:]}" == '[3, 4]'
+
+assert repr('\x1f\x1e\x1f') == '\'\\x1f\\x1e\\x1f\''
+
+assert hex(255) == '0xFF'
+assert hex(-42) == '-0x2A'