Skip to content

Commit cf96890

Browse files
committed
Added test case for simple C binary operators
1 parent 2966e9c commit cf96890

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

Diff for: tests/success/c_math/_.adept

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
pragma => adept("3.0")
3+
4+
#[foreign]
5+
func printf(format ptr#char, ...) int
6+
7+
func main {
8+
printf(c"3 + 4 = %d\n", ADD_RESULT)
9+
printf(c"3 - 4 = %d\n", SUBTRACT_RESULT)
10+
printf(c"3 * 4 = %d\n", MULTIPLY_RESULT)
11+
printf(c"21 / 4 = %d\n", DIVIDE_RESULT)
12+
printf(c"21 %% 4 = %d\n", MODULUS_RESULT)
13+
printf(c"21 || 0 = %d\n", OR_RESULT)
14+
printf(c"21 && 0 = %d\n", AND_RESULT)
15+
printf(c"21 | 2 = %d\n", BITWISE_OR_RESULT)
16+
printf(c"21 & 2 = %d\n", BITWISE_AND_RESULT)
17+
printf(c"21 ^ 2 = %d\n", BITWISE_XOR_RESULT)
18+
printf(c"21 == 2 = %d\n", EQ_RESULT)
19+
printf(c"21 != 2 = %d\n", NEQ_RESULT)
20+
printf(c"21 < 2 = %d\n", LT_RESULT)
21+
printf(c"21 > 2 = %d\n", GT_RESULT)
22+
printf(c"21 <= 2 = %d\n", LTE_RESULT)
23+
printf(c"21 >= 2 = %d\n", GTE_RESULT)
24+
printf(c"21 << 2 = %d\n", LSHIFT_RESULT)
25+
printf(c"21 >> 2 = %d\n", RSHIFT_RESULT)
26+
}
27+

Diff for: tests/success/c_math/result.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
#ifndef _C_ADD_RESULT_H_INCLUDED
3+
#define _C_ADD_RESULT_H_INCLUDED
4+
5+
#define ADD_RESULT 3 + 4
6+
#define SUBTRACT_RESULT 3 - 4
7+
#define MULTIPLY_RESULT 3 * 4
8+
#define DIVIDE_RESULT 21 / 4
9+
#define MODULUS_RESULT 21 % 4
10+
#define OR_RESULT 21 || 0
11+
#define AND_RESULT 21 && 0
12+
#define BITWISE_OR_RESULT 21 | 2
13+
#define BITWISE_AND_RESULT 21 & 2
14+
#define BITWISE_XOR_RESULT 21 ^ 2
15+
#define EQ_RESULT 21 == 2
16+
#define NEQ_RESULT 21 != 2
17+
#define LT_RESULT 21 < 2
18+
#define GT_RESULT 21 > 2
19+
#define LTE_RESULT 21 <= 2
20+
#define GTE_RESULT 21 >= 2
21+
#define LSHIFT_RESULT 21 << 2
22+
#define RSHIFT_RESULT 21 >> 2
23+
24+
#endif // _C_ADD_RESULT_H_INCLUDED
25+

0 commit comments

Comments
 (0)