mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-02-15 20:48:32 +01:00
parent
241ace4f10
commit
4ca8c44a07
3 changed files with 15 additions and 1 deletions
|
@ -93,6 +93,16 @@ class TestJSInterpreter(unittest.TestCase):
|
|||
self._test('function f(){return 0 ?? 42;}', 0)
|
||||
self._test('function f(){return "life, the universe and everything" < 42;}', False)
|
||||
self._test('function f(){return 0 - 7 * - 6;}', 42)
|
||||
self._test('function f(){return true << "5";}', 32)
|
||||
self._test('function f(){return true << true;}', 2)
|
||||
self._test('function f(){return "19" & "21.9";}', 17)
|
||||
self._test('function f(){return "19" & false;}', 0)
|
||||
self._test('function f(){return "11.0" >> "2.1";}', 2)
|
||||
self._test('function f(){return 5 ^ 9;}', 12)
|
||||
self._test('function f(){return 0.0 << NaN}', 0)
|
||||
self._test('function f(){return null << undefined}', 0)
|
||||
# TODO: Does not work due to number too large
|
||||
# self._test('function f(){return 21 << 4294967297}', 42)
|
||||
|
||||
def test_array_access(self):
|
||||
self._test('function f(){var x = [1,2,3]; x[0] = 4; x[0] = 5; x[2.0] = 7; return x;}', [5, 2, 7])
|
||||
|
|
|
@ -201,6 +201,10 @@ _NSIG_TESTS = [
|
|||
'https://www.youtube.com/s/player/2f1832d2/player_ias.vflset/en_US/base.js',
|
||||
'YWt1qdbe8SAfkoPHW5d', 'RrRjWQOJmBiP',
|
||||
),
|
||||
(
|
||||
'https://www.youtube.com/s/player/9c6dfc4a/player_ias.vflset/en_US/base.js',
|
||||
'jbu7ylIosQHyJyJV', 'uwI0ESiynAmhNg',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ def _js_bit_op(op):
|
|||
with contextlib.suppress(TypeError):
|
||||
if math.isnan(x): # NB: NaN cannot be checked by membership
|
||||
return 0
|
||||
return x
|
||||
return int(float(x))
|
||||
|
||||
def wrapped(a, b):
|
||||
return op(zeroise(a), zeroise(b)) & 0xffffffff
|
||||
|
|
Loading…
Add table
Reference in a new issue