Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 379b3e5

Browse filesBrowse files
committed
[[ Bug 21219 ]] selectedLine behavior tests
This patch adds tests to compare the behavior of `the selectedLine` to the behavior of an explicit line chunk.
1 parent 6de2d37 commit 379b3e5
Copy full SHA for 379b3e5

File tree

1 file changed

+205
-0
lines changed
Filter options

1 file changed

+205
-0
lines changed
+205Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
script "CoreFieldSelectedLine"
2+
/*
3+
Copyright (C) 2018 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestSetup
20+
create stack "Test"
21+
set the defaultStack to "Test"
22+
create field "Test"
23+
end TestSetup
24+
25+
private command __ResetField
26+
put format("a\nb\nc\nd\ne\nf\ng\nh\n") into field "Test"
27+
end __ResetField
28+
29+
on TestCutSelectedLine
30+
set the defaultStack to "Test"
31+
__ResetField
32+
cut line 4 of field "Test"
33+
TestAssert "cut line removes line", the text of field "Test" is format("a\nb\nc\ne\nf\ng\nh\n")
34+
TestDiagnostic the text of field "Test"
35+
TestAssert "cut line includes line delimiter", the clipboardData["text"] is "d" & return
36+
TestDiagnostic the clipboardData["text"]
37+
38+
__ResetField
39+
select before line 4 of field "Test"
40+
cut the selectedline
41+
TestAssert "cut selectedLine removes line", the text of field "Test" is format("a\nb\nc\ne\nf\ng\nh\n")
42+
TestDiagnostic the text of field "Test"
43+
TestAssert "cut selectedLine includes line delimiter", the clipboardData["text"] is "d" & return
44+
TestDiagnostic the clipboardData["text"]
45+
46+
__ResetField
47+
select line 4 of field "Test"
48+
cut
49+
TestAssert "select line then cut removes line", the text of field "Test" is format("a\nb\nc\ne\nf\ng\nh\n")
50+
TestDiagnostic the text of field "Test"
51+
TestAssert "cut line includes line delimiter", the clipboardData["text"] is "d" & return
52+
TestDiagnostic the clipboardData["text"]
53+
54+
__ResetField
55+
select before line 4 of field "Test"
56+
select the selectedline
57+
cut
58+
TestAssert "select selectedLine then cut removes line", the text of field "Test" is format("a\nb\nc\ne\nf\ng\nh\n")
59+
TestDiagnostic the text of field "Test"
60+
TestAssert "cut selectedLine includes line delimiter", the clipboardData["text"] is "d" & return
61+
TestDiagnostic the clipboardData["text"]
62+
end TestCutSelectedLine
63+
64+
on TestCopySelectedLine
65+
set the defaultStack to "Test"
66+
__ResetField
67+
copy line 4 of field "Test"
68+
TestAssert "copy line includes line delimiter", the clipboardData["text"] is "d" & return
69+
TestDiagnostic the clipboardData["text"]
70+
71+
__ResetField
72+
select before line 4 of field "Test"
73+
copy the selectedLine
74+
TestAssert "copy selectedLine includes line delimiter", the clipboardData["text"] is "d" & return
75+
TestDiagnostic the clipboardData["text"]
76+
77+
__ResetField
78+
select line 4 of field "Test"
79+
copy
80+
TestAssert "select line and copy includes line delimiter", the clipboardData["text"] is "d" & return
81+
TestDiagnostic the clipboardData["text"]
82+
83+
__ResetField
84+
select before line 4 of field "Test"
85+
select the selectedline
86+
copy
87+
TestAssert "select selectedline and copy includes line delimiter", the clipboardData["text"] is "d" & return
88+
TestDiagnostic the clipboardData["text"]
89+
end TestCopySelectedLine
90+
91+
on TestPasteSelectedLine
92+
set the clipboardData["text"] to "i"
93+
set the defaultStack to "Test"
94+
__ResetField
95+
select line 4 of field "Test"
96+
paste
97+
TestAssert "select line and paste includes line delimiter", the text of field "Test" is format("a\nb\nc\nie\nf\ng\nh\n")
98+
TestDiagnostic the text of field "Test"
99+
100+
__ResetField
101+
select before line 4 of field "Test"
102+
select the selectedline
103+
paste
104+
TestAssert "select selectedline and paste includes line delimiter", the text of field "Test" is format("a\nb\nc\nie\nf\ng\nh\n")
105+
TestDiagnostic the text of field "Test"
106+
end TestPasteSelectedLine
107+
108+
on TestDeleteSelectedLine
109+
set the defaultStack to "Test"
110+
__ResetField
111+
delete line 4 of field "Test"
112+
TestAssert "delete line removes line", the text of field "Test" is format("a\nb\nc\ne\nf\ng\nh\n")
113+
TestDiagnostic the text of field "Test"
114+
115+
__ResetField
116+
select before line 4 of field "Test"
117+
delete the selectedLine
118+
TestAssert "select the selectedLine then delete removes line", the text of field "Test" is format("a\nb\nc\ne\nf\ng\nh\n")
119+
end TestDeleteSelectedLine
120+
121+
on TestHiddenPropertyOfSelectedLine
122+
set the defaultStack to "Test"
123+
__ResetField
124+
set the hidden of line 4 of field "Test" to true
125+
TestAssert "hidden property of line is correct", the hidden of line 4 of field "Test" is true
126+
TestAssert "hidden property of line is correct after", the hidden of line 5 of field "Test" is false
127+
TestAssert "hidden property of line is correct before", the hidden of line 3 of field "Test" is false
128+
129+
__ResetField
130+
select before line 4 of field "Test"
131+
set the hidden of the selectedLine to true
132+
TestAssert "hidden property of selectedLine is correct", the hidden of line 4 of field "Test" is true
133+
TestAssert "hidden property of selectedLine is correct after", the hidden of line 5 of field "Test" is false
134+
TestAssert "hidden property of selectedLine is correct before", the hidden of line 3 of field "Test" is false
135+
end TestHiddenPropertyOfSelectedLine
136+
137+
on TestListStylePropertyOfSelectedLine
138+
set the defaultStack to "Test"
139+
__ResetField
140+
set the listStyle of line 4 of field "Test" to "disc"
141+
TestAssert "listStyle property of line is correct", the listStyle of line 4 of field "Test" is "disc"
142+
TestAssert "listStyle property of line is correct after", the listStyle of line 5 of field "Test" is empty
143+
TestAssert "listStyle property of line is correct before", the listStyle of line 3 of field "Test" is empty
144+
145+
__ResetField
146+
select before line 4 of field "Test"
147+
set the listStyle of the selectedLine to "disc"
148+
TestAssert "listStyle property of selectedLine is correct", the listStyle of line 4 of field "Test" is "disc"
149+
TestAssert "listStyle property of selectedLine is correct after", the listStyle of line 5 of field "Test" is empty
150+
TestAssert "listStyle property of selectedLine is correct before", the listStyle of line 3 of field "Test" is empty
151+
end TestListStylePropertyOfSelectedLine
152+
153+
on TestPutIntoSelectedLine
154+
set the defaultStack to "Test"
155+
__ResetField
156+
put "i" into line 4 of field "Test"
157+
TestAssert "put into line replaces text of line", the text of field "Test" is format("a\nb\nc\ni\ne\nf\ng\nh\n")
158+
TestDiagnostic the text of field "Test"
159+
160+
__ResetField
161+
select before line 4 of field "Test"
162+
put "i" into the selectedLine
163+
TestAssert "put into selectedLine replaces text of line", the text of field "Test" is format("a\nb\nc\ni\ne\nf\ng\nh\n")
164+
TestDiagnostic the text of field "Test"
165+
end TestPutIntoSelectedLine
166+
167+
on TestPutBeforeSelectedLine
168+
set the defaultStack to "Test"
169+
__ResetField
170+
put "i" before line 4 of field "Test"
171+
TestAssert "put before line inserts text before line", the text of field "Test" is format("a\nb\nc\nid\ne\nf\ng\nh\n")
172+
TestDiagnostic the text of field "Test"
173+
174+
__ResetField
175+
select before line 4 of field "Test"
176+
put "i" before the selectedLine
177+
TestAssert "put before selectedLine inserts text before line", the text of field "Test" is format("a\nb\nc\nid\ne\nf\ng\nh\n")
178+
TestDiagnostic the text of field "Test"
179+
end TestPutBeforeSelectedLine
180+
181+
on TestPutAfterSelectedLine
182+
set the defaultStack to "Test"
183+
__ResetField
184+
put "i" after line 4 of field "Test"
185+
TestAssert "put after line inserts text after line", the text of field "Test" is format("a\nb\nc\ndi\ne\nf\ng\nh\n")
186+
TestDiagnostic the text of field "Test"
187+
188+
__ResetField
189+
select before line 4 of field "Test"
190+
put "i" after the selectedLine
191+
TestAssert "put after selectedLine inserts text after line", the text of field "Test" is format("a\nb\nc\ndi\ne\nf\ng\nh\n")
192+
TestDiagnostic the text of field "Test"
193+
end TestPutAfterSelectedLine
194+
195+
on TestSelectedLineRoundTrip
196+
set the defaultStack to "Test"
197+
__ResetField
198+
select before line 4 of field "Test"
199+
TestAssert "selectedLine correct after select before line", the selectedLine is "line 4 of field 1"
200+
TestDiagnostic the selectedLine
201+
202+
select the selectedLine
203+
TestAssert "selectedLine round trips with select the selectedLine", the selectedLine is "line 4 of field 1"
204+
TestDiagnostic the selectedLine
205+
end TestSelectedLineRoundTrip

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.