aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_assignment_operators.sh
blob: 9b3a33ee7b25c1ded64a90e0322122da0635938f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
test_exit_code 0 <<'EOF'
#include "../../helpers.h"

int main() {
    int i = 0;
    for (; i < 5; i += 1) {}
    ASSERT_EQ(5, i);

    for (i = 5; i >= 0; i -= 1);
    ASSERT_EQ(-1, i);

    int x = 123;
    x *= 456;
    ASSERT_EQ(56088, x);

    int y = 120;
    y /= 5;
    ASSERT_EQ(24, y);

    int z = 17;
    z %= 7;
    ASSERT_EQ(3, z);

    int a = 0x05;
    a |= 0x0A;
    ASSERT_EQ(0x0F, a);

    int b = 0x0F;
    b &= 0x0A;
    ASSERT_EQ(0x0A, b);

    int c = 7;
    c |= 8;
    ASSERT_EQ(15, c);

    int d = 15;
    d &= 6;
    ASSERT_EQ(6, d);

    int e = 0x0F;
    e ^= 0x05;
    ASSERT_EQ(0x0A, e);

    int f = 3;
    f <<= 2;
    ASSERT_EQ(12, f);

    int g = 16;
    g >>= 2;
    ASSERT_EQ(4, g);

    int h = -16;
    h >>= 2;
    ASSERT_EQ(-4, h);

    int j = 1;
    j <<= 4;
    ASSERT_EQ(16, j);

    int k = 64;
    k >>= 3;
    ASSERT_EQ(8, k);
}
EOF