Menu

[d5c75e]: / tests / alltests.py  Maximize  Restore  History

Download this file

178 lines (145 with data), 6.2 kB

  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
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import time
import joefx
### TODO: Move test classes into individual files as they get bigger
# Invoke with: python3 -m unittest alltests
class FindTests(joefx.JoeTestBase):
def test_abracadabra(self):
"""Regression test for #295: infinite loop on search-and-replace"""
self.startJoe()
self.write("abracadabra")
self.cmd("bol")
self.replace("a", "X")
self.answerReplace("yyy")
self.writectl("^C")
self.joe.writectl("{left*2}{bs}a")
self.cmd("bol")
self.cmd("fnext")
self.answerReplace("yy")
self.writectl("^C")
self.assertTextAt("XbrXcXdXbra", x=0)
def test_replace_zerolen_regex(self):
"""Regression test related to #295. Check original functionality that broke"""
self.workdir.fixtureData("test", "line 1\nline 2\nline 3\nline 4\n")
self.startup.args = ("test",)
self.startJoe()
self.replace(r"\+ \$", "")
self.assertCursor(y=1)
self.write("y")
self.assertCursor(y=2)
self.write("y")
self.assertCursor(y=3)
self.write("y")
self.assertCursor(y=4)
self.write("y")
self.assertCursor(x=0, y=5)
def test_replace_skip_zerolen_regex(self):
"""Regression test related to #295. Check original functionality that broke"""
self.workdir.fixtureData("test", "line 1\nline 2\nline 3\nline 4\n")
self.startup.args = ("test",)
self.startJoe()
self.replace(r"\+ \$", "")
self.assertCursor(y=1)
self.write("n")
self.assertCursor(y=2)
self.write("n")
self.assertCursor(y=3)
self.write("n")
self.assertCursor(y=4)
self.write("n")
self.assertCursor(x=0, y=5)
class WindowTests(joefx.JoeTestBase):
def test_showlog_querysave(self):
"""Regression test for #326: joe locks up if you try querysave on the startup log"""
self.startJoe()
self.cmd("showlog,nextw,abort,querysave")
self.joe.flushin()
self.cmd("abort")
#self.cmd("showlog")
#self.assertTextAt("* Startup Log *", x=0, y=0)
#self.cmd("nextw")
#self.assertTextAt(" ", x=0, y=0)
#self.cmd("abort")
#self.assertTextAt("* Startup Log *", x=0, y=0)
#self.cmd("querysave")
#self.cmd("abort")
self.assertExited()
def test_resize_menu_narrower_doesnt_crash(self):
"""Regression test for #310: Segfault when resizing with ^T menu open"""
self.startup.lines = 25
self.startup.columns = 120
self.startJoe()
# Pull up menu and resize down to 40
self.menu("root")
for i in range(119, 39, -1):
self.joe.resize(i, 25)
self.joe.flushin()
self.writectl("^C")
self.cmd("abort")
self.assertExited()
def test_resize_menu_wider_doesnt_crash(self):
"""Regression test for #310: Segfault when resizing with ^T menu open"""
self.startup.lines = 25
self.startup.columns = 80
self.startJoe()
self.joe.resize(40, 25)
# Pull up menu and resize down to 40
self.menu("root")
for i in range(40, 121):
self.joe.resize(i, 25)
self.joe.flushin()
self.writectl("^C")
self.cmd("abort")
self.assertExited()
class EncodingTests(joefx.JoeTestBase):
def test_hex_mode_and_back(self):
"""Regresion test. Was not listed as a bug, but was fixed with [11618ed3b38f]"""
self.workdir.fixtureData("test", "ร้อนนี้คงไม่มีอะไรสำคัญเท่าครีมกันแดดอีกแล้วนะสาวๆ")
self.startup.args = ("test",)
self.startJoe()
self.writectl("{right*21}")
self.assertCursor(16, 1)
self.mode("hex")
# Check cursor movement
self.assertCursor(75, 4)
self.writectl("{left}")
self.assertCursor(74, 4)
self.writectl("{right}")
self.assertCursor(75, 4)
self.mode("hex")
# Check cursor movement
self.assertCursor(16, 1)
self.writectl("{left}")
self.assertCursor(15, 1)
def test_change_updates_cursor(self):
"""Regresion test. Was not listed as a bug, but was fixed with [11618ed3b38f]"""
self.workdir.fixtureData("test", "ร้อนนี้คงไม่มีอะไรสำคัญเท่าครีมกันแดดอีกแล้วนะสาวๆ")
self.startup.args = ("test",)
self.startJoe()
self.writectl("{right*21}")
self.assertCursor(16, 1)
# Change encoding to ascii
self.encoding("ascii")
# Check cursor movement
self.assertCursor(63, 1)
self.writectl("{left}")
self.assertCursor(62, 1)
self.writectl("{right}")
self.assertCursor(63, 1)
# Back to utf-8
self.encoding("utf-8")
# Check cursor movement
self.assertCursor(16, 1)
self.writectl("{left}")
self.assertCursor(15, 1)
class FormatTests(joefx.JoeTestBase):
def test_wordwrap_with_asterisks(self):
"""Regression test for #265: Version 3.7 treats "-" and "*" as quote characters"""
self.maxDiff = None
self.startup.args = ("-wordwrap", "--autoindent")
self.startJoe()
# Typeahead hack turns off wordwrap, so write it out slow :-(
self.writeSlow("*all* work and no play makes jack a dull boy. all work and no play makes jack a dull boy. all work and no play makes jack a dull boy. all work and no play makes jack a dull boy.")
self.save("testout")
self.cmd("abort")
self.assertExited()
self.assertFileContents("testout", "*all* work and no play makes jack a dull boy. all work and no play makes\njack a dull boy. all work and no play makes jack a dull boy. all work and no\nplay makes jack a dull boy.")
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.