[Pkg-jed-commit] r358 - in jed-extra/trunk: . tests

Guenter Milde milde-guest at costa.debian.org
Thu Jul 20 10:07:35 UTC 2006


Author: milde-guest
Date: 2006-07-20 10:07:34 +0000 (Thu, 20 Jul 2006)
New Revision: 358

Added:
   jed-extra/trunk/tests/
   jed-extra/trunk/tests/files-jed-extra-drop-in.txt
   jed-extra/trunk/tests/files-jed-extra-utils.txt
   jed-extra/trunk/tests/files-jed-extra.txt
   jed-extra/trunk/tests/test-browse_url.sl
   jed-extra/trunk/tests/test-calc.sl
   jed-extra/trunk/tests/test-ch_table.sl
   jed-extra/trunk/tests/test-console_keys.sl
   jed-extra/trunk/tests/test-css1.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-dict-cli.sl
   jed-extra/trunk/tests/test-dict-curl.sl
   jed-extra/trunk/tests/test-ishell.sl
Log:
Start of a test suite for jed-extra. Uses jedmodes.sf.net/mode/unittest/
which for this purpose should become part of jed-extra


Added: jed-extra/trunk/tests/files-jed-extra-drop-in.txt
===================================================================
--- jed-extra/trunk/tests/files-jed-extra-drop-in.txt	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/files-jed-extra-drop-in.txt	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,16 @@
+../
+brief.sl
+cal.sl
+calmisc.sl
+diary.sl
+flyspell.sl
+help.hlp
+help.sl
+hyperman.sl
+ispell.sl
+ispell_common.sl
+ispell_init.sl
+look.sl
+ncal.sl
+recent.sl
+vispell.sl

Added: jed-extra/trunk/tests/files-jed-extra-utils.txt
===================================================================
--- jed-extra/trunk/tests/files-jed-extra-utils.txt	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/files-jed-extra-utils.txt	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,11 @@
+../
+bufutils.sl
+circle.sl
+datutils.sl
+listing.sl
+menutils.sl
+sl_utils.sl
+sprint_var.sl
+strutils.sl
+txtutils.sl
+window.sl

Added: jed-extra/trunk/tests/files-jed-extra.txt
===================================================================
--- jed-extra/trunk/tests/files-jed-extra.txt	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/files-jed-extra.txt	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,58 @@
+../
+boxquote.sl
+browse_url.sl
+calc.sl
+ch_table.sl
+colors/
+console_keys.map
+console_keys.sl
+css1.sl
+csvutils.sl
+cuamark.sl
+cuamouse.sl
+dict-cli.sl
+dict-curl.sl
+dictmode.sl
+drop-in/
+email.sl
+extra/
+filelist.sl
+filter-buffer.sl
+gdbmrecent.sl
+gnuplot.sl
+grep.sl
+ishell.sl
+jedasp.sl
+keyring
+keywords.sl
+libdir.sl
+life.sl
+mailcrypt.sl
+make.sl
+make_ini.sl
+manedit.sl
+md5.sl
+mtools.sl
+mupad.sl
+navigate.sl
+numbuf.sl
+po_mode.hlp
+po_mode.sl
+print.sl
+rst.sl
+snake.sl
+sql.sl
+structured_text.sl
+temabbrv.sl
+tkl-modes.sl
+tm.sed
+tm.sl
+tmtools.sl
+tokenlist.sl
+uri.sl
+utils/
+vi.hlp
+vi.sl
+view.sl
+vimisc.sl
+x-keydefs.sl

Added: jed-extra/trunk/tests/test-browse_url.sl
===================================================================
--- jed-extra/trunk/tests/test-browse_url.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-browse_url.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,43 @@
+% test-browse_url.sl: Test browse_url.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");
+
+variable results;    % list with return value(s)
+variable test_url = "http://jedmodes.sourceforge.net/mode/cua/index.php";
+
+% find_url(url=read_mini, cmd = Browse_Url_Download_Cmd); Find a file by URL
+%  public define find_url() %(url=read_mini, cmd = Browse_Url_Download_Cmd)
+results = test_function("find_url", test_url);
+test_return_value(results, {});
+test_equal(whatbuf(), test_url);
+delbuf(test_url);
+
+% view_url(Str url=read_mini, Str cmd= Browse_Url_Viewer); View an ASCII rendering of a URL
+%  public define view_url() %(url=read_mini, cmd= Browse_Url_Viewer)
+results = test_function("view_url", test_url);
+test_return_value(results, {});
+test_equal(whatbuf(), "*"+test_url+"*");
+delbuf("*"+test_url+"*");
+
+% public  define browse_url_x() %(url, cmd=Browse_Url_X_Browser)
+% browse_url_x(Str url=ask, Str cmd=Browse_Url_X_Browser); Open a URL in a browser
+testmessage("\n  browse_url_x() needs interactive testing,");
+testmessage("\n  (opens a document in an external browser with system())");
+% results = test_function("browse_url_x", test_url);
+% test_return_value(results, {});
+%   browse_url_x(): OK ()
+
+% public define browse_url() %(url=read_mini, cmd=Browse_Url_Browser)
+% browse_url() %(url=read_mini, cmd=Browse_Url_Browser); Open the url in a browser
+testmessage("\n  browse_url() needs interactive testing,");
+testmessage("\n  (opens a document in an external browser with system())");
+% (commented out to prevent side effects)
+% results = test_function("browse_url", test_url);
+% test_return_value(results, {});
+%  browse_url(http://jedmodes.sourceforge.net/mode/cua/index.php): OK ()

Added: jed-extra/trunk/tests/test-calc.sl
===================================================================
--- jed-extra/trunk/tests/test-calc.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-calc.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,161 @@
+% test-calc.sl: % Test calc.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 for errors with call of public functions
+
+
+require("unittest");
+
+variable results;    % list of return value(s)
+
+% private namespace: `calc'
+
+% Open the calc buffer
+
+
+% calc: library function  Undocumented
+%  public define calc ()
+results = test_function("calc");
+test_return_value(results, {});
+test_equal(whatbuf(), "Calculator");
+
+
+% calc2: library function  Undocumented
+%  public define calc2 ()
+results = test_function("calc2");
+test_return_value(results, {});
+
+% clean up and abort (TODO test remaining functions)
+sw2buf("Calculator");
+set_buffer_modified_flag(0);
+delbuf("Calculator");
+delbuf("*calcres*");
+#stop
+
+% calc_select_expression_buf: undefined  Undocumented
+%  static define calc_select_expression_buf ()
+results = test_function("calc->calc_select_expression_buf");
+test_return_value(results, {});
+
+% history_next: undefined  Undocumented
+%  static define history_next ()
+results = test_function("calc->history_next");
+test_return_value(results, {});
+
+% history_prev: undefined  Undocumented
+%  static define history_prev ()
+results = test_function("calc->history_prev");
+test_return_value(results, {});
+
+% calc_next_expression: undefined  Undocumented
+%  public define calc_next_expression ()
+results = test_function("calc_next_expression");
+test_return_value(results, {});
+
+% calc_format_binary: undefined  Undocumented
+%  static define calc_format_binary (val)
+results = test_function("calc->calc_format_binary");
+test_return_value(results, {});
+
+% calc_display_value: undefined  Undocumented
+%  static define calc_display_value(val, linepref);
+results = test_function("calc->calc_display_value");
+test_return_value(results, {});
+
+% calc_display_value: undefined  Undocumented
+%  static define calc_display_value(val, linepref)
+results = test_function("calc->calc_display_value");
+test_return_value(results, {});
+
+% calc_display_stack: undefined  Undocumented
+%  static define calc_display_stack ()
+results = test_function("calc->calc_display_stack");
+test_return_value(results, {});
+
+% calc_display_variables: undefined  Undocumented
+%  public define calc_display_variables ()
+results = test_function("calc_display_variables");
+test_return_value(results, {});
+
+% calc_result_window: undefined  Undocumented
+%  public define calc_result_window ()
+results = test_function("calc_result_window");
+test_return_value(results, {});
+
+% calc_make_calculation: undefined  Undocumented
+%  public define calc_make_calculation ()
+results = test_function("calc_make_calculation");
+test_return_value(results, {});
+
+% calc_find_max_id: undefined  Undocumented
+%  static define calc_find_max_id ()
+results = test_function("calc->calc_find_max_id");
+test_return_value(results, {});
+
+% calc_read_file: undefined  Undocumented
+%  public define calc_read_file ()
+results = test_function("calc_read_file");
+test_return_value(results, {});
+
+% calc_write_file: undefined  Undocumented
+%  public define calc_write_file ()
+results = test_function("calc_write_file");
+test_return_value(results, {});
+
+% calc_float_format: undefined  Undocumented
+%  public define calc_float_format ()
+results = test_function("calc_float_format");
+test_return_value(results, {});
+
+% calc_help: undefined  Undocumented
+%  public define calc_help ()
+results = test_function("calc_help");
+test_return_value(results, {});
+
+% calc_prepare_keymap: undefined  Undocumented
+%  static define calc_prepare_keymap ()
+results = test_function("calc->calc_prepare_keymap");
+test_return_value(results, {});
+
+% calc_reset_buffer: undefined  Undocumented
+%  public define calc_reset_buffer()
+results = test_function("calc_reset_buffer");
+test_return_value(results, {});
+
+% init_menu: undefined  Undocumented
+%  static define init_menu (menu)
+results = test_function("calc->init_menu");
+test_return_value(results, {});
+
+% calc_start: undefined  Undocumented
+%  static define calc_start ()
+results = test_function("calc->calc_start");
+test_return_value(results, {});
+
+% calc_mode_dec: undefined  Undocumented
+%  public define calc_mode_dec()
+results = test_function("calc_mode_dec");
+test_return_value(results, {});
+
+% calc_mode_hex: undefined  Undocumented
+%  public define calc_mode_hex()
+results = test_function("calc_mode_hex");
+test_return_value(results, {});
+
+% calc_mode_oct: undefined  Undocumented
+%  public define calc_mode_oct()
+results = test_function("calc_mode_oct");
+test_return_value(results, {});
+
+% calc_mode_bin: undefined  Undocumented
+%  public define calc_mode_bin()
+results = test_function("calc_mode_bin");
+test_return_value(results, {});
+
+% calc_mode_all: undefined  Undocumented
+%  public define calc_mode_all()
+results = test_function("calc_mode_all");
+test_return_value(results, {});

Added: jed-extra/trunk/tests/test-ch_table.sl
===================================================================
--- jed-extra/trunk/tests/test-ch_table.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-ch_table.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,134 @@
+% 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*");
+

Added: jed-extra/trunk/tests/test-console_keys.sl
===================================================================
--- jed-extra/trunk/tests/test-console_keys.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-console_keys.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,30 @@
+% test-console_keys.sl:  Test console_keys.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 just test evaluating the file
+
+
+require("unittest");
+
+variable results;    % list of return value(s)
+
+
+results = test_function("evalfile", "console_keys");
+test_return_value(results, {1});
+
+testmessage("\n  console_keys.sl needs interactive testing in a Linux console");
+#stop
+
+% define set_console_keys()
+% set_console_keys: undefined  Undocumented
+results = test_function("set_console_keys");
+test_return_value(results, {});
+
+% define restore_console_keys()
+% restore_console_keys: undefined  Undocumented
+results = test_function("restore_console_keys");
+test_return_value(results, {});
+

Added: jed-extra/trunk/tests/test-css1.sl
===================================================================
--- jed-extra/trunk/tests/test-css1.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-css1.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,28 @@
+% test-css1.sl:  Test css1.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");
+
+variable results;    % list of return value(s)
+sw2buf("*scratch*");
+
+
+% public define css1_mode() {
+% css1_mode: library function  Undocumented
+results = test_function("css1_mode");
+test_return_value(results, {});
+test_equal(get_mode_name(), "css1");
+
+no_mode();
+
+% test the automatic mode setting at loading a file
+results = test_function("find_file", "test.css"); % new file, empty buffer
+test_equal(get_mode_name(), "css1");
+if (bufferp("test.css"))
+  delbuf("test.css");

Added: jed-extra/trunk/tests/test-csvutils.sl
===================================================================
--- jed-extra/trunk/tests/test-csvutils.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-csvutils.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,120 @@
+% 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();

Added: jed-extra/trunk/tests/test-cuamark.sl
===================================================================
--- jed-extra/trunk/tests/test-cuamark.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-cuamark.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,80 @@
+% 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();

Added: jed-extra/trunk/tests/test-cuamouse.sl
===================================================================
--- jed-extra/trunk/tests/test-cuamouse.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-cuamouse.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,97 @@
+% 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();

Added: jed-extra/trunk/tests/test-dict-cli.sl
===================================================================
--- jed-extra/trunk/tests/test-dict-cli.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-dict-cli.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,52 @@
+% test-dict-cli.sl:  Test dict-cli.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 
+
+% This test requires an internet connection (to reach "dict.org") or a running
+% dictd on localhost (customize by (un)commenting the right host variable).
+% 
+% Is there a way to test the returned results?
+
+require("unittest");
+require("dict-cli");
+
+% fixture
+private variable results;    % list of return value(s)
+
+
+private variable word = "line";
+private variable host = "dict.org";    % public dict server
+% private variable host = "localhost"; % local dict server
+private variable database = "!";       % server default
+private variable strategy = ".";       % server default
+private variable what = "db";
+
+sw2buf("*scratch*");
+erase_buffer();
+while(markp())
+  pop_mark_0();
+
+% define dict_define(word, database, host)
+% dict_define: library function  Undocumented
+results = test_function("dict_define", word, database, host);
+test_return_value(results, {});
+erase_buffer();
+
+% define dict_match(word, strategy, database, host)
+% dict_match: library function  Undocumented
+results = test_function("dict_match", word, strategy, database, host);
+test_return_value(results, {});
+erase_buffer();
+
+% define dict_show(what, host)
+% dict_show: library function  Undocumented
+results = test_function("dict_show", what, host);
+test_return_value(results, {});
+erase_buffer();
+
+sw2buf("*test report*");
+view_mode();

Added: jed-extra/trunk/tests/test-dict-curl.sl
===================================================================
--- jed-extra/trunk/tests/test-dict-curl.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-dict-curl.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,58 @@
+% test-dict-curl.sl:  Test dict-curl.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 
+
+% This test requires the curl slang module as well as
+% an internet connection (to reach "dict.org") or a running
+% dictd on localhost (don't forget to customize the host variable).
+% 
+% Is there a way to test the inserted results?
+
+require("unittest");
+
+testmessage("at my site, dict-curl crashs ('Speicherzugriffsfehler') Jed" +
+   "Jed Version: 0.99.18, S-Lang Version: 2.0.6, slang-curl 0.1.1-5");
+
+throw AssertionError, "() = evalfile(\"dict-curl\"); crashs Jed";
+
+() = evalfile("dict-curl");
+
+% fixture
+private variable results;    % list of return value(s)
+
+private variable word = "line";
+private variable host = "dict.org";    % public dict server
+% private variable host = "localhost"; % local dict server
+private variable database = "!";       % server default
+private variable strategy = ".";       % server default
+private variable what = "db";
+
+sw2buf("*scratch*");
+erase_buffer();
+while(markp())
+  pop_mark_0();
+
+% define dict_define(word, database, host)
+% dict_define: library function  Undocumented
+results = test_function("dict_define", word, database, host);
+test_return_value(results, {});
+erase_buffer();
+
+% define dict_match(word, strategy, database, host)
+% dict_match: library function  Undocumented
+results = test_function("dict_match", word, strategy, database, host);
+test_return_value(results, {});
+erase_buffer();
+
+% define dict_show(what, host)
+% dict_show: library function  Undocumented
+results = test_function("dict_show", what, host);
+test_return_value(results, {});
+erase_buffer();
+
+sw2buf("*test report*");
+view_mode();

Added: jed-extra/trunk/tests/test-ishell.sl
===================================================================
--- jed-extra/trunk/tests/test-ishell.sl	2006-07-17 17:51:52 UTC (rev 357)
+++ jed-extra/trunk/tests/test-ishell.sl	2006-07-20 10:07:34 UTC (rev 358)
@@ -0,0 +1,76 @@
+% 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