From 71a485fdb6d8dbbf63e80894905227170c1275e1 Mon Sep 17 00:00:00 2001 From: sulyi Date: Fri, 25 Nov 2016 22:41:33 +0100 Subject: [PATCH] [jsinterp] Complex call test (thx to yan12125) --- test/test_jsinterp.py | 6 ++++++ youtube_dl/jsinterp.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index ceaf36d30..9897c3db2 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -113,6 +113,12 @@ class TestJSInterpreter(unittest.TestCase): self.assertEqual(jsi.call_function('z'), 5) jsi = JSInterpreter('function x(a) { return a.split(""); }', objects={'a': 'abc'}) self.assertEqual(jsi.call_function('x'), ["a", "b", "c"]) + jsi = JSInterpreter(''' + function a(x) { return x; } + function b(x) { return x; } + function c() { return [a, b][0](0); } + ''') + self.assertEqual(jsi.call_function('c'), 0) def test_getfield(self): jsi = JSInterpreter('function c() { return a.var; }', objects={'a': {'var': 3}}) diff --git a/youtube_dl/jsinterp.py b/youtube_dl/jsinterp.py index 86b4f5488..35d2c535f 100644 --- a/youtube_dl/jsinterp.py +++ b/youtube_dl/jsinterp.py @@ -58,7 +58,7 @@ _LITERAL_RE = r'((?P%(int)s)|(?P%(float)s)|(?P%(str)s)|(?P