/
c0106.yml
113 lines (94 loc) · 2.71 KB
/
c0106.yml
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
doc_meta: |
folder: vars
title: var scope in callee
head: |
Showcase the var scope, how local var and global var are diffent and used in different context
sections:
- title: Demo
log: yes
- title: vars accessibility in call stack
content: |
Understanding of global vars scope in call stack
global vars scope is not unique, it is a concept of relative scope for its call stack. within that call stack, all changes(new registered global vars) will be valid only for its own stack in that call func only
refs:
- title: show the problem
link: ../../test-debug/c0107
- title: taskScope
content: |
use taskScope
refs:
- title: taskScope
link: ../../test-debug/c0108
notes:
goal:
- to test the registered global var should be availabe in global context
vars:
tom: this is tom
tasks:
-
name: task
task:
-
func: call
do: sub1
-
func: cmd
desc: |
check if hitom is available in global context
it should be <no value> as hitom in sub1 is marked localOnly
do:
- name: print
cmd: '{{.hitom}}'
-
func: call
do: sub2
-
func: cmd
desc: |
check if hitom is available in global context
though hitom was regiser as global var, but it was registered to its own call stack
however this is only available in its own call stack global but not return and available to its parent var scope
do:
- name: print
cmd: '{{.hitom}}'
-
name: sub1
task:
-
func: cmd
do:
- name: reg
cmd:
name: hitom
desc: by default hitom is registered in to global context
value: 'hello, {{.tom}}'
flags: [localOnly]
- name: print
cmd: '{{.hitom}}'
-
func: cmd
do:
- name: print
desc: should be <no value> since it is marked localOnly
cmd: '{{.hitom}}'
-
name: sub2
task:
-
func: cmd
do:
- name: reg
cmd:
name: hitom
desc: by default hitom is registered in to global context
value: 'hello, {{.tom}}'
- name: print
cmd: '{{.hitom}}'
-
func: cmd
do:
- name: print
desc: |
by default hitom is accessible from global context, that's why it is accessiable cross func
however this is only available in its own call stack global but not return and available to its parent var scope
cmd: '{{.hitom}}'