@@ -186,3 +186,286 @@ tests:
186186 exit_code : 0
187187 status : " OK"
188188 signal : null
189+
190+ - name : " variables and arithmetic"
191+ requests :
192+ - input :
193+ runtime : bash
194+ files :
195+ - name : main.sh
196+ type : raw
197+ content : |
198+ a=10
199+ b=3
200+ echo $((a + b))
201+ echo $((a * b))
202+ echo $((a / b))
203+ echo $((a % b))
204+ output :
205+ status : 200
206+ body :
207+ run :
208+ stdout : " 13\n 30\n 3\n 1\n "
209+ stderr : " "
210+ output : " 13\n 30\n 3\n 1\n "
211+ exit_code : 0
212+ status : " OK"
213+ signal : null
214+
215+ - name : " arrays"
216+ requests :
217+ - input :
218+ runtime : bash
219+ files :
220+ - name : main.sh
221+ type : raw
222+ content : |
223+ arr=(apple banana cherry)
224+ echo "${arr[0]}"
225+ echo "${arr[@]}"
226+ echo "${#arr[@]}"
227+ arr+=(date)
228+ echo "${arr[-1]}"
229+ output :
230+ status : 200
231+ body :
232+ run :
233+ stdout : " apple\n apple banana cherry\n 3\n date\n "
234+ stderr : " "
235+ output : " apple\n apple banana cherry\n 3\n date\n "
236+ exit_code : 0
237+ status : " OK"
238+ signal : null
239+
240+ - name : " for loop"
241+ requests :
242+ - input :
243+ runtime : bash
244+ files :
245+ - name : main.sh
246+ type : raw
247+ content : |
248+ sum=0
249+ for i in $(seq 1 10); do
250+ sum=$((sum + i))
251+ done
252+ echo $sum
253+ output :
254+ status : 200
255+ body :
256+ run :
257+ stdout : " 55\n "
258+ stderr : " "
259+ output : " 55\n "
260+ exit_code : 0
261+ status : " OK"
262+ signal : null
263+
264+ - name : " while loop"
265+ requests :
266+ - input :
267+ runtime : bash
268+ files :
269+ - name : main.sh
270+ type : raw
271+ content : |
272+ n=1
273+ while [ $n -le 5 ]; do
274+ echo -n "$n "
275+ n=$((n + 1))
276+ done
277+ echo
278+ output :
279+ status : 200
280+ body :
281+ run :
282+ stdout : " 1 2 3 4 5 \n "
283+ stderr : " "
284+ output : " 1 2 3 4 5 \n "
285+ exit_code : 0
286+ status : " OK"
287+ signal : null
288+
289+ - name : " conditionals"
290+ requests :
291+ - input :
292+ runtime : bash
293+ files :
294+ - name : main.sh
295+ type : raw
296+ content : |
297+ x=15
298+ if [ $x -gt 20 ]; then
299+ echo "large"
300+ elif [ $x -gt 10 ]; then
301+ echo "medium"
302+ else
303+ echo "small"
304+ fi
305+ output :
306+ status : 200
307+ body :
308+ run :
309+ stdout : " medium\n "
310+ stderr : " "
311+ output : " medium\n "
312+ exit_code : 0
313+ status : " OK"
314+ signal : null
315+
316+ - name : " command substitution"
317+ requests :
318+ - input :
319+ runtime : bash
320+ files :
321+ - name : main.sh
322+ type : raw
323+ content : |
324+ lines=$(echo -e "a\nb\nc" | wc -l | tr -d ' ')
325+ echo "count: $lines"
326+ output :
327+ status : 200
328+ body :
329+ run :
330+ stdout : " count: 3\n "
331+ stderr : " "
332+ output : " count: 3\n "
333+ exit_code : 0
334+ status : " OK"
335+ signal : null
336+
337+ - name : " string manipulation"
338+ requests :
339+ - input :
340+ runtime : bash
341+ files :
342+ - name : main.sh
343+ type : raw
344+ content : |
345+ s="Hello, World!"
346+ echo "${s^^}"
347+ echo "${s,,}"
348+ echo "${s/World/Bash}"
349+ echo "${#s}"
350+ echo "${s:7:5}"
351+ output :
352+ status : 200
353+ body :
354+ run :
355+ stdout : " HELLO, WORLD!\n hello, world!\n Hello, Bash!\n 13\n World\n "
356+ stderr : " "
357+ output : " HELLO, WORLD!\n hello, world!\n Hello, Bash!\n 13\n World\n "
358+ exit_code : 0
359+ status : " OK"
360+ signal : null
361+
362+ - name : " functions"
363+ requests :
364+ - input :
365+ runtime : bash
366+ files :
367+ - name : main.sh
368+ type : raw
369+ content : |
370+ factorial() {
371+ local n=$1
372+ if [ $n -le 1 ]; then
373+ echo 1
374+ else
375+ local prev=$(factorial $((n - 1)))
376+ echo $((n * prev))
377+ fi
378+ }
379+ echo $(factorial 5)
380+ echo $(factorial 10)
381+ output :
382+ status : 200
383+ body :
384+ run :
385+ stdout : " 120\n 3628800\n "
386+ stderr : " "
387+ output : " 120\n 3628800\n "
388+ exit_code : 0
389+ status : " OK"
390+ signal : null
391+
392+ - name : " read file"
393+ requests :
394+ - input :
395+ runtime : bash
396+ files :
397+ - name : main.sh
398+ type : raw
399+ content : |
400+ while IFS=, read -r name age; do
401+ echo "$name is $age years old"
402+ done < data.csv
403+ - name : data.csv
404+ type : raw
405+ content : |
406+ Alice,30
407+ Bob,25
408+ Charlie,35
409+ output :
410+ status : 200
411+ body :
412+ run :
413+ stdout : " Alice is 30 years old\n Bob is 25 years old\n Charlie is 35 years old\n "
414+ stderr : " "
415+ output : " Alice is 30 years old\n Bob is 25 years old\n Charlie is 35 years old\n "
416+ exit_code : 0
417+ status : " OK"
418+ signal : null
419+
420+ - name : " sed and grep"
421+ requests :
422+ - input :
423+ runtime : bash
424+ files :
425+ - name : main.sh
426+ type : raw
427+ content : |
428+ echo -e "apple\nbanana\ncherry\napricot" | grep "^a"
429+ echo "---"
430+ echo "Hello World" | sed 's/World/Bash/'
431+ output :
432+ status : 200
433+ body :
434+ run :
435+ stdout : " apple\n apricot\n ---\n Hello Bash\n "
436+ stderr : " "
437+ output : " apple\n apricot\n ---\n Hello Bash\n "
438+ exit_code : 0
439+ status : " OK"
440+ signal : null
441+
442+ - name : " case statement"
443+ requests :
444+ - input :
445+ runtime : bash
446+ files :
447+ - name : main.sh
448+ type : raw
449+ content : |
450+ classify() {
451+ case "$1" in
452+ [0-9]*) echo "number" ;;
453+ [a-z]*) echo "lowercase" ;;
454+ [A-Z]*) echo "uppercase" ;;
455+ *) echo "other" ;;
456+ esac
457+ }
458+ classify "42"
459+ classify "hello"
460+ classify "World"
461+ classify "!!"
462+ output :
463+ status : 200
464+ body :
465+ run :
466+ stdout : " number\n lowercase\n uppercase\n other\n "
467+ stderr : " "
468+ output : " number\n lowercase\n uppercase\n other\n "
469+ exit_code : 0
470+ status : " OK"
471+ signal : null
0 commit comments