Commit 9e2dab50 authored by Kirill Smelkov's avatar Kirill Smelkov

golang_str: tests: Adjust test_strings_index2 not to depend on repr(ustr|bstr)

repr(ustr|bstr) will change behaviour depending on whether we are
running under regular python, or gpython with string types replaced by
bstr/ustr. But this test is completely orthogonal to that. -> Let's
untie it from particular repr behaviour by emitting verified items in
quoted form + asserting their types in the code.
parent 8dc44e12
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2022 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
# Copyright (C) 2022-2023 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
......@@ -29,7 +29,8 @@ from builtin str/unicode, does not get into our way.
from __future__ import print_function, absolute_import
from golang import b, u
from golang import b, u, bstr, ustr
from golang.gcompat import qq
def main():
......@@ -37,8 +38,10 @@ def main():
bs = b("миру мир")
def emit(what, uobj, bobj):
print("u"+what, repr(uobj))
print("b"+what, repr(bobj))
assert type(uobj) is ustr
assert type(bobj) is bstr
print("u"+what, qq(uobj))
print("b"+what, qq(bobj))
emit("s", us, bs)
emit("s[:]", us[:], bs[:])
......
us u('миру мир')
bs b('миру мир')
us[:] u('миру мир')
bs[:] b('миру мир')
us[0:1] u('м')
bs[0:1] b(b'\xd0')
us[0:2] u('ми')
bs[0:2] b('м')
us[1:2] u('и')
bs[1:2] b(b'\xbc')
us[0:-1] u('миру ми')
bs[0:-1] b(b'миру ми\xd1')
us "миру мир"
bs "миру мир"
us[:] "миру мир"
bs[:] "миру мир"
us[0:1] "м"
bs[0:1] "\xd0"
us[0:2] "ми"
bs[0:2] "м"
us[1:2] "и"
bs[1:2] "\xbc"
us[0:-1] "миру ми"
bs[0:-1] "миру ми\xd1"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment