Skip to content

Commit 69c9d27

Browse files
test(name-resolve): Add non-snapshot test
1 parent d763ff3 commit 69c9d27

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

test/test_typecheck/test_name_resolve.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from unittest.mock import Mock, patch
22

33
from parser.common import StrRegion
4-
from parser.typecheck.typecheck import NameResolver
4+
from parser.typecheck.typecheck import (
5+
NameResolver, Scope, NameInfo, BoolType, ValType, VoidType,
6+
FuncInfo, ParamInfo)
57
from test.common import CommonTestCase
68

79

@@ -48,6 +50,29 @@ def test_top_scope_attr(self):
4850
self.assertIs(v2, nr.top_scope)
4951
m.assert_called_once() # Still only once
5052

53+
def test_params(self):
54+
src = ('def f1(bool b0, val v0, string s0, number n0) {let L0=s0..v0;};'
55+
'def f2() {}')
56+
sc = Scope()
57+
f1_scope = Scope()
58+
f1_scope.declared = {
59+
'b0': NameInfo(f1_scope, 'b0', BoolType(), is_param=True),
60+
'v0': (v0 := NameInfo(f1_scope, 'v0', ValType(), is_param=True)),
61+
's0': (s0 := NameInfo(f1_scope, 's0', ValType(), is_param=True)),
62+
'n0': NameInfo(f1_scope, 'n0', ValType(), is_param=True),
63+
}
64+
f1_scope.used = {'v0': v0, 's0': s0}
65+
sc.declared = {
66+
'f1': FuncInfo.from_param_info(sc, 'f1', [
67+
ParamInfo('b0', BoolType()),
68+
ParamInfo('v0', ValType()),
69+
ParamInfo('s0', ValType()), # val == string == number for now
70+
ParamInfo('n0', ValType()),
71+
], VoidType(), f1_scope),
72+
'f2': FuncInfo.from_param_info(sc, 'f2', [], VoidType(), Scope())
73+
}
74+
self.assertEqual(self.getNameResolver(src).run(), sc)
75+
5176

5277
class TestNameResolveErrors(CommonTestCase):
5378
def test_undefined_var(self):

0 commit comments

Comments
 (0)