github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0114.yml (about) 1 doc_meta: | 2 folder: call-func 3 title: sequence matters in return 1 4 head: | 5 This shows that the sequence of the return matters. In this demo, it returns a value to caller, the following change in callee to the same var will not be reflected to caller. 6 7 This is also an example to show that the return cmd returns the value instead of the pointer 8 9 sections: 10 - title: Demo 11 log: yes 12 13 notes: 14 goal: 15 - demo a workflow using return in different cases 16 - the location of return cmd used could result in different result in parent vars scope 17 18 vars: 19 tom: this is tom in global 20 jerry: this is jerry in global 21 22 tasks: 23 - 24 name: task 25 desc: main entry 26 task: 27 - 28 func: call 29 desc: call subtask and exam the return value in following steps 30 do: subtask1 31 32 - 33 func: cmd 34 desc: | 35 check value of tom 36 in this case tom's value should come from subtask1 37 tom's expected value: tom created in subtask1 38 do: 39 - name: print 40 cmd: 'in main task print3: {{.tom}}' 41 42 - 43 name: subtask1 44 desc: subtask to test reg and return 45 task: 46 - 47 func: cmd 48 desc: check value of tom after it is registered in current task stack 49 vars: 50 john: john in sub_loop func1 51 do: 52 - name: reg 53 desc: by default hitom is registered in to global context 54 cmd: 55 name: tom 56 value: 'tom created in subtask1' 57 58 - name: print 59 cmd: 'in sub_loop print1: {{.tom}}' 60 61 - 62 func: cmd 63 desc: check value of tom and it should be available in current stack 64 vars: 65 john: john in sub_loop func2 66 do: 67 - name: print 68 cmd: 'in sub_loop print2: {{.tom}}' 69 70 - name: return 71 cmd: 72 - tom 73 74 - 75 func: call 76 desc: call subtask and exam the return value in following steps 77 do: subtask2 78 79 80 - 81 name: subtask2 82 desc: subtask to test reg and return 83 task: 84 - 85 func: cmd 86 desc: check value of tom after it is registered in current task stack 87 vars: 88 john: john in sub_loop func1 89 do: 90 - name: reg 91 desc: by default hitom is registered in to global context 92 cmd: 93 name: tom 94 value: 'tom2 created in subtask2' 95 96 - name: print 97 cmd: 'in sub_loop print1: {{.tom}}' 98 99 - 100 func: cmd 101 desc: check value of tom and it should be available in current stack 102 vars: 103 john: john in sub_loop func2 104 do: 105 - name: print 106 cmd: 'in sub_loop print2: {{.tom}}' 107 108 - name: return 109 cmd: 110 - tom 111