aboutsummaryrefslogtreecommitdiff
path: root/tests/expansion/subscript.testscript
blob: 38728d448e0f538b50658662c958c602190c9ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# file      : tests/expansion/subscript.testscript
# license   : MIT; see accompanying LICENSE file

# Test subscript expansion.

.include ../common.testscript

: basics
:
$* <<EOI >>EOO
x = zero one two three
y = zero@one two@three
i = 2

print ($x[1])
print ($x[4])
print (($x)[1])
print (($x)[4])
print ($identity($x)[1])
print ($identity($x)[4])

print

print ($y[1])
print ($y[4])
print (($y)[1])
print (($y)[4])
print ($identity($y)[1])
print ($identity($y)[4])

print

print ($x[$i])

EOI
one
[null]
one
[null]
one
[null]

two@three
[null]
two@three
[null]
two@three
[null]

two
EOO

: unseparated
:
$* <<EOI >>EOO
x = zero one
print ($x [1])
EOI
zero one
EOO

: escape
:
$* <<EOI >>EOO
x = zero
print ($x\[abc])
EOI
EOO

: preparse
:
$* <<EOI >>EOO
x = zero one two three
print (true ? $x[1] : $x[])
EOI
one
EOO

: missing-rsbrace
:
$* <'print ($x[1)' 2>>EOE != 0
<stdin>:1:12: error: expected ']' instead of ')'
EOE

: invalid-subscript
:
$* <'print ($x[1a])' 2>>EOE != 0
<stdin>:1:11: error: invalid value subscript: invalid uint64 value '1a'
  <stdin>:1:9: info: use the '\[' escape sequence if this is a wildcard pattern
EOE

: empty-subscript
:
$* <'print ($x[])' 2>>EOE != 0
<stdin>:1:11: error: invalid value subscript: invalid uint64 value: empty
  <stdin>:1:9: info: use the '\[' escape sequence if this is a wildcard pattern
EOE