def test_nested_scope(self): string = "(lambda x. x) ((lambda x. x) (lambda z. (lambda x. x) x))" tokens = Lexer.tokenize(string) self.assertEqual( Parser.scope(tokens), [['lambda', 'x', '.', 'x'], [['lambda', 'x', '.', 'x'], ['lambda', 'z', '.', ['lambda', 'x', '.', 'x'], 'x']]])
def test_nested_scope(self): string = "(lambda x. x) ((lambda x. x) (lambda z. (lambda x. x) x))" tokens = Lexer.tokenize(string) self.assertEqual(Parser.scope(tokens), [['lambda', 'x', '.', 'x'], [['lambda', 'x', '.', 'x'], ['lambda', 'z', '.', ['lambda', 'x', '.', 'x'], 'x']]])
def test_scope3(self): newTokens = ['(', 'lambda', 'x', '.', 'x', 'y', ')', 't'] self.assertEqual(Parser.scope(newTokens), [['lambda', 'x', '.', 'x', 'y'], 't'])
def test_scope2(self): self.assertEqual(Parser.scope(self.id_tokens), [['lambda', 'x', '.', 'x']])
def test_scope1(self): self.assertEqual(Parser.scope(self.application_tokens), [['lambda', 'x', '.', 'x'], 't'])