Skip to content

Commit

Permalink
[ysh] Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Apr 12, 2024
1 parent bb35f43 commit 3adad24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/typed_args_test.py
Expand Up @@ -25,7 +25,7 @@ def testReaderPosArgs(self):
expr.Const(arena.NewToken(-1, 4 + 2 * i, 1, line_id), value.Null)
for i in range(7)
]
arg_list = ArgList(ltok, pos_exprs, None, [], rtok)
arg_list = ArgList(ltok, pos_exprs, None, [], None, rtok)

# Not enough args...
reader = typed_args.Reader([], {}, arg_list, False)
Expand Down Expand Up @@ -102,7 +102,7 @@ def testReaderKwargs(self):
ltok = arena.NewToken(-1, 0, 3, line_id)
rtok = arena.NewToken(-1, 0, 4, line_id)
semi_tok = arena.NewToken(-1, 0, 5, line_id)
arg_list = ArgList(ltok, [], semi_tok, [], rtok)
arg_list = ArgList(ltok, [], semi_tok, [], None, rtok)

kwargs = {
'hot': value.Int(0xc0ffee),
Expand Down
7 changes: 4 additions & 3 deletions ysh/expr_to_ast.py
Expand Up @@ -494,7 +494,7 @@ def _Subscript(self, parent):

n = parent.NumChildren()

if ISNONTERMINAL(typ0):
if typ0 == grammar_nt.expr:
if n == 3: # a[1:2]
lower = self.Expr(parent.GetChild(0))
upper = self.Expr(parent.GetChild(2))
Expand All @@ -504,12 +504,13 @@ def _Subscript(self, parent):
else: # a[1]
return self.Expr(parent.GetChild(0))
else:
assert parent.GetChild(0).tok.id == Id.Arith_Colon
assert typ0 == Id.Arith_Colon
lower = None
if n == 1: # a[:]
upper = None
else: # a[:3]
upper = self.Expr(parent.GetChild(1))

return expr.Slice(lower, parent.GetChild(0).tok, upper)

def Expr(self, pnode):
Expand Down Expand Up @@ -1049,7 +1050,7 @@ def ProcCallArgs(self, pnode, arglist):
if n == 2: # f()
return

if n >= 3:
if n == 3:
p = pnode.GetChild(1) # the X in '( X )'

assert p.typ == grammar_nt.arglist
Expand Down

0 comments on commit 3adad24

Please sign in to comment.