1 ## our_shell: ysh
2
3 #### fastlex: NUL byte not allowed inside char literal #' '
4
5 echo $'var x = #\'\x00\'; echo x=$x' > tmp.oil
6 $SH tmp.oil
7
8 echo $'var x = #\' ' > incomplete.oil
9 $SH incomplete.oil
10
11 ## status: 2
12 ## STDOUT:
13 ## END
14
15 #### fastlex: NUL byte inside shebang line
16
17 # Hm this test doesn't really tickle the bug
18
19 echo $'#! /usr/bin/env \x00 sh \necho hi' > tmp.oil
20 env OILS_HIJACK_SHEBANG=1 $SH tmp.oil
21
22 ## STDOUT:
23 hi
24 ## END
25
26 #### Tea keywords don't interfere with Oil expressions
27
28 var d = {data: 'foo'}
29
30 echo $[d->data]
31
32 var e = {enum: 1, class: 2, import: 3, const: 4, var: 5, set: 6}
33 echo $[len(e)]
34
35 ## STDOUT:
36 foo
37 6
38 ## END
39
40 #### Catch AttributeError
41
42 var s = 'foo'
43 echo s=$s
44 var t = s.bad()
45 echo 'should not get here'
46
47 ## status: 3
48 ## STDOUT:
49 s=foo
50 ## END
51
52
53 #### Command sub paren parsing bug (#1387)
54
55 write $(if (true) { write true })
56
57 const a = $(write $[len('foo')])
58 echo $a
59
60 const b = $(write $[5 ** 3])
61 echo $b
62
63 const c = $(
64 write $[6 + 7]
65 )
66 echo $c
67
68 ## STDOUT:
69 true
70 3
71 125
72 13
73 ## END
74
75
76 #### More Command sub paren parsing
77
78 write $( var mylist = ['for']; for x in (mylist) { echo $x } )
79
80 write $( echo while; while (false) { write hi } )
81
82 write $( if (true) { write 'if' } )
83
84 write $( if (false) { write 'if' } elif (true) { write 'elif' } )
85
86 ## STDOUT:
87 for
88 while
89 if
90 elif
91 ## END
92
93