/usr/share/jed/jed-extra/tests/cuamouse-test.sl is in jed-extra 2.5.6-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | % cuamouse-test.sl: Test cuamouse.sl
%
% Copyright © 2006 Günter Milde
% Released under the terms of the GNU General Public License (ver. 2 or later)
%
% Versions:
% 0.1 2006-03-03
% 02 2007-12-11 Define test-functions instead of procedural script
require("unittest");
#ifndef XWINDOWS
testmessage("\n I: cuamouse only works with xjed, skipping");
#stop
#endif
% Fixture
% -------
require("cuamouse");
private variable testbuf = "*bar*";
private variable teststring = "a test line\n";
static define setup()
{
sw2buf(testbuf);
% create a region from (2,2) to (4,6)
loop(3) {
insert("\n");
insert(teststring);
}
goto_line(2);
goto_column(2);
push_visible_mark();
goto_line(4);
goto_column(7);
}
static define teardown()
{
sw2buf(testbuf);
set_buffer_modified_flag(0);
close_buffer(testbuf);
}
% Test functions
% --------------
% click_in_region: library function
%
% SYNOPSIS
% determine whether the mouse_click is in a region
%
% USAGE
% Int click_in_region(line, col)
%
% DESCRIPTION
% Given the mouse click coordinates (line, col), the function
% returns an Integer denoting:
% -1 - click "before" region
% -2 - click "after" region
% 0 - no region defined
% 1 - click in region
% 2 - click in region but "void space" (i.e. past eol)
%
% SEE ALSO
% cuamouse_left_down_hook, cuamouse_right_down_hook
static define test_click_in_region()
{
test_equal(click_in_region(2, 2), 1, "click in the region should return 1");
test_equal(click_in_region(2, 9), 1, "click in the region should return 1");
test_equal(click_in_region(3, 1), 1, "click in the region should return 1");
test_equal(click_in_region(4, 6), 1, "click in the region should return 1");
}
% "before" region
static define test_click_in_region_before()
{
test_equal(click_in_region(1, 3), -1, "click before region should return -1");
test_equal(click_in_region(2, 1), -1, "click before region should return -1");
}
% "after" region
static define test_click_in_region_after()
{
test_equal(click_in_region(4, 7), -2, "click after region should return -2");
test_equal(click_in_region(4, 12), -2, "click after region should return -2");
test_equal(click_in_region(5, 1), -2, "click after region should return -2");
}
% in region but after eol
static define test_click_in_region_after_eol()
{
test_equal(click_in_region(2, 13), 2, "click after eol should return 2");
test_equal(click_in_region(3, 2), 2, "click after eol should return 2");
}
% no region
static define test_click_in_region_no_region()
{
pop_mark(0);
test_equal(click_in_region(1, 1), 0, "no region should return 0");
test_equal(click_in_region(2, 5), 0, "no region should return 0");
}
% copy_region_to_clipboard: static
static define test_copy_region_to_clipboard()
{
copy_region_to_clipboard();
}
% define cuamouse_insert(from_jed)
static define test_cuamouse_insert()
{
dupmark();
variable str = bufsubstr();
copy_region_to_clipboard();
push_mark();
cuamouse_insert(1);
test_equal(bufsubstr(), str, "should insert the copied text");
}
% define cuamouse_2click_hook(line, col, but, shift) %mark word
static define test_cuamouse_2click_hook()
{
pop_mark(0);
cuamouse_2click_hook(1,1,1,0);
test_true(is_visible_mark(), "double click should mark the word");
}
% internal use, test later
#stop
% define cuamouse_drag(line, col)
static define test_cuamouse_drag()
{
cuamouse_drag();
}
% define cuamouse_left_down_hook(line, col, shift)
static define test_cuamouse_left_down_hook()
{
cuamouse_left_down_hook();
}
% define cuamouse_middle_down_hook(line, col, shift)
static define test_cuamouse_middle_down_hook()
{
cuamouse_middle_down_hook();
}
% define cuamouse_right_down_hook(line, col, shift)
static define test_cuamouse_right_down_hook()
{
cuamouse_right_down_hook();
}
% define cuamouse_down_hook(line, col, but, shift)
static define test_cuamouse_down_hook()
{
cuamouse_down_hook();
}
% define cuamouse_drag_hook(line, col, but, shift)
static define test_cuamouse_drag_hook()
{
cuamouse_drag_hook();
}
% define cuamouse_up_hook(line, col, but, shift)
static define test_cuamouse_up_hook()
{
cuamouse_up_hook();
}
|