github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/c0115.yml (about) 1 doc_meta: | 2 folder: call-func 3 title: sequence matters in return 2 4 head: | 5 This shows that the sequence of the return matters. 6 7 In this demo, when callee's var value is updated in its own stack or callee stack, the return cmd will return the updated value to caller 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 - this proves the design of local 18 19 vars: 20 tom: this is tom in global 21 jerry: this is jerry in global 22 23 tasks: 24 - 25 name: task 26 desc: main entry 27 task: 28 - 29 func: call 30 name: main task 31 desc: call subtask and exam the return value in following steps 32 do: subtask1 33 34 - 35 func: cmd 36 desc: | 37 check value of tom 38 in this case tom's value should come from subtask1 39 tom's expected value: tom created in subtask1 40 do: 41 - name: print 42 cmd: 'in main task print3: {{.tom}}' 43 44 - 45 name: subtask1 46 desc: subtask to test reg and return 47 task: 48 - 49 func: cmd 50 desc: check value of tom after it is registered in current task stack 51 vars: 52 john: john in sub_loop func1 53 do: 54 - name: reg 55 desc: by default hitom is registered in to global context 56 cmd: 57 name: tom 58 value: 'tom created in subtask1' 59 60 - name: print 61 cmd: 'in subtask1 print1: {{.tom}}' 62 63 - 64 func: cmd 65 desc: check value of tom and it should be available in current stack 66 vars: 67 john: john in sub_loop func2 68 do: 69 - name: print 70 cmd: 'in subtask1 print21: {{.tom}}' 71 72 - 73 func: call 74 desc: call subtask and exam the return value in following steps 75 do: 76 - subtask2 77 - subtask3 78 79 - 80 func: cmd 81 desc: check value of tom and it should be available in current stack 82 vars: 83 john: john in sub_loop func2 84 do: 85 - name: print 86 cmd: 'in subtask1 print22: {{.tom}}' 87 88 - name: return 89 cmd: 90 - tom 91 92 93 - 94 name: subtask2 95 desc: subtask to test reg and return 96 task: 97 - 98 func: cmd 99 desc: check value of tom after it is registered in current task stack 100 vars: 101 john: john in sub_loop func1 102 do: 103 - name: reg 104 desc: by default hitom is registered in to global context 105 cmd: 106 name: tom 107 value: 'tom2 created in subtask2' 108 109 - name: print 110 cmd: 'in subtask2 print1: {{.tom}}' 111 112 - 113 func: cmd 114 desc: check value of tom and it should be available in current stack 115 vars: 116 john: john in sub_loop func2 117 do: 118 - name: print 119 cmd: 'in subtask2 print2: {{.tom}}' 120 121 - name: return 122 cmd: 123 - tom 124 125 - 126 name: subtask3 127 desc: subtask3 128 task: 129 - 130 func: cmd 131 desc: dummy 132 do: 133 - name: print 134 cmd: 'dummy to help build inspect task'