summaryrefslogtreecommitdiffstats
path: root/libacc/tests
diff options
context:
space:
mode:
authorJack Palevich <jackpal@google.com>2009-07-31 14:01:37 -0700
committerJack Palevich <jackpal@google.com>2009-07-31 14:01:37 -0700
commit43aaee31b9cedc059213396f1e7aa420ace0c797 (patch)
tree9ead26ed3294192dfe5dfd3ad91f1044cef44743 /libacc/tests
parent0c01774816245e59aac7f2109c28523eeb6492ac (diff)
downloadsystem_core-43aaee31b9cedc059213396f1e7aa420ace0c797.zip
system_core-43aaee31b9cedc059213396f1e7aa420ace0c797.tar.gz
system_core-43aaee31b9cedc059213396f1e7aa420ace0c797.tar.bz2
Support the comma operator.
Diffstat (limited to 'libacc/tests')
-rw-r--r--libacc/tests/data/comma.c35
-rw-r--r--libacc/tests/test.py10
2 files changed, 45 insertions, 0 deletions
diff --git a/libacc/tests/data/comma.c b/libacc/tests/data/comma.c
new file mode 100644
index 0000000..496944c
--- /dev/null
+++ b/libacc/tests/data/comma.c
@@ -0,0 +1,35 @@
+int testReturn() {
+ return 10, 20, 30;
+}
+
+int testArg(int a) {
+ return a;
+}
+
+void testComma() {
+ int a;
+ 0, a = 10,20;
+ printf("statement: %d\n", a);
+ a = 1;
+ if (a = 0, 1) {
+ printf("if: a = %d\n", a);
+ }
+ int b = 0;
+ a = 10;
+ while(b++,a--) {}
+ printf("while: b = %d\n", b);
+ b = 0;
+ for(b++,a = 0;b++, a < 10; b++, a++) {}
+ printf("for: b = %d\n", b);
+ b = testReturn();
+ printf("return: %d\n", b);
+ b = testArg((a,12));
+ printf("arg: %d\n", b);
+}
+
+
+
+int main() {
+ testComma();
+ return 0;
+}
diff --git a/libacc/tests/test.py b/libacc/tests/test.py
index 239bb9b..5f9a71e 100644
--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -354,6 +354,16 @@ result: 0""", """2 *= 5 10
16|= 1 17
""")
+ def testcomma(self):
+ self.compileCheck(["-R", "data/comma.c"], """Executing compiled code:
+result: 0""", """statement: 10
+if: a = 0
+while: b = 11
+for: b = 22
+return: 30
+arg: 12
+""")
+
if __name__ == '__main__':
if not outputCanRun():
print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable."