sulyi a33b47e485 [jsinterp] Adding handling lineterminator
- adds `jsgrammar.LINETERMINATORSEQ_RE`
- lexer `tstream.TokenStream` checks for lineterminators in tokens
- adds `tstream.Token`
- refractors `tstream.TokenStream` and `jsparser.Parser` and to use it
2018-06-10 22:27:22 +02:00

33 lines
963 B
Python

from __future__ import unicode_literals
from youtube_dl.jsinterp2.jsgrammar import TokenTypes
tests = [
{
'code': 'function f() { return 42; }',
'asserts': [{'value': 42, 'call': ('f',)}],
'ast': [
(TokenTypes.FUNC, 'f', [], [
(TokenTypes.RETURN,
(TokenTypes.EXPR, [
(TokenTypes.ASSIGN,
None,
(TokenTypes.OPEXPR, [(TokenTypes.MEMBER, (TokenTypes.INT, 42), None, None)]),
None)
]))
])
]
},
{
'code': 'function x() {;}',
'asserts': [{'value': None, 'call': ('x',)}],
'ast': [(TokenTypes.FUNC, 'x', [], [None])]
},
{
# FIXME: function expression needs to be implemented
'exclude': ('jsinterp2',),
'code': 'var x5 = function x5(){return 42;}',
'asserts': [{'value': 42, 'call': ('x5',)}]
}
]