File: lsortcmd.test

package info (click to toggle)
jimtcl 0.81%2Bdfsg0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 15,416 kB
  • sloc: ansic: 175,569; tcl: 5,456; sh: 4,814; cpp: 1,671; makefile: 269
file content (32 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
source [file dirname [info script]]/testing.tcl

set list {b d a c z}

proc sorter {a v1 v2} {
	set ::arg $a
	return [string compare $v1 $v2]
}

proc test_lsort_cmd {test cmd list exp} {
	lsort -command $cmd $list
	if {$::arg != $exp} {
		error "$test: Failed"
	}
}

test lsortcmd-1.1 "Sort with one arg" {
	lsort -command "sorter arg1" $list
	set arg
} {arg1}

test lsortcmd-1.2 "Sort with one arg containg spaces" {
	lsort -command {sorter "arg with space"} $list
	set arg
} {arg with space}

test lsortcmd-1.3 "Sort with arg as list containg spaces" {
	lsort -command [list sorter [list arg with list "last with spaces"]] $list
	set arg
} {arg with list {last with spaces}}

testreport