about summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/expression/parser.py16
-rwxr-xr-xtest/test_all.py1
2 files changed, 17 insertions, 0 deletions
diff --git a/test/expression/parser.py b/test/expression/parser.py
new file mode 100644
index 00000000..9c01c8a1
--- /dev/null
+++ b/test/expression/parser.py
@@ -0,0 +1,16 @@
+from miasm2.expression.parser import str_to_expr
+from miasm2.expression.expression import ExprInt, ExprId, ExprSlice, ExprMem, \
+    ExprCond, ExprCompose, ExprOp, ExprAff
+
+for expr_test in [ExprInt(0x12, 32),
+                  ExprId('test', 32),
+                  ExprSlice(ExprInt(0x10, 32), 0, 8),
+                  ExprMem(ExprInt(0x10, 32), 32),
+                  ExprCond(ExprInt(0x10, 32), ExprInt(0x11, 32), ExprInt(0x12, 32)),
+                  ExprCompose(ExprInt(0x10, 16), ExprInt(0x11, 8), ExprInt(0x12, 8)),
+                  ExprInt(0x11, 8) + ExprInt(0x12, 8),
+                  ExprAff(ExprId('EAX', 32),  ExprInt(0x12, 32)),
+                  ]:
+
+    print 'Test: %s' % expr_test
+    assert str_to_expr(repr(expr_test)) == expr_test
diff --git a/test/test_all.py b/test/test_all.py
index 41954ff1..b70afa9a 100755
--- a/test/test_all.py
+++ b/test/test_all.py
@@ -241,6 +241,7 @@ for script in ["modint.py",
                "simplifications.py",
                "expression_helper.py",
                "expr_pickle.py",
+               "parser.py",
                ]:
     testset += RegressionTest([script], base_dir="expression")