From fb3057c4a82b8cead5f45c319b4256eb2f6c8dba Mon Sep 17 00:00:00 2001 From: aspect Date: Tue, 16 Jun 2015 00:41:39 +0000 Subject: fix for a4cb3f06c4fe - bug introduced in 32b61592465 --- generic/tclCompCmdsGR.c | 2 +- tests/lreplace.test | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index b77c43c..8d8f2cc 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -1501,7 +1501,7 @@ TclCompileLreplaceCmd( return TCL_ERROR; } - if(idx2 != INDEX_END && idx2 < idx1) { + if(idx2 != INDEX_END && idx2 >= 0 && idx2 < idx1) { idx2 = idx1-1; } diff --git a/tests/lreplace.test b/tests/lreplace.test index d1319c6..cf0ae51 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -146,6 +146,9 @@ test lreplace-4.4 {lreplace edge case} { test lreplace-4.5 {lreplace edge case} { lreplace {1 2 3 4 5} 3 0 _ } {1 2 3 _ 4 5} +test lreplace-4.6 {lreplace end-x: bug a4cb3f06c4} { + lreplace {0 1 2 3 4} 0 end-2 +} {3 4} # cleanup catch {unset foo} -- cgit v0.12 From ca0957c060554b00bfdf17701723a79588030542 Mon Sep 17 00:00:00 2001 From: aspect Date: Tue, 16 Jun 2015 03:33:22 +0000 Subject: lreplace: more tests, doc improvement --- doc/lreplace.n | 2 +- tests/lreplace.test | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/doc/lreplace.n b/doc/lreplace.n index 7bba543..d19f0cd 100644 --- a/doc/lreplace.n +++ b/doc/lreplace.n @@ -35,7 +35,7 @@ by \fIfirst\fR must exist or \fIfirst\fR must indicate before the start of the list. .PP If \fIlast\fR is less than \fIfirst\fR, then any specified elements -will be inserted into the list at the point specified by \fIfirst\fR +will be inserted into the list before the point specified by \fIfirst\fR with no elements being deleted. .PP The \fIelement\fR arguments specify zero or more new arguments to diff --git a/tests/lreplace.test b/tests/lreplace.test index cf0ae51..ea88c07 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -149,6 +149,39 @@ test lreplace-4.5 {lreplace edge case} { test lreplace-4.6 {lreplace end-x: bug a4cb3f06c4} { lreplace {0 1 2 3 4} 0 end-2 } {3 4} +test lreplace-4.6.1 {lreplace end-x: bug a4cb3f06c4} { + lreplace {0 1 2 3 4} 0 end-2 a b c +} {a b c 3 4} +test lreplace-4.7 {lreplace with two end-indexes: increasing} { + lreplace {0 1 2 3 4} end-2 end-1 +} {0 1 4} +test lreplace-4.7.1 {lreplace with two end-indexes: increasing} { + lreplace {0 1 2 3 4} end-2 end-1 a b c +} {0 1 a b c 4} +test lreplace-4.8 {lreplace with two end-indexes: equal} { + lreplace {0 1 2 3 4} end-2 end-2 +} {0 1 3 4} +test lreplace-4.8.1 {lreplace with two end-indexes: equal} { + lreplace {0 1 2 3 4} end-2 end-2 a b c +} {0 1 a b c 3 4} +test lreplace-4.9 {lreplace with two end-indexes: decreasing} { + lreplace {0 1 2 3 4} end-2 end-3 +} {0 1 2 3 4} +test lreplace-4.9.1 {lreplace with two end-indexes: decreasing} { + lreplace {0 1 2 3 4} end-2 end-3 a b c +} {0 1 a b c 2 3 4} +test lreplace-4.10 {lreplace with two equal indexes} { + lreplace {0 1 2 3 4} 2 2 +} {0 1 3 4} +test lreplace-4.10.1 {lreplace with two equal indexes} { + lreplace {0 1 2 3 4} 2 2 a b c +} {0 1 a b c 3 4} +test lreplace-4.11 {lreplace end index first} { + lreplace {0 1 2 3 4} end-2 1 a b c +} {0 1 a b c 2 3 4} +test lreplace-4.12 {lreplace end index first} { + lreplace {0 1 2 3 4} end-2 2 a b c +} {0 1 a b c 3 4} # cleanup catch {unset foo} -- cgit v0.12 From 3edfd7cd0b80d37eb9bb59c40970fea1baa27b8d Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 18 Jun 2015 17:26:59 +0000 Subject: From aspect, several edge case coverage tests. --- tests/lreplace.test | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/lreplace.test b/tests/lreplace.test index 55bad37..50610dc 100644 --- a/tests/lreplace.test +++ b/tests/lreplace.test @@ -130,6 +130,58 @@ test lreplace-3.1 {lreplace won't modify shared argument objects} { p } "a b c" +test lreplace-4.1 {Bug ccc2c2cc98: lreplace edge case} { + lreplace {} 1 1 +} {} +test lreplace-4.2 {Bug ccc2c2cc98: lreplace edge case} { + lreplace { } 1 1 +} {} +test lreplace-4.3 {lreplace edge case} { + lreplace {1 2 3} 2 0 +} {1 2 3} +test lreplace-4.4 {lreplace edge case} { + lreplace {1 2 3 4 5} 3 1 +} {1 2 3 4 5} +test lreplace-4.5 {lreplace edge case} { + lreplace {1 2 3 4 5} 3 0 _ +} {1 2 3 _ 4 5} +test lreplace-4.6 {lreplace end-x: bug a4cb3f06c4} { + lreplace {0 1 2 3 4} 0 end-2 +} {3 4} +test lreplace-4.6.1 {lreplace end-x: bug a4cb3f06c4} { + lreplace {0 1 2 3 4} 0 end-2 a b c +} {a b c 3 4} +test lreplace-4.7 {lreplace with two end-indexes: increasing} { + lreplace {0 1 2 3 4} end-2 end-1 +} {0 1 4} +test lreplace-4.7.1 {lreplace with two end-indexes: increasing} { + lreplace {0 1 2 3 4} end-2 end-1 a b c +} {0 1 a b c 4} +test lreplace-4.8 {lreplace with two end-indexes: equal} { + lreplace {0 1 2 3 4} end-2 end-2 +} {0 1 3 4} +test lreplace-4.8.1 {lreplace with two end-indexes: equal} { + lreplace {0 1 2 3 4} end-2 end-2 a b c +} {0 1 a b c 3 4} +test lreplace-4.9 {lreplace with two end-indexes: decreasing} { + lreplace {0 1 2 3 4} end-2 end-3 +} {0 1 2 3 4} +test lreplace-4.9.1 {lreplace with two end-indexes: decreasing} { + lreplace {0 1 2 3 4} end-2 end-3 a b c +} {0 1 a b c 2 3 4} +test lreplace-4.10 {lreplace with two equal indexes} { + lreplace {0 1 2 3 4} 2 2 +} {0 1 3 4} +test lreplace-4.10.1 {lreplace with two equal indexes} { + lreplace {0 1 2 3 4} 2 2 a b c +} {0 1 a b c 3 4} +test lreplace-4.11 {lreplace end index first} { + lreplace {0 1 2 3 4} end-2 1 a b c +} {0 1 a b c 2 3 4} +test lreplace-4.12 {lreplace end index first} { + lreplace {0 1 2 3 4} end-2 2 a b c +} {0 1 a b c 3 4} + # cleanup catch {unset foo} ::tcltest::cleanupTests -- cgit v0.12