aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py
diff options
context:
space:
mode:
authoralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
committeralexv-smirnov <alex@ydb.tech>2023-06-13 11:05:01 +0300
commitbf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch)
tree1d1df72c0541a59a81439842f46d95396d3e7189 /contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py
parent8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff)
downloadydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz
add ymake export to ydb
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py')
-rw-r--r--contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py b/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py
new file mode 100644
index 0000000000..443551ab88
--- /dev/null
+++ b/contrib/tools/cython/Cython/Compiler/Tests/TestFlowControl.py
@@ -0,0 +1,68 @@
+
+from __future__ import absolute_import
+
+from copy import deepcopy
+from unittest import TestCase
+
+from Cython.Compiler.FlowControl import (
+ NameAssignment, StaticAssignment, Argument, NameDeletion)
+
+
+class FakeType(object):
+ is_pyobject = True
+
+
+class FakeNode(object):
+ pos = ('filename.pyx', 1, 2)
+ cf_state = None
+ type = FakeType()
+
+ def infer_type(self, scope):
+ return self.type
+
+
+class FakeEntry(object):
+ type = FakeType()
+
+
+class TestGraph(TestCase):
+ def test_deepcopy(self):
+ lhs, rhs = FakeNode(), FakeNode()
+ entry = FakeEntry()
+ entry.pos = lhs.pos
+
+ name_ass = NameAssignment(lhs, rhs, entry)
+ ass = deepcopy(name_ass)
+ self.assertTrue(ass.lhs)
+ self.assertTrue(ass.rhs)
+ self.assertTrue(ass.entry)
+ self.assertEqual(ass.pos, name_ass.pos)
+ self.assertFalse(ass.is_arg)
+ self.assertFalse(ass.is_deletion)
+
+ static_ass = StaticAssignment(entry)
+ ass = deepcopy(static_ass)
+ self.assertTrue(ass.lhs)
+ self.assertTrue(ass.rhs)
+ self.assertTrue(ass.entry)
+ self.assertEqual(ass.pos, static_ass.pos)
+ self.assertFalse(ass.is_arg)
+ self.assertFalse(ass.is_deletion)
+
+ arg_ass = Argument(lhs, rhs, entry)
+ ass = deepcopy(arg_ass)
+ self.assertTrue(ass.lhs)
+ self.assertTrue(ass.rhs)
+ self.assertTrue(ass.entry)
+ self.assertEqual(ass.pos, arg_ass.pos)
+ self.assertTrue(ass.is_arg)
+ self.assertFalse(ass.is_deletion)
+
+ name_del = NameDeletion(lhs, entry)
+ ass = deepcopy(name_del)
+ self.assertTrue(ass.lhs)
+ self.assertTrue(ass.rhs)
+ self.assertTrue(ass.entry)
+ self.assertEqual(ass.pos, name_del.pos)
+ self.assertFalse(ass.is_arg)
+ self.assertTrue(ass.is_deletion)