* support/regression/tests/arithcsi.c: added regression test
authorborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 20 Jan 2008 00:35:31 +0000 (00:35 +0000)
committerborutr <borutr@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 20 Jan 2008 00:35:31 +0000 (00:35 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4997 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/regression/tests/arithcse.c [new file with mode: 0644]

diff --git a/support/regression/tests/arithcse.c b/support/regression/tests/arithcse.c
new file mode 100644 (file)
index 0000000..f63a74f
--- /dev/null
@@ -0,0 +1,48 @@
+/* Test arithmetic CSE with /+-*
+
+    type: char, short, long
+    attr: volatile,
+ */
+
+void
+test_arithCse(void)
+{
+  (attr) {type} res;
+  {attr} {type} i = 10;
+
+  /* addition with 0 */
+  res = i + 0;
+  ASSERT (i == 10);
+
+  res = 0 + i;
+  ASSERT (res == 10);
+
+  /* multiplication with 1 */
+  res = 1 * i;
+  ASSERT (res == 10);
+
+  res = i * 1;
+  ASSERT (res == 10);
+
+  /* multiplication with 0 */
+  res = 0 * i;
+  ASSERT (res == 0);
+
+  res = i * 0;
+  ASSERT (res == 0);
+
+  /* multiplication with -1 */
+  res = -1 * i;
+  ASSERT (res == -i);
+
+  res = i * -1;
+  ASSERT (res == -i);
+
+  /* division by 1 */
+  res = i / 1;
+  ASSERT (res == i);
+
+  /* division by -1 */
+  res = i / -1;
+  ASSERT (res == -i);
+}
\ No newline at end of file