OILS / spec / ysh-reserved.test.sh View on Github | oilshell.org

48 lines, 13 significant
1## our_shell: ysh
2
3#### Standalone generator expression
4var x = (i+1 for i in 1:3)
5# This is NOT a list. TODO: This test is overspecified.
6pp cell_ x | grep -o '<generator'
7write status=$?
8## status: 2
9## STDOUT:
10## END
11
12
13
14#### List comprehension (deferred)
15shopt -s oil:all
16
17var n = [i*2 for i in range(5)]
18write --sep ' ' @n
19
20# TODO: Test this
21#var n = [i*2 for i,j in range(5)]
22
23var even = [i*2 for i in range(5) if i % 2 === 0]
24write --sep ' ' @even
25## status: 2
26## STDOUT:
27## END
28
29
30#### Lambda not implemented
31const f = |x| x + 1
32
33## status: 2
34## STDOUT:
35## END
36
37#### Anonymous function expression not implemented (Tea)
38
39# Note: this results in a expr.Lambda node. But it's not parsed.
40
41const f = func(x) {
42 myfunc(x)
43 return x + 1
44}
45
46## status: 2
47## STDOUT:
48## END