-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
guiquanz
committed
Mar 17, 2016
1 parent
a2e4a89
commit 016d55f
Showing
57 changed files
with
4,048 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test assignment | ||
--- src | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int a; | ||
a = 42; | ||
printf("%d\n", a); | ||
int b = 64; | ||
printf("%d\n", b); | ||
int c = 12, d = 34; | ||
printf("%d, %d\n", c, d); | ||
return 0; | ||
} | ||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : | ||
--- args | ||
--- out | ||
42 | ||
64 | ||
12, 34 | ||
--- err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test comment | ||
--- src | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
printf("Hello\n"); | ||
printf("Hello\n"); /* this is a comment */ printf("Hello\n"); | ||
printf("Hello\n"); | ||
// this is also a comment sayhello(); | ||
printf("Hello\n"); | ||
return 0; | ||
} | ||
--- args | ||
--- out | ||
Hello | ||
Hello | ||
Hello | ||
Hello | ||
Hello | ||
--- err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test printf | ||
--- src | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
printf("Hello world\n"); | ||
int Count; | ||
for (Count = -5; Count <= 5; Count++) | ||
printf("Count = %d\n", Count); | ||
printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there"); | ||
printf("Character 'A' is '%c'\n", 65); | ||
printf("Character 'a' is '%c'\n", 'a'); | ||
return 0; | ||
} | ||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : | ||
--- args | ||
--- out | ||
Hello world | ||
Count = -5 | ||
Count = -4 | ||
Count = -3 | ||
Count = -2 | ||
Count = -1 | ||
Count = 0 | ||
Count = 1 | ||
Count = 2 | ||
Count = 3 | ||
Count = 4 | ||
Count = 5 | ||
String 'hello', 'there' is 'hello', 'there' | ||
Character 'A' is 'A' | ||
Character 'a' is 'a' | ||
--- err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test struct | ||
--- src | ||
#include <stdio.h> | ||
struct fred | ||
{ | ||
int boris; | ||
int natasha; | ||
}; | ||
void main() | ||
{ | ||
struct fred bloggs; | ||
bloggs.boris = 12; | ||
bloggs.natasha = 34; | ||
printf("%d\n", bloggs.boris); | ||
printf("%d\n", bloggs.natasha); | ||
struct fred jones[2]; | ||
jones[0].boris = 12; | ||
jones[0].natasha = 34; | ||
jones[1].boris = 56; | ||
jones[1].natasha = 78; | ||
printf("%d\n", jones[0].boris); | ||
printf("%d\n", jones[0].natasha); | ||
printf("%d\n", jones[1].boris); | ||
printf("%d\n", jones[1].natasha); | ||
return 0; | ||
} | ||
--- args | ||
--- out | ||
12 | ||
34 | ||
12 | ||
34 | ||
56 | ||
78 | ||
--- err | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test for | ||
--- src | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int Count; | ||
for (Count = 1; Count <= 10; Count++) | ||
{ | ||
printf("%d\n", Count); | ||
} | ||
return 0; | ||
} | ||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : | ||
--- args | ||
--- out | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
6 | ||
7 | ||
8 | ||
9 | ||
10 | ||
--- err | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test array | ||
--- src | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int Count; | ||
int Array[10]; | ||
for (Count = 1; Count <= 10; Count++) | ||
{ | ||
Array[Count-1] = Count * Count; | ||
} | ||
for (Count = 0; Count < 10; Count++) | ||
{ | ||
printf("%d\n", Array[Count]); | ||
} | ||
return 0; | ||
} | ||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : | ||
--- args | ||
--- out | ||
1 | ||
4 | ||
9 | ||
16 | ||
25 | ||
36 | ||
49 | ||
64 | ||
81 | ||
100 | ||
--- err | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test case | ||
--- src | ||
#include <stdio.h> | ||
int main() | ||
{ | ||
int Count; | ||
for (Count = 0; Count < 4; Count++) | ||
{ | ||
printf("%d\n", Count); | ||
switch (Count) | ||
{ | ||
case 1: | ||
printf("%d\n", 1); | ||
break; | ||
case 2: | ||
printf("%d\n", 2); | ||
break; | ||
default: | ||
printf("%d\n", 0); | ||
break; | ||
} | ||
} | ||
return 0; | ||
} | ||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : | ||
--- args | ||
--- out | ||
0 | ||
0 | ||
1 | ||
1 | ||
2 | ||
2 | ||
3 | ||
0 | ||
--- err | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
# vi: ft= et tw=4 sw=4 | ||
|
||
use lib 't/lib'; | ||
use Test::sakura 'no_plan'; | ||
|
||
run_tests(); | ||
|
||
__DATA__ | ||
=== TEST 1: test function | ||
--- src | ||
#include <stdio.h> | ||
int myfunc(int x) | ||
{ | ||
return x * x; | ||
} | ||
void vfunc(int a) | ||
{ | ||
printf("a=%d\n", a); | ||
} | ||
void qfunc() | ||
{ | ||
printf("qfunc()\n"); | ||
} | ||
int main() | ||
{ | ||
printf("%d\n", myfunc(3)); | ||
printf("%d\n", myfunc(4)); | ||
vfunc(1234); | ||
qfunc(); | ||
return 0; | ||
} | ||
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 : | ||
--- args | ||
--- out | ||
9 | ||
16 | ||
a=1234 | ||
qfunc() | ||
--- err | ||
Oops, something went wrong.