Skip to content

Commit

Permalink
Added 1 final test (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
Totobird committed Sep 2, 2020
1 parent c3c3706 commit 9c86b61
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
56 changes: 28 additions & 28 deletions peridot/version/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,32 +214,6 @@ def visit_ArrayNode(self, node, context, insideloop=False):
)


def visit_TupleNode(self, node, context, insideloop=False):
res = RTResult()
elements = []
for i in node.elmnodes:
elm = res.register(
self.visit(
i,
context,
insideloop=insideloop
)
)

if res.shouldreturn():
return(res)

elements.append(elm)

return(
res.success(
TupleType(tuple(elements))
.setcontext(context)
.setpos(node.start, node.end)
)
)


def visit_DictionaryNode(self, node, context, insideloop=False):
res = RTResult()
elements = {}
Expand Down Expand Up @@ -277,7 +251,7 @@ def visit_DictionaryNode(self, node, context, insideloop=False):
msg = msg.replace('%s', key.type, 1)
return(
res.failure(
Exc_TypeError(
Exc_ValueError(
msg,
key.start, key.end,
context,
Expand All @@ -297,7 +271,7 @@ def visit_DictionaryNode(self, node, context, insideloop=False):
if type(value) != type(valuetype):
return(
res.failure(
Exc_TypeError(
Exc_ValueError(
msg,
value.start, value.end,
context,
Expand All @@ -322,6 +296,32 @@ def visit_DictionaryNode(self, node, context, insideloop=False):
)


def visit_TupleNode(self, node, context, insideloop=False):
res = RTResult()
elements = []
for i in node.elmnodes:
elm = res.register(
self.visit(
i,
context,
insideloop=insideloop
)
)

if res.shouldreturn():
return(res)

elements.append(elm)

return(
res.success(
TupleType(tuple(elements))
.setcontext(context)
.setpos(node.start, node.end)
)
)



### VARIABLE CONTROL
def visit_VarAccessNode(self, node, context, insideloop=False):
Expand Down
12 changes: 12 additions & 0 deletions peritests/dictionaries.peri
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
var periscope = include('periscope')


var pscope_this = func() -> Null {

var try = handler {{1: 2, 3.0: 4}}
assert(try.name == 'ValueException')

var try = handler {{1: 2, 3: 4.0}}
assert(try.name == 'ValueException')

return(Null)
}


var pscope_add = func() -> Null {

assert({1: 2, 3: 4} + {5: 6, 7: 8} == {1: 2, 3: 4, 5: 6, 7: 8})
Expand Down

0 comments on commit 9c86b61

Please sign in to comment.