smarter and error test
This commit is contained in:
parent
bf7f456967
commit
49ed7c5df5
37 changed files with 83 additions and 36 deletions
16
test/op/binary.c
Normal file
16
test/op/binary.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int main() {
|
||||
int a = 5;
|
||||
int b = 4;
|
||||
printf("%d+%d=%d\n", a, b, a + b);
|
||||
printf("%d-%d=%d\n", a, b, a - b);
|
||||
printf("%d*%d=%d\n", a, b, a * b);
|
||||
printf("%d/%d=%d\n", a, b, a / b);
|
||||
printf("%d%%%d=%d\n", a, b, a % b);
|
||||
printf("%d&%d=%d\n", a, b, a & b);
|
||||
printf("%d|%d=%d\n", a, b, a | b);
|
||||
printf("%d^%d=%d\n", a, b, a ^ b);
|
||||
printf("%d<<%d=%d\n", a, b, a << b);
|
||||
printf("%d>>%d=%d\n", a, b, a >> b);
|
||||
}
|
11
test/op/binary.out
Normal file
11
test/op/binary.out
Normal file
|
@ -0,0 +1,11 @@
|
|||
5+4=9
|
||||
5-4=1
|
||||
5*4=20
|
||||
5/4=1
|
||||
5%4=1
|
||||
5&4=4
|
||||
5|4=5
|
||||
5^4=1
|
||||
5<<4=80
|
||||
5>>4=0
|
||||
0
|
14
test/op/inc.c
Normal file
14
test/op/inc.c
Normal file
|
@ -0,0 +1,14 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int main() {
|
||||
int a = 4;
|
||||
printf("a = %d\n", a);
|
||||
printf("a++ = %d\n", a++);
|
||||
printf("a = %d\n", a);
|
||||
printf("++a = %d\n", ++a);
|
||||
printf("a = %d\n", a);
|
||||
printf("a-- = %d\n", a--);
|
||||
printf("a = %d\n", a);
|
||||
printf("--a = %d\n", --a);
|
||||
printf("a = %d\n", a);
|
||||
}
|
10
test/op/inc.out
Normal file
10
test/op/inc.out
Normal file
|
@ -0,0 +1,10 @@
|
|||
a = 4
|
||||
a++ = 4
|
||||
a = 5
|
||||
++a = 6
|
||||
a = 6
|
||||
a-- = 6
|
||||
a = 5
|
||||
--a = 4
|
||||
a = 4
|
||||
0
|
17
test/op/short.c
Normal file
17
test/op/short.c
Normal file
|
@ -0,0 +1,17 @@
|
|||
int printf(char* format, ...);
|
||||
|
||||
int f(int i) {
|
||||
printf("f(%d)\n", i);
|
||||
return i % 2;
|
||||
}
|
||||
|
||||
int main() {
|
||||
1 && f(1);
|
||||
0 && f(2);
|
||||
1 || f(3);
|
||||
0 || f(4);
|
||||
1 ? f(5) : f(6);
|
||||
0 ? f(7) : f(8);
|
||||
1 && f(9) || f(10);
|
||||
0 && f(11) || f(12);
|
||||
}
|
0
test/op/short.in
Normal file
0
test/op/short.in
Normal file
7
test/op/short.out
Normal file
7
test/op/short.out
Normal file
|
@ -0,0 +1,7 @@
|
|||
f(1)
|
||||
f(4)
|
||||
f(5)
|
||||
f(8)
|
||||
f(9)
|
||||
f(12)
|
||||
0
|
Loading…
Add table
Add a link
Reference in a new issue