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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
| | %prep
setopt chaselinks
cd .
unsetopt chaselinks
mydir=$PWD
%test
print 'print In sourced file
print $LINENO + $functrace + ${funcsourcetrace}
' >sourcedfile
print -r -- 'print Started functrace.zsh
module_path=(./Modules)
print $LINENO + $functrace + ${funcsourcetrace}
:
fn() {
print Inside function $0
print $LINENO + $functrace + ${funcsourcetrace}
}
:
fn
:
fpath=(. $fpath)
:
echo '\''print Inside $0
print $LINENO + $functrace + ${funcsourcetrace}
'\'' >autofn
:
autoload autofn
:
autofn
autofn
. ./sourcedfile' >functrace.zsh
$ZTST_testdir/../Src/zsh +Z -f ./functrace.zsh
0q:Function tracing
>Started functrace.zsh
>3 + +
>Inside function fn
>2 + ./functrace.zsh:10 + ./functrace.zsh:5
>Inside autofn
>2 + ./functrace.zsh:20 + $mydir/autofn:0
>Inside autofn
>2 + ./functrace.zsh:21 + $mydir/autofn:0
>In sourced file
>2 + ./functrace.zsh:22 + ./sourcedfile:0
print -r -- 'module_path=(./Modules)
debug_hook() { print $funcfiletrace[1] $functrace[1]; }
set -o DEBUG_BEFORE_CMD
trap "debug_hook" DEBUG
fn() {
a=1
eval "b=2"
c=3
}
fn
w=5
eval "x=6
y=7"
z=8' >rocky3.zsh
$ZTST_testdir/../Src/zsh +Z -f ./rocky3.zsh
0:Eval tracing
>./rocky3.zsh:5 ./rocky3.zsh:5
>./rocky3.zsh:10 ./rocky3.zsh:10
>./rocky3.zsh:6 fn:1
>./rocky3.zsh:7 fn:2
>./rocky3.zsh:7 (eval):1
>./rocky3.zsh:8 fn:3
>./rocky3.zsh:11 ./rocky3.zsh:11
>./rocky3.zsh:12 ./rocky3.zsh:12
>./rocky3.zsh:12 (eval):1
>./rocky3.zsh:13 (eval):2
>./rocky3.zsh:14 ./rocky3.zsh:14
(
fpath=($PWD)
print "print I have been autoloaded" >myfunc
autoload $PWD/myfunc
print ${functions_source[myfunc]}
myfunc
print ${functions_source[myfunc]}
)
0q: $functions_source
>$mydir/myfunc
>I have been autoloaded
>$mydir/myfunc
functions+=(a 'echo foo'); a
functions+=(a 'echo bar'); a
0:$functions can be appended to twice
>foo
>bar
repeat 3 echo $AUTOINCREMENT
:
AUTOINCREMENT=42;
repeat 3 echo $AUTOINCREMENT
:
AUTOINCREMENT=2147483647
repeat 3 echo $AUTOINCREMENT
:
AUTOINCREMENT=4294967295
repeat 3 echo $AUTOINCREMENT
:
AUTOINCREMENT=9223372036854775807
repeat 3 echo $AUTOINCREMENT
0:$AUTOINCREMENT unit test
>0
>1
>2
>42
>43
>44
>2147483647
>2147483648
>2147483649
>4294967295
>4294967296
>4294967297
>9223372036854775807
*>(-9223372036854775808|9223372036854775809)
*>(-9223372036854775807|9223372036854775810)
F:This test assumes zlong is at least a 64-bit type.
%clean
rm -f autofn functrace.zsh rocky3.zsh sourcedfile myfunc
|