Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -N -r1.189.2.105 -r1.189.2.106 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 29 Nov 2021 14:33:47 -0000 1.189.2.105 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 29 Nov 2021 16:56:03 -0000 1.189.2.106 @@ -3453,7 +3453,7 @@ set sv [expr {$d_end + 1}] } elseif {[regexp {^a(\d+)$} $diff full m1]} { set d_end $m1 - for {set i $sv} {$i < $m1} {incr i} { + for {set i $sv} {$i <= $m1} {incr i} { append res "${split_by}[lindex $old_w $i]" } while {1} { Index: openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/test/Attic/utilities-procs.tcl,v diff -u -N -r1.1.2.8 -r1.1.2.9 --- openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 24 Jun 2021 11:31:50 -0000 1.1.2.8 +++ openacs-4/packages/acs-tcl/tcl/test/utilities-procs.tcl 29 Nov 2021 16:56:03 -0000 1.1.2.9 @@ -241,6 +241,54 @@ } } +aa_register_case -cats { + api + smoke + production_safe +} -procs { + util::word_diff +} word_diff { + Test the util::word_diff proc. +} { + # + # Equal length + # + set cases { + { + -name "add" + -old "hello world" + -new "hello2 world" + -result {hello2 world} + } + + { + -name "delete" + -old "hello2 world" + -new "hello world" + -result {hello2 world} + } + + { + -name "add begin end" + -old "ello" + -new "hello2" + -result {hello2} + } + + { + -name "delete begin end" + -old "hello2" + -new "ello" + -result {hello2} + } + } + foreach case $cases { + aa_equals "diff [dict get $case -name]" \ + [util::word_diff -old [dict get $case -old] -new [dict get $case -new]] \ + [dict get $case -result] + } +} + # Local variables: # mode: tcl # tcl-indent-level: 4