about summary refs log tree commit diff stats
path: root/test/expression/simplifications.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2015-02-13 13:21:28 +0100
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2015-02-13 13:21:28 +0100
commitd58c585396324bb8e6c7f403ef4496320a44a7a6 (patch)
treeb068ca4abb2552c54880ea5515c93553c3cb4265 /test/expression/simplifications.py
parent4a10bea8602b410ed67b3c812fc505fdfdeba8ac (diff)
downloadmiasm-d58c585396324bb8e6c7f403ef4496320a44a7a6.tar.gz
miasm-d58c585396324bb8e6c7f403ef4496320a44a7a6.zip
Test: add regression test for simplification << >>
Diffstat (limited to 'test/expression/simplifications.py')
-rw-r--r--test/expression/simplifications.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/expression/simplifications.py b/test/expression/simplifications.py
index 0f217c72..b6d7e462 100644
--- a/test/expression/simplifications.py
+++ b/test/expression/simplifications.py
@@ -157,6 +157,39 @@ to_test = [(ExprInt32(1) - ExprInt32(1), ExprInt32(0)),
      ExprInt_fromsize(a.size, -1)),
     (ExprOp('-', ExprInt8(1), ExprInt8(0)),
      ExprInt8(1)),
+
+    (ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)]) << ExprInt64(0x20),
+     ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)])),
+    (ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)]) << ExprInt64(0x10),
+     ExprCompose([(ExprInt16(0), 0, 16), (a, 16, 48), (ExprInt16(0), 48, 64)])),
+    (ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)]) << ExprInt64(0x30),
+     ExprCompose([(ExprInt_fromsize(48, 0), 0, 48), (a[:0x10], 48, 64)])),
+    (ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)]) << ExprInt64(0x11),
+     ExprCompose([(ExprInt_fromsize(0x11, 0), 0, 0x11), (a, 0x11, 0x31), (ExprInt_fromsize(0xF, 0), 0x31, 0x40)])),
+    (ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)]) << ExprInt64(0x40),
+     ExprInt64(0)),
+    (ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)]) << ExprInt64(0x50),
+     ExprInt64(0)),
+
+    (ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)]) >> ExprInt64(0x20),
+     ExprCompose([(a, 0, 32), (ExprInt32(0), 32, 64)])),
+    (ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)]) >> ExprInt64(0x10),
+     ExprCompose([(ExprInt16(0), 0, 16), (a, 16, 48), (ExprInt16(0), 48, 64)])),
+    (ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)]) >> ExprInt64(0x30),
+     ExprCompose([(a[0x10:], 0, 16), (ExprInt_fromsize(48, 0), 16, 64)])),
+    (ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)]) >> ExprInt64(0x11),
+     ExprCompose([(ExprInt_fromsize(0xf, 0), 0, 0xf), (a, 0xf, 0x2f), (ExprInt_fromsize(0x11, 0), 0x2f, 0x40)])),
+    (ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)]) >> ExprInt64(0x40),
+     ExprInt64(0)),
+    (ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)]) >> ExprInt64(0x50),
+     ExprInt64(0)),
+
+
+    (ExprCompose([(a, 0, 32), (b, 32, 64)]) << ExprInt64(0x20),
+     ExprCompose([(ExprInt32(0), 0, 32), (a, 32, 64)])),
+    (ExprCompose([(a, 0, 32), (b, 32, 64)]) << ExprInt64(0x10),
+     ExprCompose([(ExprInt16(0), 0, 16), (a, 16, 48), (b[:16], 48, 64)])),
+
 ]
 
 for e, e_check in to_test[:]: