first commit
This commit is contained in:
commit
063194f8be
349 changed files with 36508 additions and 0 deletions
73
tester/testsuite/good/core001.jl
Normal file
73
tester/testsuite/good/core001.jl
Normal file
|
@ -0,0 +1,73 @@
|
|||
int main() {
|
||||
printInt(fac(10));
|
||||
printInt(rfac(10));
|
||||
printInt(mfac(10));
|
||||
printInt(ifac(10));
|
||||
double r ; // just to test blocks
|
||||
{
|
||||
int n = 10;
|
||||
int r = 1;
|
||||
while (n>0) {
|
||||
r = r * n;
|
||||
n--;
|
||||
}
|
||||
printInt(r);
|
||||
}
|
||||
printDouble(dfac(10.0));
|
||||
printString ("hello */");
|
||||
printString ("/* world") ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int fac(int a) {
|
||||
int r;
|
||||
int n;
|
||||
|
||||
r = 1;
|
||||
n = a;
|
||||
while (n > 0) {
|
||||
r = r * n;
|
||||
n = n - 1;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int rfac(int n) {
|
||||
if (n == 0)
|
||||
return 1;
|
||||
else
|
||||
return n * rfac(n-1);
|
||||
}
|
||||
|
||||
int mfac(int n) {
|
||||
if (n == 0)
|
||||
return 1;
|
||||
else
|
||||
return n * nfac(n-1);
|
||||
}
|
||||
|
||||
int nfac(int n) {
|
||||
if (n != 0)
|
||||
return mfac(n-1) * n;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
double dfac(double n) {
|
||||
if (n == 0.0)
|
||||
return 1.0;
|
||||
else
|
||||
return n * dfac(n-1.0);
|
||||
}
|
||||
|
||||
int ifac(int n) { return ifac2f(1,n); }
|
||||
|
||||
int ifac2f(int l, int h) {
|
||||
if (l == h)
|
||||
return l;
|
||||
if (l > h)
|
||||
return 1;
|
||||
int m;
|
||||
m = (l + h) / 2;
|
||||
return ifac2f(l,m) * ifac2f(m+1,h);
|
||||
}
|
8
tester/testsuite/good/core001.output
Normal file
8
tester/testsuite/good/core001.output
Normal file
|
@ -0,0 +1,8 @@
|
|||
3628800
|
||||
3628800
|
||||
3628800
|
||||
3628800
|
||||
3628800
|
||||
3628800.0
|
||||
hello */
|
||||
/* world
|
12
tester/testsuite/good/core002.jl
Normal file
12
tester/testsuite/good/core002.jl
Normal file
|
@ -0,0 +1,12 @@
|
|||
/* void expression as statement */
|
||||
|
||||
int main() {
|
||||
foo();
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
||||
void foo() {
|
||||
printString("foo");
|
||||
return;
|
||||
}
|
1
tester/testsuite/good/core002.output
Normal file
1
tester/testsuite/good/core002.output
Normal file
|
@ -0,0 +1 @@
|
|||
foo
|
23
tester/testsuite/good/core003.jl
Normal file
23
tester/testsuite/good/core003.jl
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Testing the return checker
|
||||
|
||||
int f () {
|
||||
if (true)
|
||||
return 0;
|
||||
else
|
||||
{}
|
||||
}
|
||||
|
||||
int g () {
|
||||
if (false)
|
||||
{}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
void p () {}
|
||||
|
||||
|
||||
int main() {
|
||||
p();
|
||||
return 0;
|
||||
}
|
0
tester/testsuite/good/core003.output
Normal file
0
tester/testsuite/good/core003.output
Normal file
7
tester/testsuite/good/core004.jl
Normal file
7
tester/testsuite/good/core004.jl
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* allow comparing booleans. */
|
||||
|
||||
int main() {
|
||||
if (true == true) { printInt(42); }
|
||||
return 0 ;
|
||||
|
||||
}
|
1
tester/testsuite/good/core004.output
Normal file
1
tester/testsuite/good/core004.output
Normal file
|
@ -0,0 +1 @@
|
|||
42
|
14
tester/testsuite/good/core005.jl
Normal file
14
tester/testsuite/good/core005.jl
Normal file
|
@ -0,0 +1,14 @@
|
|||
/* usage of variable initialized in both branches. */
|
||||
|
||||
int main () {
|
||||
int x;
|
||||
int y = 56;
|
||||
if (y + 45 <= 2) {
|
||||
x = 1;
|
||||
} else {
|
||||
x = 2;
|
||||
}
|
||||
printInt(x);
|
||||
return 0 ;
|
||||
|
||||
}
|
1
tester/testsuite/good/core005.output
Normal file
1
tester/testsuite/good/core005.output
Normal file
|
@ -0,0 +1 @@
|
|||
2
|
11
tester/testsuite/good/core006.jl
Normal file
11
tester/testsuite/good/core006.jl
Normal file
|
@ -0,0 +1,11 @@
|
|||
// Declaration of multiple variables of the same type in one statement:
|
||||
|
||||
int main () {
|
||||
int x, y;
|
||||
x = 45;
|
||||
y = -36;
|
||||
printInt(x);
|
||||
printInt(y);
|
||||
return 0 ;
|
||||
|
||||
}
|
2
tester/testsuite/good/core006.output
Normal file
2
tester/testsuite/good/core006.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
45
|
||||
-36
|
8
tester/testsuite/good/core007.jl
Normal file
8
tester/testsuite/good/core007.jl
Normal file
|
@ -0,0 +1,8 @@
|
|||
// declaration and initialization in same statement
|
||||
|
||||
int main() {
|
||||
int x = 7;
|
||||
printInt(x);
|
||||
return 0 ;
|
||||
|
||||
}
|
1
tester/testsuite/good/core007.output
Normal file
1
tester/testsuite/good/core007.output
Normal file
|
@ -0,0 +1 @@
|
|||
7
|
11
tester/testsuite/good/core008.jl
Normal file
11
tester/testsuite/good/core008.jl
Normal file
|
@ -0,0 +1,11 @@
|
|||
// multiple variables of the same type declared
|
||||
// and possibly initialized in the same statement
|
||||
|
||||
int main() {
|
||||
int x, y = 7;
|
||||
x = -1234234;
|
||||
printInt(x);
|
||||
printInt(y);
|
||||
return 0 ;
|
||||
|
||||
}
|
2
tester/testsuite/good/core008.output
Normal file
2
tester/testsuite/good/core008.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
-1234234
|
||||
7
|
13
tester/testsuite/good/core009.jl
Normal file
13
tester/testsuite/good/core009.jl
Normal file
|
@ -0,0 +1,13 @@
|
|||
// Calling functions which take zero parameters
|
||||
|
||||
int main() {
|
||||
int x = foo();
|
||||
printInt(x);
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
||||
int foo() {
|
||||
return 10;
|
||||
}
|
||||
|
1
tester/testsuite/good/core009.output
Normal file
1
tester/testsuite/good/core009.output
Normal file
|
@ -0,0 +1 @@
|
|||
10
|
19
tester/testsuite/good/core010.jl
Normal file
19
tester/testsuite/good/core010.jl
Normal file
|
@ -0,0 +1,19 @@
|
|||
// count function parameters as initialized
|
||||
|
||||
int main() {
|
||||
printInt(fac(5));
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int fac (int a) {
|
||||
int r;
|
||||
int n;
|
||||
r = 1;
|
||||
n = a;
|
||||
while (n > 0)
|
||||
{
|
||||
r = r * n;
|
||||
n = n - 1;
|
||||
}
|
||||
return r;
|
||||
}
|
1
tester/testsuite/good/core010.output
Normal file
1
tester/testsuite/good/core010.output
Normal file
|
@ -0,0 +1 @@
|
|||
120
|
6
tester/testsuite/good/core011.jl
Normal file
6
tester/testsuite/good/core011.jl
Normal file
|
@ -0,0 +1,6 @@
|
|||
/* Test pushing -1. */
|
||||
|
||||
int main() {
|
||||
printInt(-1);
|
||||
return 0 ;
|
||||
}
|
1
tester/testsuite/good/core011.output
Normal file
1
tester/testsuite/good/core011.output
Normal file
|
@ -0,0 +1 @@
|
|||
-1
|
26
tester/testsuite/good/core012.jl
Normal file
26
tester/testsuite/good/core012.jl
Normal file
|
@ -0,0 +1,26 @@
|
|||
/* Test arithmetic and comparisons. */
|
||||
|
||||
int main() {
|
||||
int x = 56;
|
||||
int y = -23;
|
||||
printInt(x+y);
|
||||
printInt(x-y);
|
||||
printInt(x*y);
|
||||
printInt(45/2);
|
||||
printInt(78%3);
|
||||
double z = -9.3;
|
||||
double w = 5.1;
|
||||
printBool(z+w > z-w);
|
||||
printBool(z/w <= z*w);
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
void printBool(boolean b) {
|
||||
if (b) {
|
||||
printString("true");
|
||||
return;
|
||||
} else {
|
||||
printString("false");
|
||||
return;
|
||||
}
|
||||
}
|
7
tester/testsuite/good/core012.output
Normal file
7
tester/testsuite/good/core012.output
Normal file
|
@ -0,0 +1,7 @@
|
|||
33
|
||||
79
|
||||
-1288
|
||||
22
|
||||
0
|
||||
true
|
||||
false
|
33
tester/testsuite/good/core013.jl
Normal file
33
tester/testsuite/good/core013.jl
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* Test boolean operators. */
|
||||
|
||||
int main() {
|
||||
printString("&&");
|
||||
printBool(test(-1) && test(0));
|
||||
printBool(test(-2) && test(1));
|
||||
printBool(test(3) && test(-5));
|
||||
printBool(test(234234) && test(21321));
|
||||
printString("||");
|
||||
printBool(test(-1) || test(0));
|
||||
printBool(test(-2) || test(1));
|
||||
printBool(test(3) || test(-5));
|
||||
printBool(test(234234) || test(21321));
|
||||
printString("!");
|
||||
printBool(true);
|
||||
printBool(false);
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
||||
void printBool(boolean b) {
|
||||
if (!b) {
|
||||
printString("false");
|
||||
} else {
|
||||
printString("true");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean test(int i) {
|
||||
printInt(i);
|
||||
return i > 0;
|
||||
}
|
25
tester/testsuite/good/core013.output
Normal file
25
tester/testsuite/good/core013.output
Normal file
|
@ -0,0 +1,25 @@
|
|||
&&
|
||||
-1
|
||||
false
|
||||
-2
|
||||
false
|
||||
3
|
||||
-5
|
||||
false
|
||||
234234
|
||||
21321
|
||||
true
|
||||
||
|
||||
-1
|
||||
0
|
||||
false
|
||||
-2
|
||||
1
|
||||
true
|
||||
3
|
||||
true
|
||||
234234
|
||||
true
|
||||
!
|
||||
true
|
||||
false
|
17
tester/testsuite/good/core014.jl
Normal file
17
tester/testsuite/good/core014.jl
Normal file
|
@ -0,0 +1,17 @@
|
|||
/* Fibonacci. */
|
||||
|
||||
int main () {
|
||||
int lo,hi,mx ;
|
||||
lo = 1 ;
|
||||
hi = lo ;
|
||||
mx = 5000000 ;
|
||||
printInt(lo) ;
|
||||
while (hi < mx) {
|
||||
printInt(hi) ;
|
||||
hi = lo + hi ;
|
||||
lo = hi - lo ;
|
||||
}
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
33
tester/testsuite/good/core014.output
Normal file
33
tester/testsuite/good/core014.output
Normal file
|
@ -0,0 +1,33 @@
|
|||
1
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
8
|
||||
13
|
||||
21
|
||||
34
|
||||
55
|
||||
89
|
||||
144
|
||||
233
|
||||
377
|
||||
610
|
||||
987
|
||||
1597
|
||||
2584
|
||||
4181
|
||||
6765
|
||||
10946
|
||||
17711
|
||||
28657
|
||||
46368
|
||||
75025
|
||||
121393
|
||||
196418
|
||||
317811
|
||||
514229
|
||||
832040
|
||||
1346269
|
||||
2178309
|
||||
3524578
|
16
tester/testsuite/good/core015.jl
Normal file
16
tester/testsuite/good/core015.jl
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* parity of positive integers by recursion */
|
||||
|
||||
int main () {
|
||||
printInt(ev(17)) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int ev (int y) {
|
||||
if (y > 0)
|
||||
return ev (y-2) ;
|
||||
else
|
||||
if (y < 0)
|
||||
return 0 ;
|
||||
else
|
||||
return 1 ;
|
||||
}
|
1
tester/testsuite/good/core015.output
Normal file
1
tester/testsuite/good/core015.output
Normal file
|
@ -0,0 +1 @@
|
|||
0
|
15
tester/testsuite/good/core016.jl
Normal file
15
tester/testsuite/good/core016.jl
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* parity of positive integers by loop */
|
||||
|
||||
int main () {
|
||||
int y = 17;
|
||||
while (y > 0)
|
||||
y = y - 2;
|
||||
if (y < 0) {
|
||||
printInt(0);
|
||||
return 0 ;
|
||||
}
|
||||
else {
|
||||
printInt(1);
|
||||
return 0 ;
|
||||
}
|
||||
}
|
1
tester/testsuite/good/core016.output
Normal file
1
tester/testsuite/good/core016.output
Normal file
|
@ -0,0 +1 @@
|
|||
0
|
40
tester/testsuite/good/core017.jl
Normal file
40
tester/testsuite/good/core017.jl
Normal file
|
@ -0,0 +1,40 @@
|
|||
/* Test boolean operators */
|
||||
|
||||
int main () {
|
||||
int x = 4;
|
||||
if (3 <= x && 4 != 2 && true) {
|
||||
printBool(true);
|
||||
} else {
|
||||
printString("apa");
|
||||
}
|
||||
|
||||
printBool(true == true || dontCallMe(1));
|
||||
printBool(4.0 < -50.0 && dontCallMe(2));
|
||||
|
||||
printBool(4 == x && true == !false && true);
|
||||
|
||||
printBool(implies(false,false));
|
||||
printBool(implies(false,true));
|
||||
printBool(implies(true,false));
|
||||
printBool(implies(true,true));
|
||||
return 0 ;
|
||||
|
||||
}
|
||||
|
||||
boolean dontCallMe(int x) {
|
||||
printInt(x);
|
||||
return true;
|
||||
}
|
||||
|
||||
void printBool(boolean b) {
|
||||
if (b) {
|
||||
printString("true");
|
||||
} else {
|
||||
printString("false");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean implies(boolean x, boolean y) {
|
||||
return !x || x == y;
|
||||
}
|
8
tester/testsuite/good/core017.output
Normal file
8
tester/testsuite/good/core017.output
Normal file
|
@ -0,0 +1,8 @@
|
|||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
2
tester/testsuite/good/core018.input
Normal file
2
tester/testsuite/good/core018.input
Normal file
|
@ -0,0 +1,2 @@
|
|||
-5673
|
||||
42.5
|
15
tester/testsuite/good/core018.jl
Normal file
15
tester/testsuite/good/core018.jl
Normal file
|
@ -0,0 +1,15 @@
|
|||
/* test input */
|
||||
|
||||
int main() {
|
||||
int x = readInt();
|
||||
double y = readDouble();
|
||||
|
||||
printInt(x-5);
|
||||
|
||||
if (y > 42.0 || y < 43.0)
|
||||
printString("yay!");
|
||||
else
|
||||
printString("nay!");
|
||||
return 0 ;
|
||||
|
||||
}
|
2
tester/testsuite/good/core018.output
Normal file
2
tester/testsuite/good/core018.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
-5678
|
||||
yay!
|
26
tester/testsuite/good/core019.jl
Normal file
26
tester/testsuite/good/core019.jl
Normal file
|
@ -0,0 +1,26 @@
|
|||
int main() {
|
||||
int i = 78;
|
||||
{
|
||||
int i = 1;
|
||||
printInt(i);
|
||||
}
|
||||
printInt(i);
|
||||
while (i > 76) {
|
||||
i--;
|
||||
printInt(i);
|
||||
// this is a little tricky
|
||||
// on the right hand side, i refers to the outer i
|
||||
int i = i + 7;
|
||||
printInt(i);
|
||||
}
|
||||
printInt(i);
|
||||
if (i > 4) {
|
||||
int i = 4;
|
||||
printInt(i);
|
||||
} else {
|
||||
printString("foo");
|
||||
}
|
||||
printInt(i);
|
||||
return 0 ;
|
||||
|
||||
}
|
9
tester/testsuite/good/core019.output
Normal file
9
tester/testsuite/good/core019.output
Normal file
|
@ -0,0 +1,9 @@
|
|||
1
|
||||
78
|
||||
77
|
||||
84
|
||||
76
|
||||
83
|
||||
76
|
||||
4
|
||||
76
|
7
tester/testsuite/good/core020.jl
Normal file
7
tester/testsuite/good/core020.jl
Normal file
|
@ -0,0 +1,7 @@
|
|||
int main() {
|
||||
p();
|
||||
printInt(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void p() {}
|
1
tester/testsuite/good/core020.output
Normal file
1
tester/testsuite/good/core020.output
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
6
tester/testsuite/good/core021.jl
Normal file
6
tester/testsuite/good/core021.jl
Normal file
|
@ -0,0 +1,6 @@
|
|||
int main() {
|
||||
if (true) {
|
||||
printInt(1);
|
||||
return 0;
|
||||
}
|
||||
}
|
1
tester/testsuite/good/core021.output
Normal file
1
tester/testsuite/good/core021.output
Normal file
|
@ -0,0 +1 @@
|
|||
1
|
7
tester/testsuite/good/core022.jl
Normal file
7
tester/testsuite/good/core022.jl
Normal file
|
@ -0,0 +1,7 @@
|
|||
int main() {
|
||||
int x;
|
||||
double y;
|
||||
printInt(x);
|
||||
printDouble(y);
|
||||
return 0;
|
||||
}
|
2
tester/testsuite/good/core022.output
Normal file
2
tester/testsuite/good/core022.output
Normal file
|
@ -0,0 +1,2 @@
|
|||
0
|
||||
0.0
|
Loading…
Add table
Add a link
Reference in a new issue