jimregexp: rename local regex functions
[jimtcl.git] / tests / debug.test
blobedfead8977667a00f5a22fe51e8b9d5eac4b1707
1 source [file dirname [info script]]/testing.tcl
2 needs cmd debug
4 set x 0
6 test debug-0.1 {debug too few args} -body {
7     debug
8 } -returnCodes error -result {wrong # args: should be "debug subcommand ?...?"}
10 test debug-0.2 {debug bad option} -body {
11     debug badoption
12 } -returnCodes error -result {bad subcommand "badoption": must be exprbc, exprlen, invstr, objcount, objects, refcount, scriptlen, or show}
14 test debug-1.1 {debug refcount too few args} -body {
15     debug refcount
16 } -returnCodes error -result {wrong # args: should be "debug refcount object"}
18 test debug-1.2 {debug refcount test} -body {
19     debug refcount x
20 }  -result {2}
22 test debug-1.3 {debug refcount too many args} -body {
23     debug refcount a b c
24 } -returnCodes error -result {wrong # args: should be "debug refcount object"}
26 test debug-2.1 {debug objcount} -body {
27     regexp {free \d+ used \d+} [debug objcount]
28 } -result {1}
30 test debug-2.2 {debug objcount too many args} -body {
31     debug objcount a b c
32 } -returnCodes error -result {wrong # args: should be "debug objcount"}
34 test debug-3.1 {debug objects} -body {
35     expr [llength [debug objects]] > 1000
36 } -result {1}
38 # does not currently check for too many args
39 test debug-3.2 {debug objects too many args} -body {
40     debug objects a b c
41 } -returnCodes error -result {wrong # args: should be "debug objects"}
43 test debug-4.1 {debug invstr too few args} -body {
44     debug invstr
45 } -returnCodes error -result {wrong # args: should be "debug invstr object"}
47 test debug-4.2 {debug invstr} -body {
48     debug invstr x
49 } -result {}
51 test debug-4.3 {debug invstr too many args} -body {
52     debug invstr a b c
53 } -returnCodes error -result {wrong # args: should be "debug invstr object"}
55 test debug-5.1 {debug scriptlen too few args} -body {
56     debug scriptlen
57 } -returnCodes error -result {wrong # args: should be "debug scriptlen script"}
59 test debug-5.2 {debug scriptlen} -body {
60     debug scriptlen {puts "hello world"}
61 } -result {3}
63 test debug-5.3 {debug scriptlen too many args} -body {
64     debug scriptlen a b c
65 } -returnCodes error -result {wrong # args: should be "debug scriptlen script"}
67 test debug-6.1 {debug exprlen too few args} -body {
68     debug exprlen
69 } -returnCodes error -result {wrong # args: should be "debug exprlen expression"}
71 test debug-6.2 {debug exprlen} -body {
72     debug exprlen { $x + 10 }
73 } -result {3}
75 test debug-6.3 {debug exprlen too many args} -body {
76     debug exprlen a b c
77 } -returnCodes error -result {wrong # args: should be "debug exprlen expression"}
79 test debug-7.1 {debug exprbc too few args} -body {
80     debug exprbc
81 } -returnCodes error -result {wrong # args: should be "debug exprbc expression"}
83 test debug-7.2 {debug exprbc} -body {
84         set y [dict create]
85         dict set y z 1
86     debug exprbc { $x + 10 + 1.5 + true + [llength {{1} {2}}] + "5" + $y(z) + "\x33"}
87 } -result {+ {+ {+ {+ {+ {+ {+ {VAR x} {INT 10}} {DBL 1.5}} {BOO true}} {CMD {llength {{1} {2}}}}} {STR 5}} {ARY y(z)}} {ESC {\x33}}}
89 test debug-7.4 {debug exprbc too many args} -body {
90     debug exprbc a b c
91 } -returnCodes error -result {wrong # args: should be "debug exprbc expression"}
93 test debug-8.1 {debug show too few args} -body {
94     debug show
95 } -returnCodes error -result {wrong # args: should be "debug show object"}
97 test debug-8.1 {debug show} -body {
98         set x hello
99         lappend x there
100     debug show $x
101 } -result {refcount: 2, type: list
102 chars (11): <<hello there>>
103 bytes (11): 68 65 6c 6c 6f 20 74 68 65 72 65}
105 test debug-8.3 {debug show too many args} -body {
106     debug show a b c
107 } -returnCodes error -result {wrong # args: should be "debug show object"}
109 testreport