summaryrefslogtreecommitdiff
path: root/Lib/test/test_dis.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-09-08 20:50:03 -0700
committerYury Selivanov <yury@magic.io>2016-09-08 20:50:03 -0700
commitb164476aaf77ceffac36ddbbdc7f4df90fbfebd3 (patch)
tree0a744472fe547a36f970c59528e48aebd01de75e /Lib/test/test_dis.py
parent61f296e12ff25b48169250d726b92d589e0221af (diff)
downloadcpython-b164476aaf77ceffac36ddbbdc7f4df90fbfebd3.tar.gz
Issue #27985: Implement PEP 526 -- Syntax for Variable Annotations.
Patch by Ivan Levkivskyi.
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r--Lib/test/test_dis.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 09e68ce70a..60810732c5 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -207,6 +207,38 @@ dis_simple_stmt_str = """\
10 RETURN_VALUE
"""
+annot_stmt_str = """\
+
+x: int = 1
+y: fun(1)
+lst[fun(0)]: int = 1
+"""
+# leading newline is for a reason (tests lineno)
+
+dis_annot_stmt_str = """\
+ 2 0 SETUP_ANNOTATIONS
+ 2 LOAD_CONST 0 (1)
+ 4 STORE_NAME 0 (x)
+ 6 LOAD_NAME 1 (int)
+ 8 STORE_ANNOTATION 0 (x)
+
+ 3 10 LOAD_NAME 2 (fun)
+ 12 LOAD_CONST 0 (1)
+ 14 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
+ 16 STORE_ANNOTATION 3 (y)
+
+ 4 18 LOAD_CONST 0 (1)
+ 20 LOAD_NAME 4 (lst)
+ 22 LOAD_NAME 2 (fun)
+ 24 LOAD_CONST 1 (0)
+ 26 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
+ 28 STORE_SUBSCR
+ 30 LOAD_NAME 1 (int)
+ 32 POP_TOP
+ 34 LOAD_CONST 2 (None)
+ 36 RETURN_VALUE
+"""
+
compound_stmt_str = """\
x = 0
while 1:
@@ -345,6 +377,7 @@ class DisTests(unittest.TestCase):
def test_disassemble_str(self):
self.do_disassembly_test(expr_str, dis_expr_str)
self.do_disassembly_test(simple_stmt_str, dis_simple_stmt_str)
+ self.do_disassembly_test(annot_stmt_str, dis_annot_stmt_str)
self.do_disassembly_test(compound_stmt_str, dis_compound_stmt_str)
def test_disassemble_bytes(self):