diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/swftests/.gitignore | 1 | ||||
-rw-r--r-- | test/swftests/ArrayAccess.as | 19 | ||||
-rw-r--r-- | test/swftests/ClassCall.as | 17 | ||||
-rw-r--r-- | test/swftests/ClassConstruction.as | 15 | ||||
-rw-r--r-- | test/swftests/ConstArrayAccess.as | 18 | ||||
-rw-r--r-- | test/swftests/ConstantInt.as | 12 | ||||
-rw-r--r-- | test/swftests/DictCall.as | 10 | ||||
-rw-r--r-- | test/swftests/EqualsOperator.as | 10 | ||||
-rw-r--r-- | test/swftests/LocalVars.as | 13 | ||||
-rw-r--r-- | test/swftests/MemberAssignment.as | 22 | ||||
-rw-r--r-- | test/swftests/NeOperator.as | 24 | ||||
-rw-r--r-- | test/swftests/PrivateCall.as | 21 | ||||
-rw-r--r-- | test/swftests/PrivateVoidCall.as | 22 | ||||
-rw-r--r-- | test/swftests/StaticAssignment.as | 13 | ||||
-rw-r--r-- | test/swftests/StaticRetrieval.as | 16 | ||||
-rw-r--r-- | test/swftests/StringBasics.as | 11 | ||||
-rw-r--r-- | test/swftests/StringCharCodeAt.as | 11 | ||||
-rw-r--r-- | test/swftests/StringConversion.as | 11 | ||||
-rw-r--r-- | test/test_iqiyi_sdk_interpreter.py | 48 | ||||
-rw-r--r-- | test/test_swfinterp.py | 80 | ||||
-rw-r--r-- | test/test_update.py | 30 | ||||
-rw-r--r-- | test/versions.json | 34 |
22 files changed, 0 insertions, 458 deletions
diff --git a/test/swftests/.gitignore b/test/swftests/.gitignore deleted file mode 100644 index da97ff7ca..000000000 --- a/test/swftests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swf diff --git a/test/swftests/ArrayAccess.as b/test/swftests/ArrayAccess.as deleted file mode 100644 index e22caa386..000000000 --- a/test/swftests/ArrayAccess.as +++ /dev/null @@ -1,19 +0,0 @@ -// input: [["a", "b", "c", "d"]] -// output: ["c", "b", "a", "d"] - -package { -public class ArrayAccess { - public static function main(ar:Array):Array { - var aa:ArrayAccess = new ArrayAccess(); - return aa.f(ar, 2); - } - - private function f(ar:Array, num:Number):Array{ - var x:String = ar[0]; - var y:String = ar[num % ar.length]; - ar[0] = y; - ar[num] = x; - return ar; - } -} -} diff --git a/test/swftests/ClassCall.as b/test/swftests/ClassCall.as deleted file mode 100644 index aef58daf3..000000000 --- a/test/swftests/ClassCall.as +++ /dev/null @@ -1,17 +0,0 @@ -// input: [] -// output: 121 - -package { -public class ClassCall { - public static function main():int{ - var f:OtherClass = new OtherClass(); - return f.func(100,20); - } -} -} - -class OtherClass { - public function func(x: int, y: int):int { - return x+y+1; - } -} diff --git a/test/swftests/ClassConstruction.as b/test/swftests/ClassConstruction.as deleted file mode 100644 index 436479f8f..000000000 --- a/test/swftests/ClassConstruction.as +++ /dev/null @@ -1,15 +0,0 @@ -// input: [] -// output: 0 - -package { -public class ClassConstruction { - public static function main():int{ - var f:Foo = new Foo(); - return 0; - } -} -} - -class Foo { - -} diff --git a/test/swftests/ConstArrayAccess.as b/test/swftests/ConstArrayAccess.as deleted file mode 100644 index 07dc3f460..000000000 --- a/test/swftests/ConstArrayAccess.as +++ /dev/null @@ -1,18 +0,0 @@ -// input: [] -// output: 4 - -package { -public class ConstArrayAccess { - private static const x:int = 2; - private static const ar:Array = ["42", "3411"]; - - public static function main():int{ - var c:ConstArrayAccess = new ConstArrayAccess(); - return c.f(); - } - - public function f(): int { - return ar[1].length; - } -} -} diff --git a/test/swftests/ConstantInt.as b/test/swftests/ConstantInt.as deleted file mode 100644 index e0bbb6166..000000000 --- a/test/swftests/ConstantInt.as +++ /dev/null @@ -1,12 +0,0 @@ -// input: [] -// output: 2 - -package { -public class ConstantInt { - private static const x:int = 2; - - public static function main():int{ - return x; - } -} -} diff --git a/test/swftests/DictCall.as b/test/swftests/DictCall.as deleted file mode 100644 index c2d174cc2..000000000 --- a/test/swftests/DictCall.as +++ /dev/null @@ -1,10 +0,0 @@ -// input: [{"x": 1, "y": 2}] -// output: 3 - -package { -public class DictCall { - public static function main(d:Object):int{ - return d.x + d.y; - } -} -} diff --git a/test/swftests/EqualsOperator.as b/test/swftests/EqualsOperator.as deleted file mode 100644 index 837a69a46..000000000 --- a/test/swftests/EqualsOperator.as +++ /dev/null @@ -1,10 +0,0 @@ -// input: [] -// output: false - -package { -public class EqualsOperator { - public static function main():Boolean{ - return 1 == 2; - } -} -} diff --git a/test/swftests/LocalVars.as b/test/swftests/LocalVars.as deleted file mode 100644 index b2911a9f3..000000000 --- a/test/swftests/LocalVars.as +++ /dev/null @@ -1,13 +0,0 @@ -// input: [1, 2] -// output: 3 - -package { -public class LocalVars { - public static function main(a:int, b:int):int{ - var c:int = a + b + b; - var d:int = c - b; - var e:int = d; - return e; - } -} -} diff --git a/test/swftests/MemberAssignment.as b/test/swftests/MemberAssignment.as deleted file mode 100644 index dcba5e3ff..000000000 --- a/test/swftests/MemberAssignment.as +++ /dev/null @@ -1,22 +0,0 @@ -// input: [1] -// output: 2 - -package { -public class MemberAssignment { - public var v:int; - - public function g():int { - return this.v; - } - - public function f(a:int):int{ - this.v = a; - return this.v + this.g(); - } - - public static function main(a:int): int { - var v:MemberAssignment = new MemberAssignment(); - return v.f(a); - } -} -} diff --git a/test/swftests/NeOperator.as b/test/swftests/NeOperator.as deleted file mode 100644 index 61dcbc4e9..000000000 --- a/test/swftests/NeOperator.as +++ /dev/null @@ -1,24 +0,0 @@ -// input: [] -// output: 123 - -package { -public class NeOperator { - public static function main(): int { - var res:int = 0; - if (1 != 2) { - res += 3; - } else { - res += 4; - } - if (2 != 2) { - res += 10; - } else { - res += 20; - } - if (9 == 9) { - res += 100; - } - return res; - } -} -} diff --git a/test/swftests/PrivateCall.as b/test/swftests/PrivateCall.as deleted file mode 100644 index f1c110a37..000000000 --- a/test/swftests/PrivateCall.as +++ /dev/null @@ -1,21 +0,0 @@ -// input: [] -// output: 9 - -package { -public class PrivateCall { - public static function main():int{ - var f:OtherClass = new OtherClass(); - return f.func(); - } -} -} - -class OtherClass { - private function pf():int { - return 9; - } - - public function func():int { - return this.pf(); - } -} diff --git a/test/swftests/PrivateVoidCall.as b/test/swftests/PrivateVoidCall.as deleted file mode 100644 index 2cc016797..000000000 --- a/test/swftests/PrivateVoidCall.as +++ /dev/null @@ -1,22 +0,0 @@ -// input: [] -// output: 9 - -package { -public class PrivateVoidCall { - public static function main():int{ - var f:OtherClass = new OtherClass(); - f.func(); - return 9; - } -} -} - -class OtherClass { - private function pf():void { - ; - } - - public function func():void { - this.pf(); - } -} diff --git a/test/swftests/StaticAssignment.as b/test/swftests/StaticAssignment.as deleted file mode 100644 index b061c219d..000000000 --- a/test/swftests/StaticAssignment.as +++ /dev/null @@ -1,13 +0,0 @@ -// input: [1] -// output: 1 - -package { -public class StaticAssignment { - public static var v:int; - - public static function main(a:int):int{ - v = a; - return v; - } -} -} diff --git a/test/swftests/StaticRetrieval.as b/test/swftests/StaticRetrieval.as deleted file mode 100644 index c8352d819..000000000 --- a/test/swftests/StaticRetrieval.as +++ /dev/null @@ -1,16 +0,0 @@ -// input: [] -// output: 1 - -package { -public class StaticRetrieval { - public static var v:int; - - public static function main():int{ - if (v) { - return 0; - } else { - return 1; - } - } -} -} diff --git a/test/swftests/StringBasics.as b/test/swftests/StringBasics.as deleted file mode 100644 index d27430b13..000000000 --- a/test/swftests/StringBasics.as +++ /dev/null @@ -1,11 +0,0 @@ -// input: [] -// output: 3 - -package { -public class StringBasics { - public static function main():int{ - var s:String = "abc"; - return s.length; - } -} -} diff --git a/test/swftests/StringCharCodeAt.as b/test/swftests/StringCharCodeAt.as deleted file mode 100644 index c20d74d65..000000000 --- a/test/swftests/StringCharCodeAt.as +++ /dev/null @@ -1,11 +0,0 @@ -// input: [] -// output: 9897 - -package { -public class StringCharCodeAt { - public static function main():int{ - var s:String = "abc"; - return s.charCodeAt(1) * 100 + s.charCodeAt(); - } -} -} diff --git a/test/swftests/StringConversion.as b/test/swftests/StringConversion.as deleted file mode 100644 index c976f5042..000000000 --- a/test/swftests/StringConversion.as +++ /dev/null @@ -1,11 +0,0 @@ -// input: [] -// output: 2 - -package { -public class StringConversion { - public static function main():int{ - var s:String = String(99); - return s.length; - } -} -} diff --git a/test/test_iqiyi_sdk_interpreter.py b/test/test_iqiyi_sdk_interpreter.py deleted file mode 100644 index 789059dbe..000000000 --- a/test/test_iqiyi_sdk_interpreter.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python - -from __future__ import unicode_literals - -# Allow direct execution -import os -import sys -import unittest -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - -from test.helper import FakeYDL -from youtube_dl.extractor import IqiyiIE - - -class IqiyiIEWithCredentials(IqiyiIE): - def _get_login_info(self): - return 'foo', 'bar' - - -class WarningLogger(object): - def __init__(self): - self.messages = [] - - def warning(self, msg): - self.messages.append(msg) - - def debug(self, msg): - pass - - def error(self, msg): - pass - - -class TestIqiyiSDKInterpreter(unittest.TestCase): - def test_iqiyi_sdk_interpreter(self): - ''' - Test the functionality of IqiyiSDKInterpreter by trying to log in - - If `sign` is incorrect, /validate call throws an HTTP 556 error - ''' - logger = WarningLogger() - ie = IqiyiIEWithCredentials(FakeYDL({'logger': logger})) - ie._login() - self.assertTrue('unable to log in:' in logger.messages[0]) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_swfinterp.py b/test/test_swfinterp.py deleted file mode 100644 index 9f18055e6..000000000 --- a/test/test_swfinterp.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python -from __future__ import unicode_literals - -# Allow direct execution -import os -import sys -import unittest -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - - -import errno -import io -import json -import re -import subprocess - -from youtube_dl.swfinterp import SWFInterpreter - - -TEST_DIR = os.path.join( - os.path.dirname(os.path.abspath(__file__)), 'swftests') - - -class TestSWFInterpreter(unittest.TestCase): - pass - - -def _make_testfunc(testfile): - m = re.match(r'^(.*)\.(as)$', testfile) - if not m: - return - test_id = m.group(1) - - def test_func(self): - as_file = os.path.join(TEST_DIR, testfile) - swf_file = os.path.join(TEST_DIR, test_id + '.swf') - if ((not os.path.exists(swf_file)) - or os.path.getmtime(swf_file) < os.path.getmtime(as_file)): - # Recompile - try: - subprocess.check_call([ - 'mxmlc', '-output', swf_file, - '-static-link-runtime-shared-libraries', as_file]) - except OSError as ose: - if ose.errno == errno.ENOENT: - print('mxmlc not found! Skipping test.') - return - raise - - with open(swf_file, 'rb') as swf_f: - swf_content = swf_f.read() - swfi = SWFInterpreter(swf_content) - - with io.open(as_file, 'r', encoding='utf-8') as as_f: - as_content = as_f.read() - - def _find_spec(key): - m = re.search( - r'(?m)^//\s*%s:\s*(.*?)\n' % re.escape(key), as_content) - if not m: - raise ValueError('Cannot find %s in %s' % (key, testfile)) - return json.loads(m.group(1)) - - input_args = _find_spec('input') - output = _find_spec('output') - - swf_class = swfi.extract_class(test_id) - func = swfi.extract_function(swf_class, 'main') - res = func(input_args) - self.assertEqual(res, output) - - test_func.__name__ = str('test_swf_' + test_id) - setattr(TestSWFInterpreter, test_func.__name__, test_func) - - -for testfile in os.listdir(TEST_DIR): - _make_testfunc(testfile) - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_update.py b/test/test_update.py deleted file mode 100644 index d9c71511d..000000000 --- a/test/test_update.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python - -from __future__ import unicode_literals - -# Allow direct execution -import os -import sys -import unittest -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - - -import json -from youtube_dl.update import rsa_verify - - -class TestUpdate(unittest.TestCase): - def test_rsa_verify(self): - UPDATES_RSA_KEY = (0x9d60ee4d8f805312fdb15a62f87b95bd66177b91df176765d13514a0f1754bcd2057295c5b6f1d35daa6742c3ffc9a82d3e118861c207995a8031e151d863c9927e304576bc80692bc8e094896fcf11b66f3e29e04e3a71e9a11558558acea1840aec37fc396fb6b65dc81a1c4144e03bd1c011de62e3f1357b327d08426fe93, 65537) - with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'versions.json'), 'rb') as f: - versions_info = f.read().decode() - versions_info = json.loads(versions_info) - signature = versions_info['signature'] - del versions_info['signature'] - self.assertTrue(rsa_verify( - json.dumps(versions_info, sort_keys=True).encode('utf-8'), - signature, UPDATES_RSA_KEY)) - - -if __name__ == '__main__': - unittest.main() diff --git a/test/versions.json b/test/versions.json deleted file mode 100644 index 6cccc2259..000000000 --- a/test/versions.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "latest": "2013.01.06", - "signature": "72158cdba391628569ffdbea259afbcf279bbe3d8aeb7492690735dc1cfa6afa754f55c61196f3871d429599ab22f2667f1fec98865527b32632e7f4b3675a7ef0f0fbe084d359256ae4bba68f0d33854e531a70754712f244be71d4b92e664302aa99653ee4df19800d955b6c4149cd2b3f24288d6e4b40b16126e01f4c8ce6", - "versions": { - "2013.01.02": { - "bin": [ - "http://youtube-dl.org/downloads/2013.01.02/youtube-dl", - "f5b502f8aaa77675c4884938b1e4871ebca2611813a0c0e74f60c0fbd6dcca6b" - ], - "exe": [ - "http://youtube-dl.org/downloads/2013.01.02/youtube-dl.exe", - "75fa89d2ce297d102ff27675aa9d92545bbc91013f52ec52868c069f4f9f0422" - ], - "tar": [ - "http://youtube-dl.org/downloads/2013.01.02/youtube-dl-2013.01.02.tar.gz", - "6a66d022ac8e1c13da284036288a133ec8dba003b7bd3a5179d0c0daca8c8196" - ] - }, - "2013.01.06": { - "bin": [ - "http://youtube-dl.org/downloads/2013.01.06/youtube-dl", - "64b6ed8865735c6302e836d4d832577321b4519aa02640dc508580c1ee824049" - ], - "exe": [ - "http://youtube-dl.org/downloads/2013.01.06/youtube-dl.exe", - "58609baf91e4389d36e3ba586e21dab882daaaee537e4448b1265392ae86ff84" - ], - "tar": [ - "http://youtube-dl.org/downloads/2013.01.06/youtube-dl-2013.01.06.tar.gz", - "fe77ab20a95d980ed17a659aa67e371fdd4d656d19c4c7950e7b720b0c2f1a86" - ] - } - } -}
\ No newline at end of file |