about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--source_text_tests.lua89
1 files changed, 36 insertions, 53 deletions
diff --git a/source_text_tests.lua b/source_text_tests.lua
index 5cd0f02..6084acb 100644
--- a/source_text_tests.lua
+++ b/source_text_tests.lua
@@ -267,26 +267,27 @@ function test_move_past_end_of_word_on_next_line()
   check_eq(Editor_state.cursor1.pos, 4, 'F - test_move_past_end_of_word_on_next_line/pos')
 end
 
-function test_click_with_mouse()
-  io.write('\ntest_click_with_mouse')
-  -- display two lines with cursor on one of them
-  App.screen.init{width=50, height=80}
+function test_click_moves_cursor()
+  io.write('\ntest_click_moves_cursor')
+  App.screen.init{width=50, height=60}
   Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc', 'def'}
+  Editor_state.lines = load_array{'abc', 'def', 'xyz'}
   Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=2, pos=1}
+  Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
-  -- click on the other line
-  edit.draw(Editor_state)
-  edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-  -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse/cursor:line')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse/selection is empty to avoid perturbing future edits')
+  Editor_state.selection1 = {}
+  edit.draw(Editor_state)  -- populate line_cache.starty for each line Editor_state.line_cache
+  edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_moves_cursor/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_moves_cursor/cursor:pos')
+  -- selection is empty to avoid perturbing future edits
+  check_nil(Editor_state.selection1.line, 'F - test_click_moves_cursor/selection:line')
+  check_nil(Editor_state.selection1.pos, 'F - test_click_moves_cursor/selection:pos')
 end
 
-function test_click_with_mouse_to_left_of_line()
-  io.write('\ntest_click_with_mouse_to_left_of_line')
+function test_click_to_left_of_line()
+  io.write('\ntest_click_to_left_of_line')
   -- display a line with the cursor in the middle
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -299,13 +300,13 @@ function test_click_with_mouse_to_left_of_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left-4,Editor_state.top+5, 1)
   -- cursor moves to start of line
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_to_left_of_line/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_with_mouse_to_left_of_line/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_to_left_of_line/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_to_left_of_line/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 1, 'F - test_click_to_left_of_line/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_to_left_of_line/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_takes_margins_into_account()
-  io.write('\ntest_click_with_mouse_takes_margins_into_account')
+function test_click_takes_margins_into_account()
+  io.write('\ntest_click_takes_margins_into_account')
   -- display two lines with cursor on one of them
   App.screen.init{width=100, height=80}
   Editor_state = edit.initialize_test_state()
@@ -319,13 +320,13 @@ function test_click_with_mouse_takes_margins_into_account()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_takes_margins_into_account/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_takes_margins_into_account/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_takes_margins_into_account/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_takes_margins_into_account/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_takes_margins_into_account/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_takes_margins_into_account/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_on_empty_line()
-  io.write('\ntest_click_with_mouse_on_empty_line')
+function test_click_on_empty_line()
+  io.write('\ntest_click_on_empty_line')
   -- display two lines with the first one empty
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -338,7 +339,7 @@ function test_click_with_mouse_on_empty_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_empty_line/cursor')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_empty_line/cursor')
 end
 
 function test_draw_text()
@@ -395,8 +396,8 @@ function test_draw_word_wrapping_text()
   App.screen.check(y, 'ghi', 'F - test_draw_word_wrapping_text/screen:3')
 end
 
-function test_click_with_mouse_on_wrapping_line()
-  io.write('\ntest_click_with_mouse_on_wrapping_line')
+function test_click_on_wrapping_line()
+  io.write('\ntest_click_on_wrapping_line')
   -- display two lines with cursor on one of them
   App.screen.init{width=50, height=80}
   Editor_state = edit.initialize_test_state()
@@ -409,13 +410,13 @@ function test_click_with_mouse_on_wrapping_line()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_wrapping_line/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_on_wrapping_line/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_on_wrapping_line/selection is empty to avoid perturbing future edits')
 end
 
-function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()
-  io.write('\ntest_click_with_mouse_on_wrapping_line_takes_margins_into_account')
+function test_click_on_wrapping_line_takes_margins_into_account()
+  io.write('\ntest_click_on_wrapping_line_takes_margins_into_account')
   -- display two lines with cursor on one of them
   App.screen.init{width=100, height=80}
   Editor_state = edit.initialize_test_state()
@@ -429,9 +430,9 @@ function test_click_with_mouse_on_wrapping_line_takes_margins_into_account()
   edit.draw(Editor_state)
   edit.run_after_mouse_click(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
   -- cursor moves
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_click_with_mouse_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')
+  check_eq(Editor_state.cursor1.line, 1, 'F - test_click_on_wrapping_line_takes_margins_into_account/cursor:line')
+  check_eq(Editor_state.cursor1.pos, 2, 'F - test_click_on_wrapping_line_takes_margins_into_account/cursor:pos')
+  check_nil(Editor_state.selection1.line, 'F - test_click_on_wrapping_line_takes_margins_into_account/selection is empty to avoid perturbing future edits')
 end
 
 function test_draw_text_wrapping_within_word()
@@ -856,24 +857,6 @@ function test_insert_from_clipboard()
   App.screen.check(y, 'def', 'F - test_insert_from_clipboard/screen:3')
 end
 
-function test_move_cursor_using_mouse()
-  io.write('\ntest_move_cursor_using_mouse')
-  App.screen.init{width=50, height=60}
-  Editor_state = edit.initialize_test_state()
-  Editor_state.lines = load_array{'abc', 'def', 'xyz'}
-  Text.redraw_all(Editor_state)
-  Editor_state.cursor1 = {line=1, pos=1}
-  Editor_state.screen_top1 = {line=1, pos=1}
-  Editor_state.screen_bottom1 = {}
-  Editor_state.selection1 = {}
-  edit.draw(Editor_state)  -- populate line_cache.starty for each line Editor_state.line_cache
-  edit.run_after_mouse_release(Editor_state, Editor_state.left+8,Editor_state.top+5, 1)
-  check_eq(Editor_state.cursor1.line, 1, 'F - test_move_cursor_using_mouse/cursor:line')
-  check_eq(Editor_state.cursor1.pos, 2, 'F - test_move_cursor_using_mouse/cursor:pos')
-  check_nil(Editor_state.selection1.line, 'F - test_move_cursor_using_mouse/selection:line')
-  check_nil(Editor_state.selection1.pos, 'F - test_move_cursor_using_mouse/selection:pos')
-end
-
 function test_select_text_using_mouse()
   io.write('\ntest_select_text_using_mouse')
   App.screen.init{width=50, height=60}
itle='Blame the previous revision' href='/akkartik/mu/blame/058generic_container.cc?h=main&id=e3cb4d0905bdfb1c0b9d520c9c0089cffc09e339'>^
5d4a1d3b ^
e3cb4d09 ^
e3cb4d09 ^

5d4a1d3b ^
e3cb4d09 ^


5967e82f ^
795f5244 ^
e3cb4d09 ^




a4f12265 ^
17b90929 ^
a4f12265 ^





a09697d0 ^
a4f12265 ^



b954ac38 ^





a4f12265 ^


17b90929 ^
a09697d0 ^










17b90929 ^
7637d1ac ^









a09697d0 ^

b954ac38 ^

a9a23371 ^
a09697d0 ^












a9a23371 ^
5d4a1d3b ^
a09697d0 ^

5d4a1d3b ^
b954ac38 ^
5d4a1d3b ^

a9a23371 ^



a09697d0 ^
a9a23371 ^
a09697d0 ^

a9a23371 ^
a09697d0 ^
a9a23371 ^
a09697d0 ^


a9a23371 ^
5d4a1d3b ^





17b90929 ^
5d4a1d3b ^












17b90929 ^
a4f12265 ^










b954ac38 ^





a4f12265 ^


17b90929 ^
a4f12265 ^












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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245

                                                       


                                                                             
                                                   
 
                                            






















                                                                              
                                                              



                                                  










                                                                             
                                                                        
                                                 
                                                                 
                                                           
                        




                                                                                                      
                                                               





                                                        

                                                                                            




                                         
                                                                                                   



                                                        
                                                                       
                                                                              

                                                                                                                           
                 



           
                                    


                                                                                                        
                      
                                     

                            
                        


                                        
                                                 
                                                                                              




                                            
 
                                           





                                 
                                       



                               





                                                                                                                                 


           
                                             










                                      
                                             









                                                      

                                          

                                                                                                                                          
                                                                    












                                                                                       
                                                                                       
                                                                          

                                                      
                                                                                   
                                                                                                                                      

             



                                                                                                       
   
                                                              

 
                                                                   
                 
                          


                                    
                                                           





                                        
                                                 












                                                                         
                                                   










                                                        





                                                                                                                           


           
                                                                           












                                 
garam <vc@akkartik.com>  2016-03-20 00:48:04 -0700
committer  Kartik K. Agaram <vc@akkartik.com>  2016-03-20 00:55:33 -0700

2799 - new approach to undoing changes in tests' href='/akkartik/mu/commit/091run_interactive.cc?h=main&id=2429c65cce16a11841212a71ec2bb50373aa54d4'>2429c65c ^
9e4f1844 ^
2429c65c ^
9e4f1844 ^
2429c65c ^
9e4f1844 ^
2429c65c ^
9e4f1844 ^
2429c65c ^
9e4f1844 ^
2429c65c ^










06584c52 ^

5db2faeb ^





b0bf5321 ^
8ee53369 ^





df2c1409 ^
b0bf5321 ^


1625e908 ^
1ead3562 ^
5db2faeb ^
5db2faeb ^
5ed9bb13 ^
4814bf94 ^


1d13dac8 ^
1ead3562 ^
b0bf5321 ^
1d13dac8 ^
1625e908 ^
b0bf5321 ^
1d13dac8 ^


5db2faeb ^


795f5244 ^
166e3c0d ^



5db2faeb ^








795f5244 ^
166e3c0d ^



5db2faeb ^








795f5244 ^
166e3c0d ^



5db2faeb ^







05331766 ^
5f98a10c ^
05331766 ^
5f98a10c ^
05331766 ^
5f98a10c ^


05331766 ^
5f98a10c ^
5ed9bb13 ^
5f98a10c ^



7afe09fb ^
5db2faeb ^
795f5244 ^
166e3c0d ^
7afe09fb ^
166e3c0d ^

5db2faeb ^
7afe09fb ^
5db2faeb ^
e00d4854 ^
5db2faeb ^



1625e908 ^
5db2faeb ^
1625e908 ^
166e3c0d ^
1625e908 ^
166e3c0d ^

5db2faeb ^
1625e908 ^
06584c52 ^
5db2faeb ^


3f7eed6c ^
1ead3562 ^
9fdda88b ^
b0bf5321 ^
1625e908 ^
b0bf5321 ^
9fdda88b ^



3f7eed6c ^
1ead3562 ^
76d22198 ^
b0bf5321 ^



76d22198 ^
1625e908 ^
b0bf5321 ^
76d22198 ^




5f98a10c ^
1ead3562 ^
5f98a10c ^
b0bf5321 ^
75a00270 ^
1625e908 ^
b0bf5321 ^
0685569c ^
5f98a10c ^
0685569c ^



75a00270 ^
0685569c ^
957ca9c9 ^
1ead3562 ^
957ca9c9 ^
b0bf5321 ^
957ca9c9 ^

1625e908 ^
957ca9c9 ^



9fdda88b ^
dd9eda26 ^
90938fcb ^
dd9eda26 ^
3eb81335 ^
dd9eda26 ^

90938fcb ^
9fdda88b ^
dd9eda26 ^
9fdda88b ^
b24eb476 ^
76d22198 ^

48e40252 ^
8d7b228e ^
de92036d ^
76d22198 ^



b24eb476 ^
4082acd2 ^
9fdda88b ^

dd9eda26 ^
9fdda88b ^
f2564285 ^
9fdda88b ^
be13beeb ^

b24eb476 ^
be13beeb ^



957ca9c9 ^
be13beeb ^
be13beeb ^

be13beeb ^


b24eb476 ^
548cd00a ^

795f5244 ^
de92036d ^
548cd00a ^

b24eb476 ^
5f98a10c ^


5ed9bb13 ^
5f98a10c ^








b24eb476 ^
0685569c ^
0685569c ^

e00d4854 ^
0685569c ^


0cfc678f ^
e00d4854 ^
0cfc678f ^




fda4f091 ^

0cfc678f ^



0685569c ^
f0eb3556 ^
1625e908 ^
5ed9bb13 ^
06584c52 ^
f0eb3556 ^


795f5244 ^
166e3c0d ^
f0eb3556 ^
166e3c0d ^
8d72e565 ^
e4630643 ^

7afe09fb ^
9dcbec39 ^
e4630643 ^

166e3c0d ^



0f0d3e7a ^










0a2026a6 ^
0f0d3e7a ^
06584c52 ^

1625e908 ^
0a2026a6 ^
f0eb3556 ^
4efc0ff3 ^
1625e908 ^
06584c52 ^
cfb142b9 ^
5ed9bb13 ^
06584c52 ^
f0eb3556 ^

06584c52 ^
5f98a10c ^
1ead3562 ^
06584c52 ^
b0bf5321 ^
06584c52 ^





0f0d3e7a ^




b0bf5321 ^
0f0d3e7a ^















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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517