*** Running test-arglist
===== CASE: -n -c json write () =====
json write ()
^
[ -c flag ]:1: Empty arg list not allowed
===== CASE: -n -c p (; n=42) =====
(command.Simple
blame_tok:
more_env: []
words: [{
}]
redirects: []
typed_args:
(ArgList
left:
pos_args: []
semi_tok:
named_args: [(NamedArg name: value:(expr.Const c:))]
right:
)
do_fork: T
)
===== CASE: -n -c = f(; n=42) =====
(command.Expr
keyword:
e:
(expr.FuncCall
func: (expr.Var name:)
args:
(ArgList
left:
pos_args: []
semi_tok:
named_args: [(NamedArg name: value:(expr.Const c:))]
right:
)
)
)
===== CASE: -n -c = f(; 42) =====
= f(; 42)
^~
[ -c flag ]:1: Positional args must come before the semi-colon
===== CASE: -n -c = f(; name) =====
= f(; name)
^~~~
[ -c flag ]:1: Positional args must come before the semi-colon
===== CASE: -n -c = f(; x for x in y) =====
= f(; x for x in y)
^
[ -c flag ]:1: Positional args must come before the semi-colon
OK test-arglist
*** Running test-blocks
===== CASE: -n -c >out { echo hi } =====
>out { echo hi }
^
[ -c flag ]:1: Unexpected typed args
===== CASE: -n -c a=1 b=2 { echo hi } =====
a=1 b=2 { echo hi }
^
[ -c flag ]:1: Unexpected typed args
===== CASE: -n -c break { echo hi } =====
break { echo hi }
^
[ -c flag ]:1: Unexpected typed args
===== CASE: -n -c cd / { echo hi } cd / =====
cd / { echo hi } cd /
^~
[ -c flag ]:1: Invalid word while parsing command line
OK test-blocks
*** Running test-destructure
===== CASE: -n -c
func f() {
const x, y = 3, 4
#setvar x = 5
setvar y = 6
} =====
const x, y = 3, 4
^~~~~
[ -c flag ]:3: const can't be inside proc or func. Use var instead.
===== CASE: -n -c
func f() {
var x, y = 3, 4
var y = 6
} =====
var y = 6
^
[ -c flag ]:5: 'y' was already declared
===== CASE: -n -c
func f() {
var x, y = 3, 4
const y = 6
} =====
const y = 6
^~~~~
[ -c flag ]:5: const can't be inside proc or func. Use var instead.
OK test-destructure
*** Running test-eggex-capture
===== CASE: -n -c = / d+ / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: []
canonical_flags: ''
)
)
===== CASE: -n -c = / < capture d+ as date > / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex:
(re.Capture
child: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
name:
)
flags: []
canonical_flags: ''
)
)
===== CASE: -n -c = / < capture d+ as date: Int > / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex:
(re.Capture
child: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
name:
func_name:
)
flags: []
canonical_flags: ''
)
)
===== CASE: -n -c var capture = 42 =====
var capture = 42
^~~~~~~
[ -c flag ]:1: Syntax error in expression (near Id.Expr_Capture)
===== CASE: -n -c var as = 42 =====
var as = 42
^~
[ -c flag ]:1: Syntax error in expression (near Id.Expr_As)
OK test-eggex-capture
*** Running test-eggex-flags
===== CASE: -n -c = / d+ ; reg_icase / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: [(EggexFlag negated:F flag:)]
canonical_flags: i
)
)
===== CASE: -n -c = / d+ ; i / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: [(EggexFlag negated:F flag:)]
canonical_flags: i
)
)
===== CASE: -n -c = / d+ ; !i / =====
= / d+ ; !i /
^
[ -c flag ]:1: Flag can't be negated
===== CASE: -n -c = / d+ ; reg_oops / =====
= / d+ ; reg_oops /
^~~~~~~~
[ -c flag ]:1: Invalid regex flag 'reg_oops'
===== CASE: -n -c = / d+ ; !i; PCRE / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: [(EggexFlag negated:T flag:)]
trans_pref:
)
)
===== CASE: -n -c = / d+ ; reg_oops; PCRE / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: [(EggexFlag negated:F flag:)]
trans_pref:
)
)
===== CASE: -n -c = / d+ ; i reg_newline ; ERE / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: [
(EggexFlag negated:F flag:)
(EggexFlag negated:F flag:)
]
trans_pref:
canonical_flags: in
)
)
===== CASE: -n -c = / d+ ; ; ERE / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: []
trans_pref:
canonical_flags: ''
)
)
===== CASE: -n -c = / d+ ; / =====
(command.Expr
keyword:
e:
(Eggex
left:
regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:))
flags: []
canonical_flags: ''
)
)
===== CASE: -n -c = / d+ ; ; / =====
= / d+ ; ; /
^
[ -c flag ]:1: Syntax error in expression (near Id.Arith_Slash)
===== CASE: -n -c = / d+ ; ; ; / =====
= / d+ ; ; ; /
^
[ -c flag ]:1: Syntax error in expression (near Id.Op_Semi)
OK test-eggex-flags
*** Running test-fat-arrow
===== CASE: -n -c var x = s => trim() =====
(command.VarDecl
keyword:
lhs: [(NameType name:)]
rhs:
(expr.FuncCall
func:
(Attribute
obj: (expr.Var name:)
op: '>
attr:
ctx: expr_context.Store
)
args: (ArgList left: pos_args:[] named_args:[] right:)
)
)
===== CASE: -n -c func f(x Int) => List[Int] { echo hi } =====
(Func
keyword:
name:
positional:
(ParamGroup
params: [
(Param
blame_tok:
name: x
type: (TypeExpr tok: name:Int)
)
]
)
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
)
OK test-fat-arrow
*** Running test-float-literals
===== CASE: -n -c = 42.0 =====
(command.Expr keyword: e:(expr.Const c:))
===== CASE: -n -c = 42_0.0 =====
(command.Expr keyword: e:(expr.Const c:))
===== CASE: -n -c = 42_.0 =====
= 42_.0
^
[ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt)
===== CASE: -n -c = 42. =====
= 42.
^
[ -c flag ]:1: Syntax error in expression (near Id.Eof_Real)
===== CASE: -n -c = .333 =====
= .333
^
[ -c flag ]:1: Syntax error in expression (near Id.Expr_Dot)
===== CASE: -n -c = _42.0 =====
= _42.0
^
[ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt)
OK test-float-literals
*** Running test-for-parse-bare-word
===== CASE: -n -c
for x in bare {
echo $x
}
=====
for x in bare {
^~~~
[ -c flag ]:2: Surround this word with either parens or quotes (parse_bare_word)
===== CASE: -n -c
for x in a b {
echo $x
}
=====
(command.ForEach
keyword:
iter_names: [x]
iterable: (for_iter.Words words:[{} {}])
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {($ Id.VSub_DollarName x)}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
redirects: []
)
===== CASE: -n -c
for x in *.py {
echo $x
}
=====
(command.ForEach
keyword:
iter_names: [x]
iterable: (for_iter.Words words:[{ <.py>}])
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {($ Id.VSub_DollarName x)}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
redirects: []
)
===== CASE: -n -c
for x in "quoted" {
echo $x
}
=====
(command.ForEach
keyword:
iter_names: [x]
iterable: (for_iter.Words words:[{(DQ )}])
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {($ Id.VSub_DollarName x)}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
redirects: []
)
OK test-for-parse-bare-word
*** Running test-func-def
===== CASE: -n -c func f(p) { var p = foo } =====
func f(p) { var p = foo }
^
[ -c flag ]:1: 'p' was already declared
===== CASE: -n -c func f(p; n) { var n = foo } =====
func f(p; n) { var n = foo }
^
[ -c flag ]:1: 'n' was already declared
OK test-func-def
*** Running test-func-sig
===== CASE: -n -c func f { echo hi } =====
func f { echo hi }
^
[ -c flag ]:1: Syntax error in expression (near Id.Op_LBrace)
===== CASE: -n -c func f () { echo hi } =====
(Func
keyword:
name:
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
)
===== CASE: -n -c func f (a List[Int] = [3,4]) { echo hi } =====
(Func
keyword:
name:
positional:
(ParamGroup
params: [
(Param
blame_tok:
name: a
type:
(TypeExpr
tok:
name: List
params: [(TypeExpr tok: name:Int)]
)
default_val:
(expr.List
left:
elts: [(expr.Const c:) (expr.Const c:)]
ctx: expr_context.Store
)
)
]
)
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
)
===== CASE: -n -c func f (a, b, ...rest; c) { echo hi } =====
(Func
keyword:
name:
positional:
(ParamGroup
params: [(Param blame_tok: name:a) (Param blame_tok: name:b)]
rest_of: (RestParam blame_tok: name:rest)
)
named: (ParamGroup params:[(Param blame_tok: name:c)])
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
)
===== CASE: -n -c func f (a, b, ...rest; c, ...named) { echo hi } =====
(Func
keyword:
name:
positional:
(ParamGroup
params: [(Param blame_tok: name:a) (Param blame_tok: name:b)]
rest_of: (RestParam blame_tok: name:rest)
)
named:
(ParamGroup
params: [(Param blame_tok: name:c)]
rest_of: (RestParam blame_tok: name:named)
)
body:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
)
===== CASE: -n -c func f (a, b, ...rest; c, ...named;) { echo hi } =====
func f (a, b, ...rest; c, ...named;) { echo hi }
^
[ -c flag ]:1: Syntax error in expression (near Id.Op_Semi)
OK test-func-sig
*** Running test-func-var-checker
===== CASE: -n -c
func f(x) {
setvar x = True
}
=====
(Func
keyword:
name:
positional: (ParamGroup params:[(Param blame_tok: name:x)])
body:
(BraceGroup
left:
children: [
(command.Mutation
keyword:
lhs: [(y_lhs.Var name:)]
op:
rhs: (expr.Var name:)
)
]
redirects: []
right:
)
)
===== CASE: -n -c
func f() {
setvar x = True
}
=====
setvar x = True
^
[ -c flag ]:3: setvar couldn't find matching 'var x'
OK test-func-var-checker
*** Running test-hay-assign
===== CASE: -n -c
name = val
=====
name = val
^
[ -c flag ]:2: Unexpected = (Hint: use var/setvar, or quote it)
===== CASE: -n -c
rule {
x = 42
}
=====
x = 42
^
[ -c flag ]:3: Unexpected = (Hint: use var/setvar, or quote it)
===== CASE: -n -c
RULE {
x = 42
}
=====
x = 42
^
[ -c flag ]:3: Unexpected = (Hint: use var/setvar, or quote it)
===== CASE: -n -c
Rule {
x = 42
}
=====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [(command.VarDecl lhs:[(NameType name:)] rhs:(expr.Const c:))]
redirects: []
right:
)
lines: [
(SourceLine line_num:2 content:'Rule {\n' src:(source__CFlag))
(SourceLine line_num:3 content:' x = 42\n' src:(source__CFlag))
(SourceLine line_num:4 content:'}\n' src:(source__CFlag))
]
)
do_fork: T
)
===== CASE: -n -c
Rule X Y {
x = 42
}
=====
(command.Simple
blame_tok:
more_env: []
words: [{} {} {}]
redirects: []
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [(command.VarDecl lhs:[(NameType name:)] rhs:(expr.Const c:))]
redirects: []
right:
)
lines: [
(SourceLine line_num:2 content:'Rule X Y {\n' src:(source__CFlag))
(SourceLine line_num:3 content:' x = 42\n' src:(source__CFlag))
(SourceLine line_num:4 content:'}\n' src:(source__CFlag))
]
)
do_fork: T
)
===== CASE: -n -c
RULe { # inconsistent but OK
x = 42
}
=====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [(command.VarDecl lhs:[(NameType name:)] rhs:(expr.Const c:))]
redirects: []
right:
)
lines: [
(SourceLine line_num:2 content:'RULe { # inconsistent but OK\n' src:(source__CFlag))
(SourceLine line_num:3 content:' x = 42\n' src:(source__CFlag))
(SourceLine line_num:4 content:'}\n' src:(source__CFlag))
]
)
do_fork: T
)
===== CASE: -n -c
hay eval :result {
Rule {
foo = 42
}
bar = 43 # parse error here
}
=====
bar = 43 # parse error here
^
[ -c flag ]:8: Unexpected = (Hint: use var/setvar, or quote it)
===== CASE: -n -c
hay define TASK
TASK build {
foo = 42
}
=====
foo = 42
^
[ -c flag ]:5: Unexpected = (Hint: use var/setvar, or quote it)
===== CASE: -n -c
hay define Package/TASK
Package libc {
TASK build {
# this is not an attribute, should not be valid
foo = 42
}
}
=====
foo = 42
^
[ -c flag ]:7: Unexpected = (Hint: use var/setvar, or quote it)
===== CASE: -n -c
hay define Rule
Rule {
return (x)
}
=====
return (x)
^
[ -c flag ]:5: Typed return is only allowed inside func
OK test-hay-assign
*** Running test-hay-shell-assign
===== CASE: -n -c
hay define Package
Package foo {
version=1
}
=====
version=1
^~~~~~~~
[ -c flag ]:5: Use var/setvar to assign in YSH
===== CASE: -n -c
hay define Package/User
Package foo {
User bob {
sudo=1
}
}
=====
sudo=1
^~~~~
[ -c flag ]:6: Use var/setvar to assign in YSH
===== CASE: -n -c
hay define Package/SHELL/User
Package foo {
SHELL bob {
sudo=1
User {
name = "z"
}
}
}
=====
(command.CommandList
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {} {<'Package/SHELL/User'>}]
redirects: []
do_fork: T
)
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [
(command.ShAssignment
left:
pairs: [
(AssignPair
left:
lhs: (sh_lhs.Name left: name:sudo)
op: assign_op.Equal
rhs: {<1>}
)
]
redirects: []
)
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [
(command.VarDecl
lhs: [(NameType name:)]
rhs: (DQ )
)
]
redirects: []
right:
)
lines: [
(SourceLine
line_num: 7
content: ' User {\n'
src: (source__CFlag)
)
(SourceLine
line_num: 8
content: ' name = "z"\n'
src: (source__CFlag)
)
(SourceLine
line_num: 9
content: ' }\n'
src: (source__CFlag)
)
]
)
do_fork: T
)
]
redirects: []
right:
)
lines: []
)
do_fork: T
)
]
redirects: []
right:
)
lines: []
)
do_fork: T
)
]
)
===== CASE: -n -c
hay define Package/SHELL/User
Package foo {
SHELL bob {
# Disallowed
# a = b
User {
x=1
}
}
}
=====
x=1
^~
[ -c flag ]:9: Use var/setvar to assign in YSH
OK test-hay-shell-assign
*** Running test-int-literals
===== CASE: -n -c = 42 =====
(command.Expr keyword: e:(expr.Const c:))
===== CASE: -n -c = 42_0 =====
(command.Expr keyword: e:(expr.Const c:))
===== CASE: -n -c = 42_ =====
= 42_
^
[ -c flag ]:1: Units suffix not implemented
===== CASE: -n -c = 42_0_ =====
= 42_0_
^
[ -c flag ]:1: Units suffix not implemented
===== CASE: -n -c = _42 =====
(command.Expr keyword: e:(expr.Var name:))
OK test-int-literals
*** Running test-lazy-arg-list
===== CASE: -n -c assert [42 === x] =====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [
(expr.Compare
left: (expr.Const c:)
ops: []
comparators: [(expr.Var name:)]
)
]
named_args: []
right:
)
do_fork: T
)
===== CASE: -n -c assert [ 42 === x ] =====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [
(expr.Compare
left: (expr.Const c:)
ops: []
comparators: [(expr.Var name:)]
)
]
named_args: []
right:
)
do_fork: T
)
===== CASE: -n -c assert [42, 43] =====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [(expr.Const c:) (expr.Const c:)]
named_args: []
right:
)
do_fork: T
)
===== CASE: -n -c assert [42, named=true] =====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [(expr.Const c:)]
named_args: [(NamedArg name: value:(expr.Const c:))]
right:
)
do_fork: T
)
===== CASE: -n -c assert [42, named=true]; echo hi =====
(command.CommandList
children: [
(command.Sentence
child:
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [(expr.Const c:)]
named_args: [
(NamedArg
name:
value: (expr.Const c:)
)
]
right:
)
do_fork: T
)
terminator:
)
(command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T)
]
)
===== CASE: -n -c assert [42, named=true] { echo hi } =====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [(expr.Const c:)]
named_args: [(NamedArg name: value:(expr.Const c:))]
right:
)
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [
(command.Simple
blame_tok:
more_env: []
words: [{} {}]
redirects: []
do_fork: T
)
]
redirects: []
right:
)
lines: [(SourceLine line_num:1 content:'assert [42, named=true] { echo hi }' src:(source__CFlag))]
)
do_fork: T
)
===== CASE: -n -c assert [42, named=true]{ echo hi } =====
(command.Simple
blame_tok:
more_env: []
words: [{}]
redirects: []
typed_args:
(ArgList
left:
pos_args: [(expr.Const c:)]
named_args: [(NamedArg name: value:(expr.Const c:))]
right:
)
block:
(LiteralBlock
brace_group:
(BraceGroup
left:
children: [
(command.Simple
blame_tok: