diff --git a/test/js2tests/__init__.py b/test/js2tests/__init__.py index a9b1660b8..05df89c4f 100644 --- a/test/js2tests/__init__.py +++ b/test/js2tests/__init__.py @@ -1,3 +1,5 @@ +# TODO use json instead of py +# TODO create devscript to generate ASTs (using e.g. acorn) # """ # This package contains templates for `test_jsinterp` and `test_interp_parse` to create test methods. # These modules will create a test method for each module in this package. A test method consist of one or more subtest. diff --git a/test/js2tests/call.py b/test/js2tests/call.py index e49d56e15..f08f96a80 100644 --- a/test/js2tests/call.py +++ b/test/js2tests/call.py @@ -39,7 +39,7 @@ tests = [ ]) ] }, { - # FIXME built-in functions not yet implemented + # FIXME built-in functions are not yet implemented 'exclude': ('jsinterp2',), 'code': 'function x(a) { return a.split(""); }', 'asserts': [{'value': ["a", "b", "c"], 'call': ('x', "abc")}], diff --git a/youtube_dl/jsinterp2/jsbuilt_ins/internals.py b/youtube_dl/jsinterp2/jsbuilt_ins/internals.py index e822d87fc..3e888b4ab 100644 --- a/youtube_dl/jsinterp2/jsbuilt_ins/internals.py +++ b/youtube_dl/jsinterp2/jsbuilt_ins/internals.py @@ -83,6 +83,7 @@ def to_number(o): if v: s = 1 if v.startswith('+') or v.startswith('-') else 0 if v[s:] == 'Infinity': + # FIXME: declare in jsbuilt_ins (propery of global_obj) return float(v[:s] + 'inf') # 10 ** 10000 according to spec elif v[s:].isdigit(): return int(v) @@ -93,6 +94,7 @@ def to_number(o): else: return 0 else: + # FIXME: declare in jsbuilt_ins (propery of global_obj) return float('nan') elif isinstance(o, JSObjectPrototype): diff --git a/youtube_dl/jsinterp2/jsgrammar.py b/youtube_dl/jsinterp2/jsgrammar.py index 44bf15603..4b2e228c0 100644 --- a/youtube_dl/jsinterp2/jsgrammar.py +++ b/youtube_dl/jsinterp2/jsgrammar.py @@ -30,7 +30,7 @@ __ESC_HEX_RE = r'x[0-9a-fA-F]{2}' # NOTE order is fixed due to regex matching, does not represent any precedence -# NOTE unary operator 'delete', 'void', 'instanceof' and relation 'in' and 'instanceof' do not handled this way +# NOTE unary operator 'delete', 'void', 'instanceof' and relation 'in' and 'instanceof' are not handled this way _logical_operator = ['||', '&&'] _relation = ['===', '!==', '==', '!=', '<=', '>=', '<', '>'] _unary_operator = ['++', '--', '!', '~'] @@ -44,8 +44,8 @@ _NAME_RE = r'[a-zA-Z_$][a-zA-Z_$0-9]*' # non-escape char also can be escaped, but line continuation and quotes has to be # XXX unicode and hexadecimal escape sequences should be validated -_SINGLE_QUOTED_RE = r"""'(?:(?:\\'|\n)|[^'\n])*'""" -_DOUBLE_QUOTED_RE = r'''"(?:(?:\\"|\n)|[^"\n])*"''' +_SINGLE_QUOTED_RE = r"'(?:(?:\\'|\n)|[^'\n])*'" +_DOUBLE_QUOTED_RE = r'"(?:(?:\\"|\n)|[^"\n])*"' _STRING_RE = r'(?:%s)|(?:%s)' % (_SINGLE_QUOTED_RE, _DOUBLE_QUOTED_RE) _INTEGER_RE = r'(?:%(hex)s)|(?:%(dec)s)|(?:%(oct)s)' % {'hex': __HEXADECIMAL_RE, 'dec': __DECIMAL_RE, 'oct': __OCTAL_RE} @@ -54,7 +54,7 @@ _FLOAT_RE = r'(?:(?:%(dec)s\.[0-9]*)|(?:\.[0-9]+))(?:[eE][+-]?[0-9]+)?' % {'dec' _BOOL_RE = r'true|false' _NULL_RE = r'null' -# XXX early validation might needed +# XXX early validation might be needed # r'''/(?!\*) # (?:(?:\\(?:[tnvfr0.\\+*?^$\[\]{}()|/]|[0-7]{3}|x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4}|c[A-Z]|))|[^/\n])* # /(?:(?![gimy]*(?P[gimy])[gimy]*(?P=flag))[gimy]{0,4}\b|\s|$)'''