mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-12 02:42:56 +02:00
Clearance of multicell tests
This commit is contained in:
@@ -23,11 +23,6 @@ def test_multicell(self: TestMulticell) -> None:
|
||||
def ac(x_, y_, **assertions): # assert cell
|
||||
cell = s.cpu_cells(y_, x_)
|
||||
msg = f'Assertion failed for cell at ({x_}, {y_})\n{cell}\n'
|
||||
if 'is_multicell' in assertions:
|
||||
if assertions['is_multicell']:
|
||||
assert cell['mcd'] is not None, msg
|
||||
else:
|
||||
assert cell['mcd'] is None, msg
|
||||
def ae(key):
|
||||
if key not in assertions:
|
||||
return
|
||||
@@ -38,7 +33,8 @@ def test_multicell(self: TestMulticell) -> None:
|
||||
if mcd is None:
|
||||
raise AssertionError(f'{msg}Unexpectedly not a multicell')
|
||||
val = mcd[key]
|
||||
assert assertions[key] == val, f'{msg}{assertions[key]!r} != {val!r}'
|
||||
if assertions[key] != val:
|
||||
raise AssertionError(f'{msg}{assertions[key]!r} != {val!r}')
|
||||
|
||||
ae('x')
|
||||
ae('y')
|
||||
@@ -48,10 +44,30 @@ def test_multicell(self: TestMulticell) -> None:
|
||||
ae('vertical_align')
|
||||
ae('text')
|
||||
ae('explicitly_set')
|
||||
|
||||
if 'cursor' in assertions:
|
||||
self.ae(assertions['cursor'], (s.cursor.x, s.cursor.y), msg)
|
||||
|
||||
s = self.create_screen(cols=5, lines=5)
|
||||
if 'is_multicell' in assertions:
|
||||
q = cell['mcd']
|
||||
if assertions['is_multicell']:
|
||||
if q is None:
|
||||
raise AssertionError(f'{msg}Unexpectedly not a multicell')
|
||||
else:
|
||||
if q is not None:
|
||||
raise AssertionError(f'{msg}Unexpectedly is a multicell')
|
||||
|
||||
def count_multicells(with_text=''):
|
||||
ans = 0
|
||||
for y in range(s.lines):
|
||||
for x in range(s.columns):
|
||||
c = s.cpu_cells(y, x)
|
||||
if c['mcd'] is not None and (not with_text or c['text'] == with_text):
|
||||
ans += 1
|
||||
return ans
|
||||
|
||||
# Test basic multicell drawing
|
||||
s = self.create_screen(cols=6, lines=6)
|
||||
ac(0, 0, is_multicell=False)
|
||||
multicell(s, 'a')
|
||||
ac(0, 0, is_multicell=True, width=1, scale=1, subscale=0, x=0, y=0, text='a', explicitly_set=True, cursor=(1, 0))
|
||||
@@ -60,4 +76,47 @@ def test_multicell(self: TestMulticell) -> None:
|
||||
ac(0, 0, is_multicell=True, width=1, scale=1, subscale=0, x=0, y=0, text='a', explicitly_set=True)
|
||||
ac(1, 0, is_multicell=True, width=2, scale=1, subscale=0, x=0, y=0, text='莊', explicitly_set=False, cursor=(3, 0))
|
||||
ac(2, 0, is_multicell=True, width=2, scale=1, subscale=0, x=1, y=0, text='', explicitly_set=False)
|
||||
ac(1, 0, is_multicell=False), ac(1, 1, is_multicell=False)
|
||||
for x in range(s.columns):
|
||||
ac(x, 1, is_multicell=False)
|
||||
s.cursor.x = 0
|
||||
multicell(s, 'a', width=2, scale=2, subscale=3)
|
||||
ac(0, 0, is_multicell=True, width=2, scale=2, subscale=3, x=0, y=0, text='a', explicitly_set=True, cursor=(4, 0))
|
||||
for x in range(1, 4):
|
||||
ac(x, 0, is_multicell=True, width=2, scale=2, subscale=3, x=x, y=0, text='', explicitly_set=True)
|
||||
for x in range(0, 4):
|
||||
ac(x, 1, is_multicell=True, width=2, scale=2, subscale=3, x=x, y=1, text='', explicitly_set=True)
|
||||
|
||||
# Test draw with cursor in a multicell
|
||||
s.reset()
|
||||
s.draw('莊')
|
||||
s.cursor.x -= 1
|
||||
s.draw('a'), ac(0, 0, is_multicell=False), ac(1, 0, is_multicell=False)
|
||||
s.reset()
|
||||
s.draw('莊')
|
||||
s.cursor.x = 0
|
||||
s.draw('a'), ac(0, 0, is_multicell=False), ac(1, 0, is_multicell=False)
|
||||
s.reset()
|
||||
multicell(s, 'a', width=2, scale=2, subscale=3)
|
||||
s.cursor.x, s.cursor.y = 1, 1
|
||||
s.draw('b')
|
||||
self.ae(0, count_multicells())
|
||||
s.reset()
|
||||
s.cursor.x = 1
|
||||
s.draw('莊')
|
||||
s.cursor.x = 0
|
||||
s.draw('莊')
|
||||
ac(2, 0, is_multicell=False, text=' ')
|
||||
|
||||
# Test multicell with cursor in a multicell
|
||||
def big_a(x, y):
|
||||
s.reset()
|
||||
s.cursor.x, s.cursor.y = 1, 1
|
||||
multicell(s, 'a', scale=4)
|
||||
s.cursor.x, s.cursor.y = x, y
|
||||
multicell(s, 'b', scale=2)
|
||||
self.ae(4, count_multicells())
|
||||
for x in range(1, 5):
|
||||
ac(x, 4, text=' ')
|
||||
big_a(0, 0), big_a(1, 1), big_a(2, 2), big_a(5, 1)
|
||||
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ class TestParser(BaseTest):
|
||||
e('s', 'Malformed GraphicsCommand control block, no = after key')
|
||||
e('s=', 'Malformed GraphicsCommand control block, expecting an integer value')
|
||||
e('s==', 'Malformed GraphicsCommand control block, expecting an integer value for key: s')
|
||||
e('s=1=', 'Malformed GraphicsCommand control block, expecting a comma or semi-colon after a value, found: 0x3d')
|
||||
e('s=1=', 'Malformed GraphicsCommand control block, expecting a , or semi-colon after a value, found: 0x3d')
|
||||
|
||||
def test_deccara(self):
|
||||
s = self.create_screen()
|
||||
|
||||
Reference in New Issue
Block a user