mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
ascii: Improve test
This commit is contained in:
1 parent
4ee80a3d42
commit
5bfa4cec7c
2 files changed
+4
-2
No files matched your search
@@ -2,4 +2,6 @@ assert ascii('hello world') == "'hello world'"
|
||||
assert ascii('안녕 세상') == "'\\uc548\\ub155 \\uc138\\uc0c1'"
|
||||
assert ascii('안녕 RustPython') == "'\\uc548\\ub155 RustPython'"
|
||||
assert ascii(5) == '5'
|
||||
assert ascii(chr(0x10001)) == "'\\U00010001'"
|
||||
assert ascii(chr(0x10001)) == "'\\U00010001'"
|
||||
assert ascii(chr(0x9999)) == "'\\u9999'"
|
||||
assert ascii(chr(0x0A)) == "'\\n'"
|
||||
+1
-1
@@ -66,7 +66,7 @@ fn builtin_ascii(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<String> {
|
||||
if c.is_ascii() {
|
||||
ascii.push(c);
|
||||
} else if (c as i64) < 0x10000 {
|
||||
let hex = format!("\\u{:x}", c as i64);
|
||||
let hex = format!("\\u{:04x}", c as i64);
|
||||
ascii.push_str(&hex);
|
||||
} else {
|
||||
let hex = format!("\\U{:08x}", c as i64);
|
||||
|
||||
Reference in new issue
Block a user