[hackers] [scc] Add tests for integer operations || Roberto E. Vargas Caballero
commit 4cd3b53a109cfc9c02c2ff15a8f60cb658a4b574
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Aug 14 19:01:04 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Aug 14 19:01:04 2015 +0200
Add tests for integer operations
diff --git a/cc1/tests/test004.c b/cc1/tests/test004.c
new file mode 100644
index 0000000..0698a52
--- /dev/null
+++ b/cc1/tests/test004.c
_AT_@ -0,0 +1,55 @@
+/*
+name: TEST004
+description: Test integer operations
+output:
+F1
+X1 F1 main
+G1 F1 main {
+-
+A2 I x
+ A2 #I0 :I
+ A2 A2 #I2 +I :I
+ A2 A2 #I1 -I :I
+ A2 A2 #I6 *I :I
+ A2 A2 #I2 /I :I
+ A2 A2 #I2 %I :I
+ A2 A2 #I2 lI :I
+ A2 A2 #I1 rI :I
+ A2 A2 #IFF |I :I
+ A2 A2 #I3 &I :I
+ A2 A2 #I1 ^I :I
+ A2 A2 A2 #I1 >I #I1 #I0 ?I +I :I
+ A2 A2 A2 #I3 <I #I1 #I0 ?I +I :I
+ A2 A2 A2 #I1 >I #I1 #I0 ?I +I :I
+ A2 A2 A2 #I4 <I #I1 #I0 ?I +I :I
+ j L0 A2 #I4 =I
+ yI #I1
+L0
+ yI #I0
+}
+*/
+
+int
+main()
+{
+ int x;
+
+ x = 0;
+ x = x + 2; // 2
+ x = x - 1; // 1
+ x = x * 6; // 6
+ x = x / 2; // 3
+ x = x % 2; // 1
+ x = x << 2; // 4
+ x = x >> 1; // 2
+ x = x | 255; // 255
+ x = x & 3; // 3
+ x = x ^ 1; // 2
+ x = x + (x > 1); // 2
+ x = x + (x < 3); // 2
+ x = x + (x > 1); // 3
+ x = x + (x < 4); // 4
+ if(x != 4)
+ return 1;
+ return 0;
+}
\ No newline at end of file
diff --git a/cc1/tests/test005.c b/cc1/tests/test005.c
new file mode 100644
index 0000000..762f051
--- /dev/null
+++ b/cc1/tests/test005.c
_AT_@ -0,0 +1,36 @@
+/*
+name: TEST005
+description: Test unary integer operations
+output:
+F1
+X1 F1 main
+G1 F1 main {
+-
+A2 I x
+ A2 #I3 :I
+ A2 A2 #I0 =I #I1 #I0 ?I :I
+ A2 A2 #I0 =I #I1 #I0 ?I :I
+ A2 A2 ~I :I
+ A2 A2 _I :I
+ j L0 A2 #I2 =I
+ yI #I1
+L0
+ yI #I0
+}
+*/
+
+
+int
+main()
+{
+ int x;
+
+ x = 3;
+ x = !x; // 0
+ x = !x; // 1
+ x = ~x; // -1
+ x = -x; // 2
+ if(x != 2)
+ return 1;
+ return 0;
+}
Received on Fri Aug 14 2015 - 19:03:56 CEST
This archive was generated by hypermail 2.3.0
: Fri Aug 14 2015 - 19:12:14 CEST