diff options
author | dirkf <[email protected]> | 2024-12-07 03:37:39 +0000 |
---|---|---|
committer | dirkf <[email protected]> | 2024-12-16 12:38:51 +0000 |
commit | 118c6d7a17c61f1a1031e5530ca2854a526834d5 (patch) | |
tree | f818faab5391ab91e035a3177c986a7689885a86 /test | |
parent | f28d7178e4afb58a94994796cd81c22183ca33c2 (diff) | |
download | youtube-dl-118c6d7a17c61f1a1031e5530ca2854a526834d5.tar.gz youtube-dl-118c6d7a17c61f1a1031e5530ca2854a526834d5.zip |
[jsinterp] Implement `typeof` operator
Diffstat (limited to 'test')
-rw-r--r-- | test/test_jsinterp.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index c7a4f2cbf..d063bbd36 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -266,7 +266,20 @@ class TestJSInterpreter(unittest.TestCase): self._test('function f() { return (l=[0,1,2,3], function(a, b){return a+b})((l[1], l[2]), l[3]) }', 5) def test_void(self): - self._test('function f() { return void 42; }', None) + self._test('function f() { return void 42; }', JS_Undefined) + + def test_typeof(self): + self._test('function f() { return typeof undefined; }', 'undefined') + self._test('function f() { return typeof NaN; }', 'number') + self._test('function f() { return typeof Infinity; }', 'number') + self._test('function f() { return typeof true; }', 'boolean') + self._test('function f() { return typeof null; }', 'object') + self._test('function f() { return typeof "a string"; }', 'string') + self._test('function f() { return typeof 42; }', 'number') + self._test('function f() { return typeof 42.42; }', 'number') + self._test('function f() { var g = function(){}; return typeof g; }', 'function') + self._test('function f() { return typeof {key: "value"}; }', 'object') + # not yet implemented: Symbol, BigInt def test_return_function(self): jsi = JSInterpreter(''' |