-
-
Notifications
You must be signed in to change notification settings - Fork 187
/
Copy pathmanual_test_blockformat.py
80 lines (62 loc) · 2.87 KB
/
manual_test_blockformat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# -*- coding: utf-8 -*-
"""
jishaku manual blockformat test
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This test checks that blockformats look OK and function correctly.
You should run it in a bash-like shell (that supports ANSI codes).
:copyright: (c) 2021 Devon (scarletcafe) R
:license: MIT, see LICENSE for more details.
"""
import inspect
from jishaku.formatting import LineFormatter, MultilineFormatter
if __name__ == '__main__':
print("== No Annotations Test ==")
formatter = LineFormatter("one (two three) four")
print(formatter.output(False, False))
print(formatter.output(True, False))
print(formatter.output(True, True))
print("== Forward Test ==")
formatter = LineFormatter("one (two three) four")
formatter.add_annotation("First", (0, 2), 34)
formatter.add_annotation("Second", (4, 14), 31, 33, 41)
formatter.add_annotation("Third", (5, 7), 32, 34)
formatter.add_annotation("Fourth", (9, 13), 33)
formatter.add_annotation("Fifth", (16, 19), 34)
print(formatter.output(False, False))
print(formatter.output(True, False))
print(formatter.output(True, True))
print("== Backward Test ==")
formatter = LineFormatter("one (two three) four")
formatter.add_annotation("Fifth", (16, 19), 34)
formatter.add_annotation("Fourth", (9, 13), 33)
formatter.add_annotation("Third", (5, 7), 32, 34)
formatter.add_annotation("Second", (4, 14), 31, 33, 41)
formatter.add_annotation("First", (0, 2), 34)
formatter.add_annotation("Extra", (9, 13), 35)
print(formatter.output(False, False))
print(formatter.output(True, False))
print(formatter.output(True, True))
print("== Multiline ==")
formatter = MultilineFormatter(inspect.cleandoc("""
one (two three) four
five six seven eight nine
"""))
formatter.add_annotation(0, "First", (0, 2), 34)
formatter.add_annotation(0, "Second", (4, 14), 31, 33, 41)
formatter.add_annotation(0, "Third", (5, 7), 32, 34)
formatter.add_annotation(0, "Fourth", (9, 13), 33)
formatter.add_annotation(0, "Fifth", (16, 19), 34)
formatter.add_annotation(1, "Second on second line", (9, 11), 31, 33, 41)
formatter.add_annotation(1, "Whole second line", (4, 23), 35)
formatter.add_annotation(1, "No span", None, 34)
# Will not show as a line
formatter.add_annotation(1, "", (19, 23), None, None, 45)
formatter.add_annotation(1, "", (20, 20), None, 31, None)
formatter.add_annotation(1, "Eight with a highlighted i", (19, 23), 33)
formatter.add_annotation(1, "", (26, 26), None, 36, None)
formatter.add_annotation(1, "", (25, 28), None, None, 41)
formatter.add_annotation(1, "Nine with a highlighted i", (25, 28), 32)
formatter.add_annotation(1, "A small bit after the end", (30, 35), 34)
print(formatter.output(False, False))
print(formatter.output(True, False))
print(formatter.output(True, True))