Browse Source
TIP 746 (Tcl 9.1) removed lseq's expr-operand behaviour. punk::lib::range (lseq branch) now normalizes int[+-]int offsets via offset_expr so callers like `range 0 [llength $list]-1` keep working (punk::ansi::grepstr broke under 9.1b0, taking example-block highlighting and the punk::args examples.test with it). The lseq branch is also aligned with the tcl8 fallback contract: default 'by' now infers direction (descending ranges previously returned empty under tcl9) and 'by 0' returns empty (Tcl 9.1 lseq changed by-0 to return one element). Direct lseq expression operands expr-wrapped: punk::lib lzipn_tcl9b/c, cols, cols2; punk::args zero_based_posns. check::has_tclbug_safeinterp_compile falls back to interp invokehidden tcl:unsupported:disassemble - Tcl 9.1 safe interps hide tcl::unsupported::*. New modules/punk/lib range.test pins the range contract on 9.0 and 9.1; core tests AGENTS.md documents native-tclsh vs punk-exe exec.test baselines. Assisted-by: harness=claude; primary-model=claude-fable-5; api-location=anthropic.commaster
8 changed files with 99 additions and 12 deletions
@ -1,3 +1,3 @@
|
||||
[project] |
||||
name = "punkshell" |
||||
version = "0.4.11" |
||||
version = "0.4.12" |
||||
|
||||
@ -0,0 +1,60 @@
|
||||
package require tcltest |
||||
package require punk::lib |
||||
|
||||
namespace eval ::testspace { |
||||
namespace import ::tcltest::* |
||||
variable common { |
||||
set result "" |
||||
} |
||||
|
||||
test range_basic {ascending and descending integer ranges (direction inferred when by not given)}\ |
||||
-setup $common -body { |
||||
lappend result [punk::lib::range 1 5] |
||||
lappend result [punk::lib::range 5 1] |
||||
}\ |
||||
-cleanup { |
||||
}\ |
||||
-result [list\ |
||||
{1 2 3 4 5}\ |
||||
{5 4 3 2 1} |
||||
] |
||||
|
||||
test range_by_step {explicit by step}\ |
||||
-setup $common -body { |
||||
lappend result [punk::lib::range 1 7 2] |
||||
}\ |
||||
-cleanup { |
||||
}\ |
||||
-result [list\ |
||||
{1 3 5 7} |
||||
] |
||||
|
||||
test range_offset_expr_operands {int[+-]int offset expressions accepted in all operands (lseq in Tcl 9.1+ TIP 746 no longer evaluates these itself)}\ |
||||
-setup $common -body { |
||||
#common calling pattern e.g punk::ansi::grepstr: range 0 [llength $list]-1 |
||||
set l {a b c d} |
||||
lappend result [punk::lib::range 0 [llength $l]-1] |
||||
lappend result [punk::lib::range 2-1 [llength $l]+1] |
||||
lappend result [punk::lib::range 0 8 1+1] |
||||
}\ |
||||
-cleanup { |
||||
}\ |
||||
-result [list\ |
||||
{0 1 2 3}\ |
||||
{1 2 3 4 5}\ |
||||
{0 2 4 6 8} |
||||
] |
||||
|
||||
test range_by_zero {step of zero produces empty list as per lseq}\ |
||||
-setup $common -body { |
||||
lappend result [llength [punk::lib::range 1 5 0]] |
||||
set result |
||||
}\ |
||||
-cleanup { |
||||
}\ |
||||
-result [list\ |
||||
0 |
||||
] |
||||
|
||||
} |
||||
tcltest::cleanupTests ;#needed to produce test summary. |
||||
Loading…
Reference in new issue