]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_dis.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_dis.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_dis.py b/AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_dis.py
deleted file mode 100644 (file)
index 93370d4..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-# Minimal tests for dis module\r
-\r
-from test.test_support import run_unittest\r
-import unittest\r
-import sys\r
-import dis\r
-import StringIO\r
-\r
-\r
-def _f(a):\r
-    print a\r
-    return 1\r
-\r
-dis_f = """\\r
- %-4d         0 LOAD_FAST                0 (a)\r
-              3 PRINT_ITEM\r
-              4 PRINT_NEWLINE\r
-\r
- %-4d         5 LOAD_CONST               1 (1)\r
-              8 RETURN_VALUE\r
-"""%(_f.func_code.co_firstlineno + 1,\r
-     _f.func_code.co_firstlineno + 2)\r
-\r
-\r
-def bug708901():\r
-    for res in range(1,\r
-                     10):\r
-        pass\r
-\r
-dis_bug708901 = """\\r
- %-4d         0 SETUP_LOOP              23 (to 26)\r
-              3 LOAD_GLOBAL              0 (range)\r
-              6 LOAD_CONST               1 (1)\r
-\r
- %-4d         9 LOAD_CONST               2 (10)\r
-             12 CALL_FUNCTION            2\r
-             15 GET_ITER\r
-        >>   16 FOR_ITER                 6 (to 25)\r
-             19 STORE_FAST               0 (res)\r
-\r
- %-4d        22 JUMP_ABSOLUTE           16\r
-        >>   25 POP_BLOCK\r
-        >>   26 LOAD_CONST               0 (None)\r
-             29 RETURN_VALUE\r
-"""%(bug708901.func_code.co_firstlineno + 1,\r
-     bug708901.func_code.co_firstlineno + 2,\r
-     bug708901.func_code.co_firstlineno + 3)\r
-\r
-\r
-def bug1333982(x=[]):\r
-    assert 0, ([s for s in x] +\r
-              1)\r
-    pass\r
-\r
-dis_bug1333982 = """\\r
- %-4d         0 LOAD_CONST               1 (0)\r
-              3 POP_JUMP_IF_TRUE        38\r
-              6 LOAD_GLOBAL              0 (AssertionError)\r
-              9 BUILD_LIST               0\r
-             12 LOAD_FAST                0 (x)\r
-             15 GET_ITER\r
-        >>   16 FOR_ITER                12 (to 31)\r
-             19 STORE_FAST               1 (s)\r
-             22 LOAD_FAST                1 (s)\r
-             25 LIST_APPEND              2\r
-             28 JUMP_ABSOLUTE           16\r
-\r
- %-4d   >>   31 LOAD_CONST               2 (1)\r
-             34 BINARY_ADD\r
-             35 RAISE_VARARGS            2\r
-\r
- %-4d   >>   38 LOAD_CONST               0 (None)\r
-             41 RETURN_VALUE\r
-"""%(bug1333982.func_code.co_firstlineno + 1,\r
-     bug1333982.func_code.co_firstlineno + 2,\r
-     bug1333982.func_code.co_firstlineno + 3)\r
-\r
-_BIG_LINENO_FORMAT = """\\r
-%3d           0 LOAD_GLOBAL              0 (spam)\r
-              3 POP_TOP\r
-              4 LOAD_CONST               0 (None)\r
-              7 RETURN_VALUE\r
-"""\r
-\r
-class DisTests(unittest.TestCase):\r
-    def do_disassembly_test(self, func, expected):\r
-        s = StringIO.StringIO()\r
-        save_stdout = sys.stdout\r
-        sys.stdout = s\r
-        dis.dis(func)\r
-        sys.stdout = save_stdout\r
-        got = s.getvalue()\r
-        # Trim trailing blanks (if any).\r
-        lines = got.split('\n')\r
-        lines = [line.rstrip() for line in lines]\r
-        expected = expected.split("\n")\r
-        import difflib\r
-        if expected != lines:\r
-            self.fail(\r
-                "events did not match expectation:\n" +\r
-                "\n".join(difflib.ndiff(expected,\r
-                                        lines)))\r
-\r
-    def test_opmap(self):\r
-        self.assertEqual(dis.opmap["STOP_CODE"], 0)\r
-        self.assertIn(dis.opmap["LOAD_CONST"], dis.hasconst)\r
-        self.assertIn(dis.opmap["STORE_NAME"], dis.hasname)\r
-\r
-    def test_opname(self):\r
-        self.assertEqual(dis.opname[dis.opmap["LOAD_FAST"]], "LOAD_FAST")\r
-\r
-    def test_boundaries(self):\r
-        self.assertEqual(dis.opmap["EXTENDED_ARG"], dis.EXTENDED_ARG)\r
-        self.assertEqual(dis.opmap["STORE_NAME"], dis.HAVE_ARGUMENT)\r
-\r
-    def test_dis(self):\r
-        self.do_disassembly_test(_f, dis_f)\r
-\r
-    def test_bug_708901(self):\r
-        self.do_disassembly_test(bug708901, dis_bug708901)\r
-\r
-    def test_bug_1333982(self):\r
-        # This one is checking bytecodes generated for an `assert` statement,\r
-        # so fails if the tests are run with -O.  Skip this test then.\r
-        if __debug__:\r
-            self.do_disassembly_test(bug1333982, dis_bug1333982)\r
-\r
-    def test_big_linenos(self):\r
-        def func(count):\r
-            namespace = {}\r
-            func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"])\r
-            exec func in namespace\r
-            return namespace['foo']\r
-\r
-        # Test all small ranges\r
-        for i in xrange(1, 300):\r
-            expected = _BIG_LINENO_FORMAT % (i + 2)\r
-            self.do_disassembly_test(func(i), expected)\r
-\r
-        # Test some larger ranges too\r
-        for i in xrange(300, 5000, 10):\r
-            expected = _BIG_LINENO_FORMAT % (i + 2)\r
-            self.do_disassembly_test(func(i), expected)\r
-\r
-def test_main():\r
-    run_unittest(DisTests)\r
-\r
-\r
-if __name__ == "__main__":\r
-    test_main()\r