* test: test alloca more.

git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@4108 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
Minero Aoki 2008-12-14 12:04:58 +00:00
parent e0105bda01
commit 73ecd8d50b
3 changed files with 71 additions and 0 deletions

View File

@ -1,3 +1,7 @@
Sun Dec 14 21:04:56 2008 Minero Aoki <aamine@loveruby.net>
* test: test alloca more.
Sun Dec 14 20:43:47 2008 Minero Aoki <aamine@loveruby.net>
* net/loveruby/cflat/compiler/CodeGenerator.java

60
test/alloca2.cb Normal file
View File

@ -0,0 +1,60 @@
import stdio;
import string;
import alloca;
int
main(int argc, char **argv)
{
fa();
puts("");
return 0;
}
static int
fa(void)
{
int[10] junk;
int x = 4 * 4 - 13;
char* s = alloca(10);
fb();
strcpy(s, ";%d");
printf(s, 14 + x);
}
static int
fb(void)
{
int[10] junk;
int x = (61 - 1) / 4;
char* s = alloca(15);
x += 4;
fc();
strcpy(s, ";%d");
printf(s, x - 2);
}
static int
fc(void)
{
int[10] junk;
int x = 4 * 4;
char* s = alloca(20);
x--;
fd();
strcpy(s, ";%d");
printf(s, x + 2);
}
static int
fd(void)
{
int[10] junk;
int x = 88 / 4;
char* s = alloca(25);
strcpy(s, "%d");
printf(s, -5 + x);
}

View File

@ -279,6 +279,10 @@ test_28_syntax() {
test_29_import() {
assert_compile_success duplicated-import.cb
assert_compile_success vardecl.cb &&
assert_status 0 ./vardecl
assert_compile_success -fPIC vardecl.cb &&
assert_status 0 ./vardecl
}
test_30_staticfunction() {
@ -314,6 +318,9 @@ test_35_invalidstmt() {
test_36_alloca() {
assert_out "<<Hello>>" ./alloca
assert_out "17;17;17;17" ./alloca2
assert_compile_success -fPIE -pie alloca2.cb &&
assert_out "17;17;17;17" ./alloca2
}
###