From 1e608ca59f15227c31f0433e41d67c4efe347bd9 Mon Sep 17 00:00:00 2001 From: Yann Weber Date: Sat, 25 Jan 2020 15:57:05 +0100 Subject: [PATCH] New long compilation tests --- tests/tests_rpn.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/tests_rpn.py b/tests/tests_rpn.py index 92e1a0a..5c65c5f 100755 --- a/tests/tests_rpn.py +++ b/tests/tests_rpn.py @@ -141,10 +141,23 @@ class TestRpnCompile(unittest.TestCase): def test_long_code(self): """ Compile long expressions """ - for i in range(64,256,2): - for j in range(256,4): - exprs = ' '.join(['+' for _ in range(i)]) - expr = pyrpn.RPNExpr(exprs, j) + for i in range(0x100,0x10000,0x500): + with self.subTest('Testing expression with %X ops' % i): + for argc in range(1,32, 8): + args = [random.randint(0,IMAX) for _ in range(argc)] + expr = pyrpn.RPNExpr(pyrpn.random_expr(argc, i), argc) + del(expr) + + def test_very_long(self): + """ Compile a very long expression """ + argc = 4 + codelen = 0x500000 + import time + for i in range(3): + args = [random.randint(0,IMAX) for _ in range(argc)] + expr_str = pyrpn.random_expr(argc, codelen) + expr = pyrpn.RPNExpr(expr_str, argc) + del(expr) def test_pickling(self): """ Pickle & unpickle tests """