File: testsuit.e

package info (click to toggle)
euler 1.61.0-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,164 kB
  • sloc: ansic: 24,761; sh: 8,314; makefile: 141; cpp: 47; php: 1
file content (117 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
form=shortformat();

"Test suite for EULER implementations."
""

function isone (x)
	if !(any(x)!=1); "passed",
	else "*************** failed ****************",
	endif;
	return ""
endfunction

"--- Linear Sytems"
a=random(5,5);
isone(a\sum(a)~=1);
isone(ones(5,1) <<= ilgs(~a~,~sum(a)~));
a=a+random(5,5)*1i;
isone(a\sum(a)~=1);

"--- Intervals",
x=dup([~-2,-1~,~-2,3~,~1,2~],3); y=x'; z=x*y;
h1=left(x)*left(y); h2=right(x)*right(y);
h3=left(x)*right(y); h4=right(x)*left(y);
isone(left(z)<>min(min(min(h1,h2),h3),h4));
isone(right(z)<>max(max(max(h1,h2),h3),h4));

"--- Accumulator"
x=exp(random(1,100)*30); x=x|(-x)|1;
isone(accuload(x));
accuload(x,x);
isone(accuadd(x,-x)==0);
x=exp(random(1,10)*60); x=x|(-x)|1;
isone(accuload(x));
isone(middle(accuload(~x~))==1);
x=exp(random(1,10)*60)+1i*exp(random(1,10)*60);
isone(abs(accuload(x|-x|1))==1);
isone(abs(accuload(x|x,-x|x))==0);

"--- Residuum"
{i,j}=field(1:8,1:8); h=fak(15)/(i+j-1); b=sum(h); x=h\b;
x=x-h\residuum(h,x,b); x=x-h\residuum(h,x,b);
isone(x~=ones(8,1));

"--- Functions"
function test
	i=0;
	loop -10 to 11;
		i=i+#;
	end;
	return i;
endfunction
isone(test()==11);
function test
	i=0;
	for j=-10 to 11 step 1;
		i=i+j;
	end;
	return i;
endfunction
isone(test()==11);
function test
	i=0;
	j=-10;
	repeat;
		i=i+j;
		if j>=11; return i; endif;
		j=j+1;
	end;
endfunction
isone(test()==11);
function test (k=3)
	l=6;
	if (k==3); return 1; endif;
	if (k<2); return 2;
	else
		if (k>4);
			if k>5; return 3; endif;
		else l=5;
		endif;
	endif
	return l;
endfunction
isone([test()==1,test(3)==1,test(1)==2, ..
test(3.5)==5,test(6)==3,test(4.5)==6]);

"--- Strings"
isone(''Affe''<"Berta");
isone("Affen">"Affe");
isone("test"==''test'');
function test
	return ''3+4*''=="3+4*"
endfunction
isone(test());

"--- Operators"
p=1:5; isone(p[1]==p[1]); isone(p[1]<p[2]); isone(p[1]<>p[2]);
isone(!(~1,2~<~1,3~)); isone(~2,3~>~0,1~); isone(1+0i==1);
isone((pi()<4)&&(pi>3));

"--- FFT and Complex Polynomials"
z=exp(2*Pi*(0:15)/16);
isone(polyval(1:16,z)~=fft(1:16));
p=random(1,256)+1i*random(1,256);
isone(p~=ifft(fft(p)));
isone(p~=fft(ifft(p)));

"--- Statistics"
n=10000; h=normal(1,n);
isone(abs(sum(h)/n)<=0.1);
isone(abs(sum(h*h)/n-1)<=0.1);
t=-2:0.1:2;
isone(abs(invnormaldis(normaldis(t))-t)<0.001);

format(form);

.. EOF