[Pkg-jed-commit] r446 - jed-extra/trunk/tests

Guenter Milde milde-guest at costa.debian.org
Fri Oct 6 10:02:34 UTC 2006


Author: milde-guest
Date: 2006-10-06 10:02:33 +0000 (Fri, 06 Oct 2006)
New Revision: 446

Added:
   jed-extra/trunk/tests/ch_table-test.sl
   jed-extra/trunk/tests/csvutils-test.sl
   jed-extra/trunk/tests/cuamark-test.sl
   jed-extra/trunk/tests/cuamouse-test.sl
   jed-extra/trunk/tests/datutils-test.sl
   jed-extra/trunk/tests/ishell-test.sl
   jed-extra/trunk/tests/listing-test.sl
Removed:
   jed-extra/trunk/tests/test-ch_table.sl
   jed-extra/trunk/tests/test-csvutils.sl
   jed-extra/trunk/tests/test-cuamark.sl
   jed-extra/trunk/tests/test-cuamouse.sl
   jed-extra/trunk/tests/test-ishell.sl
Log:
new and updated test scripts (for unittest (>= 0.3))


Added: jed-extra/trunk/tests/ch_table-test.sl
===================================================================
--- jed-extra/trunk/tests/ch_table-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/ch_table-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,168 @@
+% ch_table-testª.sl: 
+% 
+% Copyright (c) 2006 Günter Milde
+% Released under the terms of the GNU General Public License (ver. 2 or later)
+%
+% Versions:
+% 0.1 2006-03-03 
+
+% Test ch_table.sl
+
+% private namespace: `ch_table'
+
+% set fixture:
+require("unittest");
+
+static define setup()
+{
+   popup_buffer("*bar*");
+   insert("bar\n");
+}
+       
+static define teardown()
+{
+   sw2buf("*bar*");
+   set_buffer_modified_flag(0);
+   close_buffer("*bar*");
+}
+
+
+% test the public defined functions:
+test_equal(is_defined("ch_table"), 2, "ch_table() should be defined");
+test_equal(is_defined("special_chars"), 2, "special_chars() should be defined");
+
+require("ch_table");
+
+% ch_table: library function  Undocumented
+%  public define ch_table () % ch_table(StartChar = 0)
+static define test_ch_table()
+{
+   ch_table();
+   test_equal(whatbuf(), "*ch_table*");
+   close_buffer("*ch_table*");
+}
+
+% special_chars: library function  Undocumented
+%  public define special_chars ()
+static define test_special_chars()
+{
+   special_chars();
+   test_equal(whatbuf(), "*ch_table*");
+   close_buffer("*ch_table*");
+}
+
+% ct_load_popup_hook: library function  Undocumented
+%  define ct_load_popup_hook (menubar)
+% test_function("ct_load_popup_hook");
+
+% int2string: undefined  Undocumented
+%  static define int2string(i, base)
+test_function("ch_table->int2string", 32, 10);
+test_last_result("32");
+test_function("ch_table->int2string", 32, 16);
+test_last_result("20");
+test_function("ch_table->int2string", 32, 8);
+test_last_result("40");
+test_function("ch_table->int2string", 32, 2);
+test_last_result("100000");
+
+% string2int: undefined  Undocumented
+%  static define string2int(s, base)
+test_function("ch_table->string2int", "32", 10);
+test_last_result(32);
+test_function("ch_table->string2int", "20", 16);
+test_last_result(32);
+test_function("ch_table->string2int", "40", 8);
+test_last_result(32);
+test_function("ch_table->string2int", "100000", 2);
+test_last_result(32);
+
+% ct_status_line: undefined  Undocumented
+%  static define ct_status_line()
+% test_function("ch_table->ct_status_line");
+
+% ct_update: undefined  Undocumented
+%  static define ct_update ()
+% test_function("ch_table->ct_update");
+
+% ct_up: undefined  Undocumented
+%  static define ct_up ()
+% test_function("ch_table->ct_up");
+
+% ct_down: undefined  Undocumented
+%  static define ct_down ()
+static define test_ct_down()
+{
+   special_chars();
+   ch_table->ct_down();
+   % () = get_y_or_n("continue");
+   test_equal(bufsubstr()[0], 170, "special_chars should highlight char 170");
+   close_buffer("*ch_table*");
+}
+
+% ct_right: undefined  Undocumented
+%  static define ct_right ()
+% test_function("ch_table->ct_right");
+
+% ct_left: undefined  Undocumented
+%  static define ct_left ()
+% test_function("ch_table->ct_left");
+
+% ct_bol: undefined  Undocumented
+%  static define ct_bol ()   { bol; ct_right;}
+% test_function("ch_table->ct_bol");
+
+% ct_eol: undefined  Undocumented
+%  static define ct_eol ()   { eol; ct_update;}
+% test_function("ch_table->ct_eol");
+
+% ct_bob: undefined  Undocumented
+%  static define ct_bob ()   { goto_line(3); ct_right;}
+% test_function("ch_table->ct_bob");
+
+% ct_eob: undefined  Undocumented
+%  static define ct_eob ()   { eob; ct_update;}
+% test_function("ch_table->ct_eob");
+
+% ct_mouse_up_hook: undefined  Undocumented
+%  static define ct_mouse_up_hook (line, col, but, shift)
+% test_function("ch_table->ct_mouse_up_hook");
+
+% ct_mouse_2click_hook: undefined  Undocumented
+%  static define ct_mouse_2click_hook (line, col, but, shift)
+% test_function("ch_table->ct_mouse_2click_hook");
+
+% ct_goto_char: undefined  Undocumented
+%  static define ct_goto_char ()
+% test_function("ch_table->ct_goto_char");
+
+% insert_ch_table: undefined  Undocumented
+%  static define insert_ch_table ()
+% test_function("ch_table->insert_ch_table");
+
+% use_base: undefined  Undocumented
+%  static define use_base (numbase)
+% test_function("ch_table->use_base");
+
+% ct_change_base: undefined  Undocumented
+%  static define ct_change_base ()
+% test_function("ch_table->ct_change_base");
+
+% setup_dfa_callback: undefined  Undocumented
+%  static define setup_dfa_callback (mode)
+% test_function("ch_table->setup_dfa_callback");
+
+% ct_insert_and_close: undefined  Undocumented
+%  static define ct_insert_and_close ()
+static define test_ct_insert_and_close()
+{
+   special_chars();
+   ch_table->ct_down();
+   ch_table->ct_insert_and_close();
+   push_mark();
+   go_left_1();
+   test_equal(bufsubstr(), "ª");
+}
+  
+update(1);
+

Added: jed-extra/trunk/tests/csvutils-test.sl
===================================================================
--- jed-extra/trunk/tests/csvutils-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/csvutils-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,281 @@
+% csvutils-test.sl:  Test csvutils.sl Test csvutils.sl
+% 
+% Copyright (c) 2006 Günter Milde
+% Released under the terms of the GNU General Public License (ver. 2 or later)
+%
+% Versions:
+% Versions:
+% 0.1 2006-03-03   basic test, check public functions
+% 0.2 2006-03-03   use test function discovery
+
+require("unittest");
+require("txtutils");
+require("datutils");
+
+% uncomment if you do not want to test default activation
+test_true(is_defined("buffer_compress"), "public function buffer_compress undefined");
+test_true(is_defined("format_table"), "public function format_table undefined");
+test_true(is_defined("goto_max_column"), "public function goto_max_column undefined");
+
+testmessage(" only basic test, arguments not tested completely");
+
+
+% Fixture
+% -------
+
+require("csvutils");
+
+private variable testbuf = "*bar*";
+private variable teststring = "first line \n  second   line" ;
+private variable testtable = strtok(teststring);
+reshape(testtable, [2,2]);
+private variable linelength = array_map(Int_Type, &strlen, 
+                                        strtok(teststring,"\n"));
+private variable max_linelength = array_max(linelength);   
+
+static define setup()
+{
+   sw2buf(testbuf);
+   insert(teststring);
+}
+
+static define teardown()
+{
+   sw2buf(testbuf);
+   set_buffer_modified_flag(0);
+   close_buffer(testbuf);
+}
+
+% Test functions
+% --------------
+
+% define get_lines() % (kill=0)
+static define test_get_lines()
+{
+   variable lines = get_lines();
+   test_equal(lines, strtok(teststring, "\n"));
+}
+
+% buffer_compress: library function
+% 
+%  SYNOPSIS
+%   Remove excess whitespace characters from the buffer
+% 
+%  USAGE
+%   Void buffer_compress(white="\t ")
+% 
+%  DESCRIPTION
+%   Calls `strcompress' on the buffer or (if visible) region.
+% 
+%  SEE ALSO
+%   trim_buffer, strcompress, get_lines, get_buffer
+static define test_buffer_compress()
+{
+   buffer_compress();
+   test_equal(get_buffer(), strjoin2d(testtable),
+      "buffer_compress() should replace in-line whithespace with tabs");
+   buffer_compress(" \t");
+   test_equal(get_buffer(), strjoin2d(testtable, " "),
+      "buffer_compress should call strcompress() on the buffer");
+}
+
+
+% strchop2d: undefined
+% 
+%  SYNOPSIS
+%   Chop a string into a 2d-array (lines and columns)
+% \usage{Array strchop2d(str, col_sep='\t', line_sep='\n', quote=0)
+%        Array strchop2d(String str, String col_sep, line_sep='\n')}
+% 
+%  DESCRIPTION
+%   The 2d equivalent to strchop and strtok. Split the string first into
+%   lines (or equivalent with line_sep != '\n') and then into fields.
+%   Return the result as a 2d-array with missing values set to NULL
+% 
+%   The datatype of col_sep determines which function is used to split
+%   the lines:
+%     if typeof(col_sep) == String_Type, use strtok, else use strchop
+% 
+%  EXAMPLE
+% 
+%    strchop2d(bufsubstr, " \t")
+% 
+%   will return the data in the region interpreted as a white-space
+%   delimited table.
+% 
+%  SEE ALSO
+%   strchop, strtok, read_table
+static define test_strchop2d()
+{
+   variable table = strchop2d(teststring, " ");
+   test_equal(table, testtable, "strchop2d should return a 2d array");
+}
+
+% get_table: undefined
+% 
+%  SYNOPSIS
+%   Return a 2d-string-array with csv data in the region/buffer
+% 
+%  USAGE
+%   String get_table(col_sep="", kill=0)
+% 
+%  DESCRIPTION
+%  Return a 2d-string-array with the data in the region/buffer
+%  The default col_sep=="" means whitespace (any number of spaces or tabs).
+%  The optional argument `kill' tells, whether the table should be
+%  deleted after reading.
+% 
+% 
+%  EXAMPLE
+% 
+%     get_table(" ");   % columns are separated by single spaces
+%     get_table(" | "); % columns are separated by space-sourounded bars
+%     get_table("");    % columns are separated by any whitespace (default)
+% 
+% 
+%  SEE ALSO
+%   strchop2d, format_table, insert_table
+static define test_get_table()
+{
+   variable table = get_table();
+   test_equal(table, testtable, "get_table should return a 2d array");
+}
+
+% strjoin2d: library function
+% 
+%  SYNOPSIS
+%   Print 2d-array as a nicely formatted table to a string
+% 
+%  USAGE
+%   Str strjoin2d(Array a, col_sep="\t", line_sep="\n", align=NULL)
+% 
+%  DESCRIPTION
+%    The function takes an 2d-array and returns a string that represents
+%    the data as an csv-table. It can be seen as a 2d-variant of
+%    strjoin(Array_Type a, String_Type delim).
+% 
+%  SEE ALSO
+%   strjoin, strchop2d, insert_table, get_table
+static define test_strjoin2d()
+{
+   variable str = strjoin2d(testtable);
+   test_equal(str, "first\tline\nsecond\tline");
+}
+
+% insert_table: undefined
+% 
+%  SYNOPSIS
+%   Print 2d-array as a nicely formatted table
+% 
+%  USAGE
+%   Void insert_table(Array a, align="l", col_sep=" ")
+% 
+%  DESCRIPTION
+%    The function takes an 2d-array and writes it as an aligned table.
+%    `col_sep' is the string separating the items on a line. It defaults 
+%    to " " (space).
+%    `align' is a format string formed of the key charaters:
+%      "l": left align,
+%      "r": right align,
+%      "c": center align, or
+%      "n": no align (actually every character other than "lrc"),
+%    one for each column. If the string is shorter than the number of columns,
+%    it will be repeated, i.e. if it contains only one character, the
+%    align is the same for all columns)
+% 
+%  EXAMPLE
+%    The call
+% 
+%         insert_table(a, " | ", "llrn");
+% 
+%    inserts `a' as a table with elements separated by " | " and
+%    first and second columns left aligned, third column right aligned
+%    and last column not aligned.
+% 
+%  SEE ALSO
+%   get_table, strjoin2d, strjoin
+static define test_insert_table()
+{
+   erase_buffer();
+   insert_table(testtable);
+   test_equal(get_buffer(), "first  line\n"
+                           +"second line\n");
+}
+
+% format_table: library function
+% 
+%  SYNOPSIS
+%   Adjust a table to evenly spaced columns
+% 
+%  USAGE
+%   format_table(col_sep=NULL, align=NULL, new_sep=NULL)
+% 
+%  DESCRIPTION
+%   Read visible region or buffer as grid data into a 2d array, reformat and
+%   insert again.  The indention of the whole table is determined by the point
+%   or mark (whichever is more left) if a visible region is defined.
+% 
+%   If the arguments are not given, they will be asked for in the minibuffer:
+%     `col_sep':     the string separating columns (default "" means whitespace)
+%     `align':       string of "l", "r", "c", or "n" (see `insert_table')
+%     `new_sep':     string to separate the columns in the output.
+% 
+%  SEE ALSO
+%   get_table, insert_table
+static define test_format_table()
+{
+   format_table("", "n", "|");
+   test_equal(get_buffer(), "first|line\nsecond|line\n");
+}
+
+% define max_column()
+static define test_max_column()
+{
+   test_equal(max_column(), max_linelength+1);
+}
+
+% goto_max_column: library function
+% 
+%  SYNOPSIS
+%   Goto the maximal column of the buffer (or region)
+% 
+%  USAGE
+%   goto_max_column()
+% 
+%  DESCRIPTION
+%  Goto the column of the longest line of the buffer (or, if visible, region).
+%  Insert whitespace if needed. The region stays marked.
+%  
+%  If the optional parameter `trim' is nonzero, trailing
+%  whitespace will be removed during the scan.
+% 
+%  NOTES
+%  This function comes handy, if you want to mark a rectagle but
+%  the last line is shorter than preceding lines.
+% 
+%  SEE ALSO
+%   max_column, goto_column, copy_rect
+static define test_goto_max_column()
+{
+   goto_max_column();
+   test_equal(what_column(), max_linelength+1,
+      "point should be at the column of the longest line in the buffer");
+}
+
+% define compute_columns() % (a, width=SCREEN_WIDTH, col_sep_length=1)
+static define test_compute_columns()
+{
+   test_equal(compute_columns(strtok(teststring), 14, 1), 2,
+      "2 columns should fit");
+}
+
+% define list2table() % (a, cols=compute_columns(a))
+static define test_list2table()
+{
+   variable table = list2table(strtok(teststring), 2);
+   test_equal(table[0,*], testtable[*,0]);
+   test_equal(table[1,*], testtable[*,1]);
+}
+
+sw2buf("*test report*");
+view_mode();

Added: jed-extra/trunk/tests/cuamark-test.sl
===================================================================
--- jed-extra/trunk/tests/cuamark-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/cuamark-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,144 @@
+% cuamark-test.sl:  Test cuamark.sl
+% 
+% Copyright (c) 2006 Günter Milde
+% Released under the terms of the GNU General Public License (ver. 2 or later)
+%
+% Versions:
+% 0.1 2006-10-05
+
+require("unittest");
+require("txtutils");
+
+% Fixture
+% -------
+
+require("cuamark");
+
+private variable testbuf = "*bar*";
+private variable teststring = "a test line";
+
+static define setup()
+{
+   sw2buf(testbuf);
+   insert(teststring);
+}
+
+static define teardown()
+{
+   sw2buf(testbuf);
+   set_buffer_modified_flag(0);
+   close_buffer(testbuf);
+}
+
+% Test functions
+% --------------
+
+% cua_mark: library function
+% 
+%  SYNOPSIS
+%   Mark a cua-region (usually, with Shift-Arrow keys)
+% 
+%  USAGE
+%   cua_mark()
+% 
+%  DESCRIPTION
+%    if no visible region is defined, set visible mark and key-hooks
+%    so that Cua_Unmarking_Functions unmark the region and
+%    Cua_Deleting_Functions delete it.
+% 
+%  SEE ALSO
+%   cua_kill_region, cua_copy_region, Cua_Unmarking_Functions, Cua_Deleting_Functions
+static define test_cua_mark()
+{
+   bob();
+   cua_mark();
+   eob();  % this should not cancel the mark (see Cua_Unmarking_Functions)
+   test_true(is_visible_mark(), "there should be a visible mark");
+   test_equal(bufsubstr(), teststring, 
+      "the marked region should equal the teststring");
+}
+
+% cua_insert_clipboard: library function
+% 
+%  SYNOPSIS
+%   Insert X selection at point
+% 
+%  USAGE
+%   Void cua_insert_clipboard()
+% 
+%  DESCRIPTION
+%  Insert the content of the X selection at point.
+%  Use, if you want to have a keybinding for the "middle click" action.
+% 
+%  NOTES
+%  This function doesnot return the number of characters inserted so it can
+%  be bound to a key easily.
+% 
+%  SEE ALSO
+%   x_insert_selection, x_insert_cutbuffer
+% static define test_cua_insert_clipboard()
+% {
+   % TODO: for some strange reason, the insertion is only visible after the next
+   % keypress!!!
+   % !if (is_defined("x_copy_region_to_selection") or 
+   %      is_defined("x_copy_region_to_cutbuffer"))
+   %   {
+   %      testmessage("I: x_copy_region_to_... not available... skipping");
+   %      return;
+   %   }
+   % mark_buffer();
+   % cua_kill_region();
+   % test_true(bobp() and eobp(), "The buffer should be empty now");
+   % cua_insert_clipboard();
+   % test_equal(get_buffer(), teststring, "The teststring should be reinserted");
+% }
+
+% cua_kill_region: library function
+% 
+%  SYNOPSIS
+%   Kill region (and copy to yp-yankbuffer [and X selection])
+% 
+%  USAGE
+%   Void cua_kill_region()
+% 
+%  DESCRIPTION
+%    Kill region. A copy is placed in the yp-yankbuffer.
+% 
+%    If `x_copy_region_to_selection' or `x_copy_region_to_cutbuffer'
+%    exist, a copy is pushed to the X selection as well.
+% 
+%  SEE ALSO
+%   yp_kill_region, cua_copy_region, yp_yank
+static define test_cua_kill_region()
+{
+   mark_buffer();
+   cua_kill_region();
+   test_true(bobp() and eobp(), "The buffer should be empty now");
+   yp_yank();
+   test_equal(get_buffer(), teststring, "yp_yank should reinsert the kill");
+}
+
+% cua_copy_region: library function
+% 
+%  SYNOPSIS
+%   Copy region to yp-yankbuffer [and X selection])
+% 
+%  USAGE
+%   Void cua_copy_region()
+% 
+%  DESCRIPTION
+%    Copy the region to the yp-yankbuffer.
+% 
+%    If `x_copy_region_to_selection' or `x_copy_region_to_cutbuffer'
+%    exist, a copy is pushed to the X selection as well.
+% 
+%  SEE ALSO
+%   yp_copy_region_as_kill, cua_kill_region, yp_yank
+static define test_cua_copy_region()
+{
+   mark_buffer();
+   cua_copy_region();
+   yp_yank();
+   test_equal(get_buffer(), teststring+teststring,
+      "yp_yank should append the copy");
+}

Added: jed-extra/trunk/tests/cuamouse-test.sl
===================================================================
--- jed-extra/trunk/tests/cuamouse-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/cuamouse-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,200 @@
+% cuamouse-test.sl:  Test cuamouse.sl
+%
+% Copyright (c) 2006 Günter Milde
+% Released under the terms of the GNU General Public License (ver. 2 or later)
+%
+% Versions:
+% 0.1 2006-03-03
+
+require("unittest");
+
+#ifndef XWINDOWS
+testmessage("\n  I: cuamouse only works with xjed, skipping");
+#stop
+#endif
+
+% test availability of public functions (comment to skip)
+test_true(is_defined("copy_region_to_clipboard"), "public fun copy_region_to_clipboard undefined");
+
+% 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)
+   insert("\n");
+   insert(teststring);
+   insert("\n");
+   insert(teststring);
+   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
+%           -3 - click in region but "void space" (i.e. past eol)
+%            0 - no region defined
+%            1 - click in region
+%
+%  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), -3, "click after eol should return -3");
+   test_equal(click_in_region(3, 2), -3, "click after eol should return -3");
+}
+
+% 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: library function
+%
+%  SYNOPSIS
+%   Copy region to x-selection/cutbuffer and internal mouse clipboard
+%
+%  USAGE
+%    copy_region_to_clipboard()
+%
+%  DESCRIPTION
+%    Copy region to selection/cutbuffer and internal mouse clipboard.
+%
+%    The region stays marked.
+%
+%  NOTES
+%    Tries x_copy_region_to_selection() and x_copy_region_to_cutbuffer()
+%    (in this order).
+%
+%    With CuaMouse_Use_Xclip = 1, the region is piped to the `xclip` command
+%    line tool instead. This is a workaround for interaction with applications
+%    using the QT toolkit that refuse to paste the selected text otherwise.
+%
+%  SEE ALSO
+%   CuaMouse_Use_Xclip, copy_region, yp_copy_region_as_kill
+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();
+}

Added: jed-extra/trunk/tests/datutils-test.sl
===================================================================
--- jed-extra/trunk/tests/datutils-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/datutils-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,31 @@
+% Test the functions in datutils.sl 
+% 
+% Copyright (c) 2006 Günter Milde
+% Released under the terms of the GNU General Public License (ver. 2 or later)
+%
+% Versions:
+% 0.1 2006-03-03 
+
+_debug_info = 1;
+
+require("unittest");
+
+% Fixture: provide some test data
+variable lst = {1,2,3,4};
+variable strlist = {"hello", "world"};
+
+% Test the public functions
+
+% list2array with optional arg
+test_function("list2array", lst, Integer_Type);
+test_function("list2array", strlist, String_Type);
+% list2array without otional arg
+test_function("list2array", lst);
+test_function("list2array", strlist);
+
+% test the result
+$1 = where([1,2,3,4] == list2array(lst));
+test_equal(length(lst), length($1));
+
+popup_buffer("*test report*", 1.0);
+view_mode();

Added: jed-extra/trunk/tests/ishell-test.sl
===================================================================
--- jed-extra/trunk/tests/ishell-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/ishell-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,173 @@
+% Test ishell.sl
+
+% currently, this tests function calls for errors but does only a partial
+% test of advertised functionality
+
+
+% ishell.sl: Interactive shell mode (based on ashell.sl by J. E. Davis)
+
+% custom_variable("Ishell_default_output_placement", ">");
+% custom_variable("Ishell_logout_string", ""); % default is Ctrl-D
+% custom_variable("Ishell_Max_Popup_Size", 10);
+% custom_variable("Shell_Default_Shell", getenv ("COMSPEC"));
+% custom_variable("Ishell_Default_Shell", Shell_Default_Shell);
+% custom_variable("Shell_Default_Shell", getenv ("SHELL"));
+% custom_variable("Ishell_Default_Shell", Shell_Default_Shell+" -i");
+
+require("unittest");
+
+% Fixture
+% -------
+
+autoload("Global->ishell_send_input", "ishell");
+autoload("Global->ishell_logout", "ishell");
+autoload("get_buffer", "txtutils");
+
+private variable cmd = "echo 'hello world'";
+% the setting of ADD_NEWLINE has influence of the return value of 
+% functions saving the buffer (e.g. using bufsubstring()) and processing the
+% resulting file
+private variable add_newline_before = ADD_NEWLINE;
+
+static define mode_setup()
+{
+   ADD_NEWLINE = 0; 
+}
+
+
+static define mode_teardown()
+{
+   ADD_NEWLINE = add_newline_before;
+}
+
+static define setup()
+{
+   popup_buffer("*bar*");
+   insert("bar bar");
+}
+       
+static define teardown()
+{
+   sw2buf("*bar*");
+   set_buffer_modified_flag(0);
+   close_buffer("*bar*");
+}
+
+
+% ishell_mode(cmd=Ishell_Default_Shell); Open a process and attach it to the current buffer.
+% test_function("ishell_mode");
+static define test_ishell_mode()
+{
+   ishell_mode(); % attach a shell to the buffer
+   % test the attached shell
+   % 
+   % to test the proper working, we would need a way to synchronize the
+   % assynchron working (i.e. wait for a response from the command.)
+   % 
+   % Maybe input_pending() can be (ab)used in conjunction with an output handler
+   % pushing a string back on the input-stream (ungetkey()). (Maybe a special
+   % blocal "Ishell_output_filter"?)
+   
+   usleep(2000);  % wait for the startup
+   insert("pwd");
+   ishell_send_input();
+   usleep(1000);  % wait for the result
+   % logout
+   ishell_logout();
+   usleep(1000);  % wait for the result
+}
+
+
+static define test_ishell()
+{
+   ishell(); % Interactive shell
+
+   if (whatbuf() != "*ishell*")
+     throw AssertionError, "  not in *ishell* buffer";
+
+   % % logout
+   % ishell_logout();
+   % usleep(1000);  % wait for the result
+   % close
+   set_buffer_modified_flag(0);
+   delbuf("*ishell*");
+}
+
+% terminal(cmd = Ishell_Default_Shell); Run a command in a terminal
+static define test_terminal()
+{
+   % terminal();       % doesnot close!
+   terminal("logout");
+}
+
+
+% shell_command(cmd="", output_handling=0); Run a shell command
+static define test_shell_command_0()
+{
+   shell_command(cmd, 0); % output to "*shell-output*"
+   test_equal(get_buffer(), "hello world\n");
+   test_equal(whatbuf(), "*shell-output*");
+   close_buffer("*shell-output*");
+}
+
+static define test_shell_command_named_buffer()
+{
+   shell_command(cmd, "*foo*"); % output to buffer "*foo*"
+   test_equal(get_buffer(), "hello world\n");
+   test_equal(whatbuf(), "*foo*");
+   close_buffer("*foo*");
+}
+
+static define test_shell_command_1() % insert at point
+{
+   shell_command(cmd, 1); 
+   test_equal(get_buffer(), "bar barhello world\n");
+}
+
+static define test_shell_command_2() % replace region/buffer at point
+{
+   shell_command(cmd, 2); 
+   test_equal(get_buffer(), "hello world\n");
+}
+
+static define test_shell_command_3() % return output
+{
+   test_equal("hello world\n", shell_command(cmd, 3));
+}
+
+static define test_shell_command_4() % message output
+{
+   shell_command(cmd, 4);
+   test_equal("hello world\n", MESSAGE_BUFFER);
+}
+
+static define test_shell_command_ignore()
+{
+   shell_command(cmd, -1); % ignore output
+}
+
+
+% shell_cmd_on_region_or_buffer: library function  Undocumented
+static define test_shell_cmd_on_region_or_buffer()
+{
+   push_visible_mark();
+   bob();
+   test_equal(shell_cmd_on_region_or_buffer("cat", 3), "bar bar");
+}
+
+  
+% shell_cmd_on_region(cmd="", output_handling=0, postfile_args=""); Save region to a temp file and run a command on it
+static define test_shell_cmd_on_region()
+{
+   test_equal(shell_cmd_on_region("cat", 3), "bar bar");
+}
+
+
+% filter_region(cmd=NULL); Filter the region through a shell command
+static define test_filter_region()
+{
+   filter_region("wc");
+   % the filename part of the output differs as we use a tmp file
+   test_equal(get_buffer()[[0:4]], "0 2 7",
+      "filter_region output differs from expected value");
+}

Added: jed-extra/trunk/tests/listing-test.sl
===================================================================
--- jed-extra/trunk/tests/listing-test.sl	                        (rev 0)
+++ jed-extra/trunk/tests/listing-test.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -0,0 +1,357 @@
+% test-listing-list.sl:  Test listing-list.sl Test listing.sl
+%
+% Copyright (c) 2006 Günter Milde
+% Released under the terms of the GNU General Public License (ver. 2 or later)
+%
+% Versions:
+% 0.1 2006-03-03
+
+require("unittest");
+autoload("get_buffer", "txtutils");
+
+% test availability of public functions (comment to skip)
+% test_true(is_defined("listing_mode"), "public fun listing_mode undefined");
+
+require("listing");
+
+% private namespace: `listing'
+
+% fixture
+static define setup()
+{
+   sw2buf("*bar*");
+   insert("three\ntest\nlines");
+}
+
+static define teardown()
+{
+   sw2buf("*bar*");
+   set_buffer_modified_flag(0);
+   close_buffer("*bar*");
+}
+
+private define clear_input()
+{
+   while (input_pending(0))
+     {
+        () = getkey();
+     }
+}
+
+
+% static define null_fun() { }
+% null_fun: just return the arguments
+static define test_null_fun()
+{
+   variable result, result2;
+   listing->null_fun();
+   test_stack();
+   result = listing->null_fun(1);
+   test_equal(result, 1);
+   (result, result2) = listing->null_fun(1, "2");
+   test_equal({result, result2}, {1, "2"});
+   test_stack();
+}
+
+% static define get_confirmation() % (prompt, [default])
+%       y: yes,
+%       n: no,
+%       !: all,
+%       q:quit,
+% Int  listing->get_confirmation(Str prompt, Str default=""); Ask whether a list of actions should go on
+static define test_get_confirmation_yes()
+{
+   listing->Dont_Ask = 0;
+   clear_input();
+   ungetkey('y');
+   test_equal(1, listing->get_confirmation("Prompt"),
+      "key 'y' should result in 1");
+   test_equal(listing->Dont_Ask, 0, "key 'y' should not change Dont_Ask");
+   clear_input();
+}
+
+static define test_get_confirmation_no()
+{
+   listing->Dont_Ask = 0;
+   clear_input();
+   ungetkey('n');
+   test_equal(0, listing->get_confirmation("Prompt"),
+      "key 'n' should result in 0");
+   test_equal(listing->Dont_Ask, 0, "key 'n' should not change Dont_Ask");
+   clear_input();
+}
+   
+static define test_get_confirmation_with_default()
+{
+   listing->Dont_Ask = 0;
+   clear_input();
+   ungetkey('\r');
+   test_equal(1, listing->get_confirmation("Prompt", "y"),
+      "key Return should use default ('y')");
+   ungetkey('\r');
+   test_equal(0, listing->get_confirmation("Prompt", "n"),
+      "key Return should use default ('n')");
+   test_equal(listing->Dont_Ask, 0, "key Return should not change Dont_Ask");
+   
+   ungetkey('n');
+   test_equal(0, listing->get_confirmation("Prompt", "y"),
+      "key 'n' should override default 'y'");
+   ungetkey('y');
+   test_equal(1, listing->get_confirmation("Prompt", "n"),
+      "key 'y' should override default 'n'");
+   clear_input();
+}
+
+static define test_get_confirmation_all()
+{
+   listing->Dont_Ask = 0;
+   clear_input();
+   ungetkey('!');
+   test_equal(1, listing->get_confirmation("Prompt"),
+      "key '!' should result in 1");
+   ungetkey('n');
+   test_equal(1, listing->get_confirmation("Prompt"),
+      "Dont_Ask 1 should ignore key (not wait for it)");
+   test_equal('n', getkey(), "Dont_Ask 1 should ignore key");
+   clear_input();
+}
+
+static define test_get_confirmation_abort()
+{
+   variable err;
+   listing->Dont_Ask = 0;
+   clear_input();
+   ungetkey('q');
+   !if (input_pending(0))
+     throw ApplicationError, "there should be a 'q' waiting at input";
+   err = test_for_exception("listing->get_confirmation", "Prompt");
+   if (err == NULL)
+     throw AssertionError, "key 'q' should abort get_confirmation()";
+   if (err.error != UserBreakError)
+     throw AssertionError, 
+     "key 'q' should throw UserBreakError not " + err.descr;
+   clear_input();
+}
+
+static define test_get_confirmation_wrong_key()
+{
+   variable err;
+   listing->Dont_Ask = 0;
+   clear_input();
+   buffer_keystring("eeeee"); % five nonaccepted keys
+   !if (input_pending(0))
+     throw ApplicationError, "there should be waiting input";
+   err = test_for_exception("listing->get_confirmation", "Prompt");
+   if (err == NULL)
+     throw AssertionError, "three wrong keys should abort get_confirmation()";
+   if (err.error != UserBreakError)
+     throw AssertionError, 
+     "three wrong keys should throw UserBreakError not " + err.descr;
+   clear_input();
+}
+
+% public define listing_mode()
+% listing_mode: library function  Undocumented
+static define test_listing_mode()
+{
+   listing_mode();
+   test_equal(pop2list(what_mode(),2 ), {"listing", 0});
+   test_equal(what_keymap, "listing");
+}
+
+% static define tags_length() % (scope=2)
+% Int tags_length(scope=2); Return the number of tagged lines.
+static define test_tags_length()
+{
+   listing_mode();
+   test_equal(0, listing->tags_length(), "no tagged line");
+}
+
+static define test_tags_length_0()
+{
+   listing_mode();
+   test_equal(1, listing->tags_length(0), "one current line");
+}
+   
+static define test_tags_length_1()
+{
+   listing_mode();
+   test_equal(1, listing->tags_length(1), "one current line");
+}
+
+static define test_tags_length_2()
+{   
+   listing_mode();
+   test_equal(0, listing->tags_length(2), "no tagged line");
+}
+
+% static define line_is_tagged()
+% line_is_tagged: Return 0 or (index of tagged line +1)
+static define test_line_is_tagged()
+{
+   listing_mode();
+   test_equal(0, listing->line_is_tagged());
+}
+
+% static define tag() % (how = 1)
+% tag(how = 1); Mark the current line and append to the Tags list
+static define test_tag()
+{
+   listing_mode();
+   listing->tag();
+   test_stack();
+   % now there should be 1 tagged line
+   test_equal(1, listing->line_is_tagged(), "current line is tagged");
+   test_equal(1, listing->tags_length, "one tagged line");
+   % tag a second line
+   bob();
+   listing->tag();
+   test_equal(2, listing->tags_length(), "2 tagged lines");
+   test_equal(2, listing->line_is_tagged(), "current line should be second tag");
+   % untag current line
+   listing->tag(0);
+   test_stack();
+   test_equal(0, listing->line_is_tagged(), "current line not tagged");
+   test_equal(1, listing->tags_length, "one tagged line");
+   % toggle current line tag
+   listing->tag(2);
+   test_equal(2, listing->tags_length(), "2 tagged lines");
+}
+
+
+% static define tag_all() % (how = 1)
+% tag_all(how = 1); (Un)Tag all lines
+static define test_tag_all()
+{
+   listing_mode();
+   bob();
+   listing->tag_all();
+   test_stack();
+   test_equal(3, listing->tags_length(), "3 tagged lines");
+   test_true(bobp(), "tag_all() should not move the point");
+   % untag current line
+   listing->tag(0);
+   test_equal(0, listing->line_is_tagged(), "current line not tagged");
+   test_equal(2, listing->tags_length, "should be 2 tagged lines");
+   % toggle
+   listing->tag_all(2);
+   test_equal(1, listing->line_is_tagged(), "current line should be tagged");
+   test_equal(1, listing->tags_length, "should be 1 tagged line");
+   % untag
+   listing->tag_all(0);
+   test_equal(0, listing->tags_length(2), "no tagged line");
+}
+
+
+% static define tag_matching() %(how)
+% tag_matching: undefined  Undocumented
+static define test_tag_matching()
+{
+   clear_input();
+   listing_mode();
+   buffer_keystring("th\r"); % simulate keyboard input
+   listing->tag_matching();
+   test_equal(1, listing->tags_length, "should be 1 tagged line");
+   
+   clear_input();
+   buffer_keystring("t\r");
+   listing->tag_matching();
+   test_equal(2, listing->tags_length, "should be 2 tagged lines");
+   clear_input();
+}
+
+
+% public  define listing_list_tags() % (scope=2, untag=0)
+% scope: 0 current line, 1 tagged or current line(s), 2 tagged lines
+
+% Arr[Str] listing_list_tags(scope=2, untag=0); Return an array of tagged lines.
+static define test_listing_list_tags()
+{
+   listing_mode();
+   listing->tag_all();
+   !if (is_equal(["three", "test", "lines"], listing_list_tags()))
+     throw AssertionError,
+     "listing_list_tags() should return the tagged lines as String array";
+   !if (3 == listing->tags_length)
+     throw AssertionError, "there should be 3 tagged lines";
+}
+static define test_listing_list_tags_0()
+{
+   listing_mode();
+   listing->tag_all();
+   !if (is_equal(["lines"], listing_list_tags(0)))
+     throw AssertionError,
+     "listing_list_tags(0) should return the current line as String array";
+   !if (3 == listing->tags_length)
+     throw AssertionError, "there should be 3 tagged lines";
+}
+static define test_listing_list_tags_1_non_tagged()
+{
+   listing_mode();
+   !if (is_equal(["lines"], listing_list_tags(1)))
+     throw AssertionError,
+     "listing_list_tags(1) should return the tagged lines as String array";
+   !if (0 == listing->tags_length)
+     throw AssertionError, "there should be no tagged line";
+}
+static define test_listing_list_tags_1_tagged()
+{
+   listing_mode();
+   listing->tag_all();
+   !if (is_equal(["three", "test", "lines"], listing_list_tags(1)))
+     throw AssertionError,
+     "listing_list_tags(1) should return the tagged lines as String array";
+   !if (3 == listing->tags_length)
+     throw AssertionError, "there should be 3 tagged lines";
+}
+static define test_listing_list_tags_2_1()
+{
+   listing_mode();
+   listing->tag_all();
+   !if (is_equal(["three", "test", "lines"], listing_list_tags(2, 1)))
+     throw AssertionError,
+     "listing_list_tags should return the tagged lines as String array";
+   !if (0 == listing->tags_length)
+     throw AssertionError, "all lines should be untagged";
+}
+static define test_listing_list_tags_2_2()
+{
+   listing_mode();
+   listing->tag_all();
+   !if (is_equal(["three", "test", "lines"], listing_list_tags(2, 2)))
+     throw AssertionError,
+     "listing_list_tags should return the tagged lines as String array";
+   !if (bobp and eobp)
+     {
+        testmessage("buffer content: '%s'", get_buffer());
+        throw AssertionError, "all lines should be deleted";
+     }
+}
+
+
+% public  define listing_map() % (scope, fun, [args])
+% listing_map(Int scope, Ref fun, Any [args]); Call a function for marked lines.
+%
+% this is implicitely tested by listing_list_tags()
+
+% static define listing_update_hook()
+% listing_update_hook: undefined  Undocumented
+%
+% this is interactively tested
+
+
+% static define listing_menu (menu)
+% listing_menu: undefined  Undocumented
+% static define test_listing_menu()
+% {
+%    listing_mode();
+%    menu_select_menu("Global.M&ode.Tag &All");
+%    !if (3 == listing->tags_length)
+%      throw AssertionError, "there should be 3 tagged lines";
+% }
+
+
+% static define edit()
+% edit: undefined  Undocumented
+% test_function("listing->edit");
+% test_last_result();

Deleted: jed-extra/trunk/tests/test-ch_table.sl
===================================================================
--- jed-extra/trunk/tests/test-ch_table.sl	2006-10-06 09:52:51 UTC (rev 445)
+++ jed-extra/trunk/tests/test-ch_table.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -1,134 +0,0 @@
-% test-ch_table.sl: 
-% 
-% Copyright (c) 2006 Günter Milde
-% Released under the terms of the GNU General Public License (ver. 2 or later)
-%
-% Versions:
-% 0.1 2006-03-03 
-
-% Test ch_table.sl
-
-% private namespace: `ch_table'
-
-% set fixture:
-% 
-require("unittest");
-private variable results;    % list with return value(s)
-sw2buf("*scratch*");
-
-
-% ch_table: library function  Undocumented
-%  public define ch_table () % ch_table(StartChar = 0)
-results = test_function("ch_table");
-test_equal(whatbuf(), "*ch_table*");
-
-% special_chars: library function  Undocumented
-%  public define special_chars ()
-results = test_function("special_chars");
-
-% ct_load_popup_hook: library function  Undocumented
-%  define ct_load_popup_hook (menubar)
-% results = test_function("ct_load_popup_hook");
-
-% int2string: undefined  Undocumented
-%  static define int2string(i, base)
-results = test_function("ch_table->int2string", 32, 10);
-test_return_value(results, {"32"});
-results = test_function("ch_table->int2string", 32, 16);
-test_return_value(results, {"20"});
-results = test_function("ch_table->int2string", 32, 8);
-test_return_value(results, {"40"});
-results = test_function("ch_table->int2string", 32, 2);
-test_return_value(results, {"100000"});
-
-% string2int: undefined  Undocumented
-%  static define string2int(s, base)
-results = test_function("ch_table->string2int", "32", 10);
-test_return_value(results, {32});
-results = test_function("ch_table->string2int", "20", 16);
-test_return_value(results, {32});
-results = test_function("ch_table->string2int", "40", 8);
-test_return_value(results, {32});
-results = test_function("ch_table->string2int", "100000", 2);
-test_return_value(results, {32});
-
-% ct_status_line: undefined  Undocumented
-%  static define ct_status_line()
-% results = test_function("ch_table->ct_status_line");
-
-% ct_update: undefined  Undocumented
-%  static define ct_update ()
-% results = test_function("ch_table->ct_update");
-
-% ct_up: undefined  Undocumented
-%  static define ct_up ()
-% results = test_function("ch_table->ct_up");
-
-% ct_down: undefined  Undocumented
-%  static define ct_down ()
-results = test_function("ch_table->ct_down");
-
-% ct_right: undefined  Undocumented
-%  static define ct_right ()
-% results = test_function("ch_table->ct_right");
-
-% ct_left: undefined  Undocumented
-%  static define ct_left ()
-% results = test_function("ch_table->ct_left");
-
-% ct_bol: undefined  Undocumented
-%  static define ct_bol ()   { bol; ct_right;}
-% results = test_function("ch_table->ct_bol");
-
-% ct_eol: undefined  Undocumented
-%  static define ct_eol ()   { eol; ct_update;}
-% results = test_function("ch_table->ct_eol");
-
-% ct_bob: undefined  Undocumented
-%  static define ct_bob ()   { goto_line(3); ct_right;}
-% results = test_function("ch_table->ct_bob");
-
-% ct_eob: undefined  Undocumented
-%  static define ct_eob ()   { eob; ct_update;}
-% results = test_function("ch_table->ct_eob");
-
-% ct_mouse_up_hook: undefined  Undocumented
-%  static define ct_mouse_up_hook (line, col, but, shift)
-% results = test_function("ch_table->ct_mouse_up_hook");
-
-% ct_mouse_2click_hook: undefined  Undocumented
-%  static define ct_mouse_2click_hook (line, col, but, shift)
-% results = test_function("ch_table->ct_mouse_2click_hook");
-
-% ct_goto_char: undefined  Undocumented
-%  static define ct_goto_char ()
-% results = test_function("ch_table->ct_goto_char");
-
-% insert_ch_table: undefined  Undocumented
-%  static define insert_ch_table ()
-% results = test_function("ch_table->insert_ch_table");
-
-% use_base: undefined  Undocumented
-%  static define use_base (numbase)
-% results = test_function("ch_table->use_base");
-
-% ct_change_base: undefined  Undocumented
-%  static define ct_change_base ()
-% results = test_function("ch_table->ct_change_base");
-
-% setup_dfa_callback: undefined  Undocumented
-%  static define setup_dfa_callback (mode)
-% results = test_function("ch_table->setup_dfa_callback");
-
-% ct_insert_and_close: undefined  Undocumented
-%  static define ct_insert_and_close ()
-results = test_function("ch_table->ct_insert_and_close");
-push_mark();
-go_left_1();
-test_equal(bufsubstr_delete(), "ª");
-  
-
-update(1);
-
-sw2buf("*test report*");
-

Deleted: jed-extra/trunk/tests/test-csvutils.sl
===================================================================
--- jed-extra/trunk/tests/test-csvutils.sl	2006-10-06 09:52:51 UTC (rev 445)
+++ jed-extra/trunk/tests/test-csvutils.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -1,120 +0,0 @@
-% test-csvutils.sl:  Test csvutils.sl
-% 
-% Copyright (c) 2006 Günter Milde
-% Released under the terms of the GNU General Public License (ver. 2 or later)
-%
-% Versions:
-% 0.1 2006-03-03   basic test, check public functions
-
-
-require("unittest");
-
-variable results;    % list of return value(s)
-
-% fixture
-sw2buf("*scratch*");
-private variable teststring = "first line \n  second   line";
-private variable teststring_compressed = strcompress(teststring, " \n");
-erase_buffer();
-insert(teststring);
-
-
-% define get_lines() % (kill=0)
-% get_lines: library function  Undocumented
-results = test_function("get_lines");
-test_equal(typeof(results[0]), Array_Type);
-test_equal(_typeof(results[0]), String_Type);
-test_equal(length(results[0]), 2);
-test_equal(strjoin(results[0], "\n"), teststring);
-
-% public define buffer_compress(white)
-% buffer_compress(white); Remove excess whitespace characters from the buffer
-results = test_function("buffer_compress", " \n\t");
-test_return_value(results, {});
-test_equal(strjoin(get_lines(), " "), teststring_compressed);
-
-% public define spaces2tab()
-% spaces2tab(); "Normalize" whitespace delimited data
-results = test_function("spaces2tab");
-test_return_value(results, {});
-test_equal(strjoin(get_lines(), "\t"), str_replace_all(teststring_compressed, " ", "\t"));
-
-% define strchop2d() % (str, col_sep='\t', line_sep='\n', quote=0)
-% ; Chop a string into a 2d-array (lines and columns)
-results = test_function("strchop2d", get_buffer());
-test_equal(string(results[0]), "String_Type[2,2]");
-test_equal(strjoin(results[0], " "), teststring_compressed);
-
-% define get_table() % (col_sep="", kill=0)
-% Str get_table(col_sep="", kill=0); Return a 2d-string-array with csv data in the region/buffer
-erase_buffer();
-insert(teststring);
-results = test_function("get_table");
-test_equal(strjoin(results[0], " "), teststring_compressed);
-results = test_function("get_table", "l");
-private variable testtable = results[0];
-
-% define strjoin2d() %(a, col_sep="\t", line_sep="\n", align=NULL)
-% Str strjoin2d(Arr a, col_sep="\t", line_sep="\n", align=NULL); Print 2d-array as a nicely formatted table to a string
-results = test_function("strjoin2d", testtable, "l");
-test_return_value(results, {teststring});
-
-% define insert_table() %(a, align="l", col_sep=" ")
-% insert_table(Arr a, col_sep=" ", align="l"); Print 2d-array as a nicely formatted table
-erase_buffer();
-results = test_function("insert_table", testtable, "n", " l");
-test_return_value(results, {});
-test_equal(str_replace_all(get_buffer(), "\n", " "), teststring_compressed + " ");
-
-
-% public define format_table() % (col_sep=" \t", align="l", new_sep=" ")
-% format_table(col_sep="", align="l", new_sep=col_sep); Adjust a table to evenly spaced columns
-results = test_function("format_table", "", "l", " | ");
-test_return_value(results, {});
-% test alignment
-bob();
-test_true(fsearch("|"), "new col_sep not found (format_table)");
-$1 = what_column();
-test_true(fsearch("|"));
-test_equal($1, what_column());  
-
-% define max_column()
-% max_column: library function  Undocumented
-erase_buffer();
-insert(teststring);
-results = test_function("max_column");
-test_return_value(results, {16});
-
-% public define goto_max_column()
-% goto_max_column(); Goto the maximal column of the buffer (or region)
-bob();
-results = test_function("goto_max_column");
-test_return_value(results, {});
-test_equal(what_column(), 16);
-
-% Buggy, not needed anywhere, so commented out
-% % public define format_table_rect()
-% % format_table_rect([[[col_sep], align], new_sep]); Format the contents of the rectangle as table
-% bob();
-% skip_word();
-% push_visible_mark();
-% eob();
-% insert(" folly ");
-% results = test_function("format_table_rect", " \t", "r", " | ");
-% test_return_value(results, {});
-
-% define compute_columns() % (a, width=SCREEN_WIDTH, col_sep_length=1)
-% compute_columns: library function  Undocumented
-private variable funlist = _apropos("Global", "str", 1);
-results = test_function("compute_columns", funlist, 80, 1);
-test_return_value(results, {3});
-
-% define list2table() % (a, cols=compute_columns(a))
-% list2table: library function  Undocumented
-results = test_function("list2table", funlist, 3);
-test_equal(typeof(results[0]), Array_Type);
-test_equal(_typeof(results[0]), String_Type);
-% erase_buffer();
-% insert(strjoin2d(results[0], " ", "\n", "l"));
-
-erase_buffer();

Deleted: jed-extra/trunk/tests/test-cuamark.sl
===================================================================
--- jed-extra/trunk/tests/test-cuamark.sl	2006-10-06 09:52:51 UTC (rev 445)
+++ jed-extra/trunk/tests/test-cuamark.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -1,80 +0,0 @@
-% test-cuamark.sl:  Test cuamark.sl
-% 
-% Copyright (c) 2006 Günter Milde
-% Released under the terms of the GNU General Public License (ver. 2 or later)
-%
-% Versions:
-% 0.1 2006-03-03 
-
-require("unittest");
-
-% fixture
-private variable results;    % list of return value(s)
-private variable teststring = "a test line";
-sw2buf("*scratch*");
-erase_buffer();
-insert(teststring);
-
-
-% define cua_mark()
-% cua_mark(); Mark a cua-region (usually, with Shift-Arrow keys)
-bob();
-results = test_function("cua_mark");
-test_return_value(results, {});
-eol();  % this should not cancel the mark (see Cua_Unmarking_Functions)
-test_true(is_visible_mark(), "cua_mark(): there should be a visible mark");
-test_equal(bufsubstr(), teststring);
-
-% TODO: This test doesnot work, as the unmarking is done in a keypress hook
-%       (we would need to simulate a keypress, how?)
-% bob();
-% results = test_function("cua_mark");
-% test_return_value(results, {});
-% call("eol_cmd");  % this should cancel the mark (see Cua_Unmarking_Functions)
-% test_true(not is_visible_mark(), "cua_mark(): there should be no visible mark "+
-%                                  "after (no-shifted) movement");
-
-% define cua_kill_region ()
-% cua_kill_region(); Kill region (and copy to yp-yankbuffer and X selection)
-bob();
-push_mark_eol();
-results = test_function("cua_kill_region");
-test_return_value(results, {});
-% the buffer should now be empty
-test_true(bobp() and eobp(), "After killing the buffer, it should be empty");
-% inserting the yp-yankbuffer should restore the content
-yp_yank();
-mark_buffer();
-test_equal(bufsubstr(), teststring);
-
-% define cua_copy_region()
-% cua_copy_region(); Copy region to yp-yankbuffer [and X selection])
-bob();
-push_mark_eol();
-results = test_function("cua_copy_region");
-test_return_value(results, {});
-% the buffer content should be untouched
-mark_buffer();
-test_equal(bufsubstr(), teststring);
-% the yp_yankbuffer should have a copy
-erase_buffer();
-yp_yank();
-mark_buffer();
-test_equal(bufsubstr(), teststring);
-
-% define cua_insert_clipboard()
-% cua_insert_clipboard(); Insert X selection at point
-erase_buffer();
-test_true(bobp() and eobp(), "After erasing, the buffer should be empty");
-results = test_function("cua_insert_clipboard");
-test_return_value(results, {});
-if (is_defined("x_insert_selection") or is_defined("x_insert_cutbuffer"))
-{
-   % the buffer content should be restored if the X selection is available
-   mark_buffer();
-   test_equal(bufsubstr(), teststring);
-}
-
-   
-sw2buf("*test report*");
-view_mode();

Deleted: jed-extra/trunk/tests/test-cuamouse.sl
===================================================================
--- jed-extra/trunk/tests/test-cuamouse.sl	2006-10-06 09:52:51 UTC (rev 445)
+++ jed-extra/trunk/tests/test-cuamouse.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -1,97 +0,0 @@
-% test-cuamouse.sl:  Test cuamouse.sl
-% 
-% Copyright (c) 2006 Günter Milde
-% Released under the terms of the GNU General Public License (ver. 2 or later)
-%
-% Versions:
-% 0.1 2006-03-03 
-
-
-require("unittest");
-
-% fixture
-private variable results;    % list of return value(s)
-private variable teststring = "a test line";
-
-sw2buf("*scratch*");
-erase_buffer();
-while(markp())
-  pop_mark_0();
-
-% create a region from (2,2) to (4,6)
-insert("\n"+teststring+"\n\n"+teststring+"\n\n"+teststring+"\n");
-goto_line(2);
-goto_column(2);
-push_visible_mark();
-goto_line(4);
-goto_column(7);
-
-% define click_in_region(col,line)
-% Int = click_in_region(col, line); determine whether the mouse_click is in a region
-%
-% "before" region
-results = test_function("click_in_region", 1, 3);
-test_return_value(results, {-1});           
-results = test_function("click_in_region", 2, 1);
-test_return_value(results, {-1});           
-% "after" region                            
-results = test_function("click_in_region", 4, 7);
-test_return_value(results, {-2});           
-results = test_function("click_in_region", 4, 12);
-test_return_value(results, {-2});           
-results = test_function("click_in_region", 5, 1);
-test_return_value(results, {-2});           
-% in region but after eol                   
-results = test_function("click_in_region", 2, 13);
-test_return_value(results, {-3});           
-results = test_function("click_in_region", 3, 2);
-test_return_value(results, {-3});           
-% in region                                 
-results = test_function("click_in_region", 2, 2);
-test_return_value(results, {1});            
-results = test_function("click_in_region", 2, 9);
-test_return_value(results, {1});            
-results = test_function("click_in_region", 3, 1);
-test_return_value(results, {1});            
-results = test_function("click_in_region", 4, 6);
-test_return_value(results, {1});            
-% no region                                 
-pop_mark(0);                                
-results = test_function("click_in_region", 1, 1);
-test_return_value(results, {0});            
-results = test_function("click_in_region", 2, 5);
-test_return_value(results, {0});
-
-% public define copy_region_to_clipboard()
-% copy_region_to_clipboard(); Copy region to x-selection/cutbuffer and internal mouse clipboard
-bol();
-push_mark_eol();
-results = test_function("copy_region_to_clipboard");
-test_return_value(results, {});
-
-
-% define cuamouse_insert(from_jed)
-% cuamouse_insert: library function  Undocumented
-% 
-% from CuaMouseClipboard
-erase_buffer();
-results = test_function("cuamouse_insert", 1); 
-test_return_value(results, {});
-mark_buffer();
-test_equal(bufsubstr(), teststring);
-% from x selection
-if (is_defined("x_insert_selection") or is_defined("x_insert_cutbuffer"))
-{
-   erase_buffer();
-   results = test_function("cuamouse_insert", 0);
-   test_return_value(results, {});
-   % the buffer content should be restored if the X selection is available
-   mark_buffer();
-   test_equal(bufsubstr(), teststring);
-}
-
-% Remaining functions need interactive testing
-
-
-sw2buf("*test report*");
-view_mode();

Deleted: jed-extra/trunk/tests/test-ishell.sl
===================================================================
--- jed-extra/trunk/tests/test-ishell.sl	2006-10-06 09:52:51 UTC (rev 445)
+++ jed-extra/trunk/tests/test-ishell.sl	2006-10-06 10:02:33 UTC (rev 446)
@@ -1,76 +0,0 @@
-% Test ishell.sl
-
-% currently, this only tests function calls for errors but does only a partial
-% test of advertised functionality
-
-
-% ishell.sl: Interactive shell mode (based on ashell.sl by J. E. Davis)
-
-% custom_variable("Ishell_default_output_placement", ">");
-% custom_variable("Ishell_logout_string", ""); % default is Ctrl-D
-% custom_variable("Ishell_Max_Popup_Size", 10);
-% custom_variable("Shell_Default_Shell", getenv ("COMSPEC"));
-% custom_variable("Ishell_Default_Shell", Shell_Default_Shell);
-% custom_variable("Shell_Default_Shell", getenv ("SHELL"));
-% custom_variable("Ishell_Default_Shell", Shell_Default_Shell+" -i");
-
-
-require("unittest");
-
-variable results; % list of return values of function tests
-
-% ishell_mode(cmd=Ishell_Default_Shell); Open a process and attach it to the current buffer.
-% test_function("ishell_mode"); % used in ishell() (see below)
-
-% ishell(); Interactive shell
-results = test_function("ishell");
-
-if (whatbuf() != "*ishell*")
-  throw AssertionError, "  not in *ishell* buffer";
-
-% test the attached shell
-% 
-% to test the proper working, we would need a way to synchronize the
-% assynchron working (i.e. wait for a response from the command.)
-% 
-% Maybe input_pending() can be (ab)used in conjunction with an output handler
-% pushing a string back on the input-stream (ungetkey()). (Maybe a special
-% blocal "Ishell_output_filter"?)
-
-usleep(2000);  % wait for the startup
-insert("pwd");
-results = test_function("ishell_send_input");
-usleep(1000);  % wait for the result
-% logout
-results = test_function("ishell_logout");
-usleep(1000);  % wait for the result
-% close
-set_buffer_modified_flag(0);
-delbuf("*ishell*");
-
-
-% terminal(cmd = Ishell_Default_Shell); Run a command in a terminal
-results = test_function("terminal", "logout");
-
-% shell_command(cmd="", output_handling=0); Run a shell command
-results = test_function("shell_command", "echo 'hello world'", 3);
-test_return_value(results, {"hello world\n"});
-
-% shell_cmd_on_region_or_buffer: library function  Undocumented
-sw2buf("*scratch*");
-erase_buffer();
-push_visible_mark();
-insert("123 456 789");
-results = test_function("shell_cmd_on_region_or_buffer", "cat", 3);
-test_return_value(results, {"123 456 789\n"});
-  
-% shell_cmd_on_region(cmd="", output_handling=0, postfile_args=""); Save region to a temp file and run a command on it
-results = test_function("shell_cmd_on_region", "cat", 3);
-test_return_value(results, {"123 456 789\n"});
-
-% filter_region(cmd=NULL); Filter the region through a shell command
-results = test_function("filter_region", "wc");
-bob();
-!if (looking_at(" 1  3 12"))
-  testmessage("filter_region output differs from expected value");
-erase_buffer();




More information about the Pkg-jed-commit mailing list