]> pd.if.org Git - lice/blobdiff - tests/compound.c
autocommit for files dated 2014-11-17 20:13:34
[lice] / tests / compound.c
diff --git a/tests/compound.c b/tests/compound.c
new file mode 100644 (file)
index 0000000..9fa7099
--- /dev/null
@@ -0,0 +1,19 @@
+// compound assignment
+
+int main(void) {
+    int a = 5;
+    expecti((a += 5), 10);
+    expecti((a -= 5), 5);
+    expecti((a *= 5), 25);
+    expecti((a /= 5), 5);
+    expecti((a %= 3), 2);
+
+    int b = 14;
+    expecti((b &= 7), 6);
+    expecti((b |= 8), 14);
+    expecti((b ^= 3), 13);
+    expecti((b <<= 2), 52);
+    expecti((b >>= 2), 13);
+
+    return 0;
+}