Changes in / [9d6497a:014bb94]
- Location:
- tests
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/coroutine/fmtLines.c
r9d6497a r014bb94 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 22:45:36201813 // Update Count : 4 812 // Last Modified On : Tue Dec 11 21:58:49 2018 13 // Update Count : 47 14 14 // 15 15 … … 48 48 void format( Format & fmt ) { 49 49 resume( fmt ); 50 } // format50 } // prt 51 51 52 52 int main() { -
tests/coroutine/prodcons.c
r9d6497a r014bb94 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 23:04:49201813 // Update Count : 5 312 // Last Modified On : Tue Dec 11 21:58:25 2018 13 // Update Count : 52 14 14 // 15 15 … … 24 24 25 25 coroutine Prod { 26 Cons &c;26 Cons * c; 27 27 int N, money, receipt; 28 28 }; … … 30 30 // 1st resume starts here 31 31 for ( i; N ) { // N pairs of values 32 int p1 = random( 100 ), p2 = random( 100 ); 32 int p1 = random( 100 ); 33 int p2 = random( 100 ); 33 34 sout | p1 | " " | p2; 34 int status = delivery( c, p1, p2 ); 35 sout | " $" | money | nl | status; 35 int status = delivery( *c, p1, p2 ); 36 sout | " $" | money; 37 sout | status; 36 38 receipt += 1; 37 39 } 38 stop( c );40 stop( *c ); 39 41 sout | "prod stops"; 40 42 } … … 45 47 } 46 48 void start( Prod & prod, int N, Cons &c ) { 47 &prod.c = &c; 48 prod.[N, receipt] = [N, 0]; 49 prod.N = N; 50 prod.c = &c; 51 prod.receipt = 0; 49 52 resume( prod ); // activate main 50 53 } 51 54 52 55 coroutine Cons { 53 Prod &p;56 Prod * p; 54 57 int p1, p2, status; 55 58 bool done; 56 59 }; 57 60 void ?{}( Cons & cons, Prod & p ) { 58 &cons.p = &p; 59 cons.[status, done ] = [0, false]; 61 cons.p = &p; 62 cons.status = 0; 63 cons.done = false; 60 64 } 61 65 void ^?{}( Cons & cons ) {} … … 64 68 int money = 1, receipt; 65 69 for ( ; ! done; ) { 66 sout | p1 | " " | p2 | nl | " $" | money; 70 sout | p1 | " " | p2; 71 sout | " $" | money; 67 72 status += 1; 68 receipt = payment( p, money );73 receipt = payment( *p, money ); 69 74 sout | " #" | receipt; 70 75 money += 1; … … 73 78 } 74 79 int delivery( Cons & cons, int p1, int p2 ) { 75 cons.[p1, p2] = [p1, p2]; 80 cons.p1 = p1; 81 cons.p2 = p2; 76 82 resume( cons ); // main 1st time, then 77 83 return cons.status; // cons in payment -
tests/io1.cfa
r9d6497a r014bb94 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 18:23:44201813 // Update Count : 1 1012 // Last Modified On : Tue Dec 4 21:40:28 2018 13 // Update Count : 106 14 14 // 15 15 … … 25 25 26 26 sout | "opening delimiters"; 27 sout | "x (" | 1 | nonl; 28 sout | "x [" | 2 | nonl; 29 sout | "x {" | 3 | nonl; 30 sout | "x =" | 4 | nonl; 31 sout | "x $" | 5 | nonl; 32 sout | "x £" | 6 | nonl; 33 sout | "x ¥" | 7 | nonl; 34 sout | "x ¡" | 8 | nonl; 35 sout | "x ¿" | 9 | nonl; 36 sout | "x «" | 10; 27 sout 28 | "x (" | 1 29 | "x [" | 2 30 | "x {" | 3 31 | "x =" | 4 32 | "x $" | 5 33 | "x £" | 6 34 | "x ¥" | 7 35 | "x ¡" | 8 36 | "x ¿" | 9 37 | "x «" | 10 38 | nl; 37 39 38 40 sout | "closing delimiters"; 39 sout | 1 | ", x" | nonl; 40 sout | 2 | ". x" | nonl; 41 sout | 3 | "; x" | nonl; 42 sout | 4 | "! x" | nonl; 43 sout | 5 | "? x" | nonl; 44 sout | 6 | "% x" | nonl; 45 sout | 7 | "¢ x" | nonl; 46 sout | 8 | "» x" | nonl; 47 sout | 9 | ") x" | nonl; 48 sout | 10 | "] x" | nonl; 49 sout | 11 | "} x"; 41 sout 42 | 1 | ", x" 43 | 2 | ". x" 44 | 3 | "; x" 45 | 4 | "! x" 46 | 5 | "? x" 47 | 6 | "% x" 48 | 7 | "¢ x" 49 | 8 | "» x" 50 | 9 | ") x" 51 | 10 | "] x" 52 | 11 | "} x" 53 | nl; 50 54 51 55 sout | "opening/closing delimiters"; 52 sout | "x`" | 1 | "`x'" | 2 | nonl; 53 sout | "'x\"" | 3 | "\"x:" | 4 | nonl; 54 sout | ":x " | 5 | " x\t" | 6 | nonl; 55 sout | "\tx\f" | 7 | "\fx\v" | 8 | nonl; 56 sout | "\vx\n" | 9 | "\nx\r" | 10 | nonl; 57 sout | "\rx"; 56 sout 57 | "x`" | 1 | "`x'" | 2 58 | "'x\"" | 3 | "\"x:" | 4 59 | ":x " | 5 | " x\t" | 6 60 | "\tx\f" | 7 | "\fx\v" | 8 61 | "\vx\n" | 9 | "\nx\r" | 10 62 | "\rx" 63 | nl; 58 64 59 65 sout | "override opening/closing delimiters"; -
tests/io2.cfa
r9d6497a r014bb94 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 16:19:15201813 // Update Count : 1 1012 // Last Modified On : Tue Dec 11 21:51:52 2018 13 // Update Count : 109 14 14 // 15 15 … … 44 44 45 45 sout | "input bacis types"; 46 in | b ;// boolean47 in | c | sc | usc;// character48 in | si | usi | i | ui | li | uli | lli | ulli;// integral49 in | f | d | ld;// floating point50 in | fc | dc | ldc;// floating-point complex51 in| cstr( s1 ) | cstr( s2, size ); // C string, length unchecked and checked46 in | b // boolean 47 | c | sc | usc // character 48 | si | usi | i | ui | li | uli | lli | ulli // integral 49 | f | d | ld // floating point 50 | fc | dc | ldc // floating-point complex 51 | cstr( s1 ) | cstr( s2, size ); // C string, length unchecked and checked 52 52 sout | nl; 53 53 54 54 sout | "output basic types"; 55 sout | b ;// boolean56 sout | c | ' ' | sc | ' ' | usc;// character57 sout | si | usi | i | ui | li | uli | lli | ulli;// integral58 sout | f | d | ld;// floating point59 sout| fc | dc | ldc; // complex55 sout | b | nl // boolean 56 | c | ' ' | sc | ' ' | usc | nl // character 57 | si | usi | i | ui | li | uli | lli | ulli | nl // integral 58 | f | d | ld | nl // floating point 59 | fc | dc | ldc; // complex 60 60 sout | nl; 61 61 … … 66 66 67 67 sout | "toggle separator"; 68 sout | f | "" | d | "" | ld ;// floating point without separator69 sout | sepDisable | fc | dc | ldc;// complex without separator70 sout | fc | sepOn | dc | ldc;// local separator add71 sout | sepEnable | fc | dc | ldc;// complex with separator72 sout | fc | sepOff | dc | ldc;// local separator removal73 sout | s1 | sepOff | s2;// local separator removal74 sout| s1 | "" | s2; // local separator removal68 sout | f | "" | d | "" | ld | nl // floating point without separator 69 | sepDisable | fc | dc | ldc | nl // complex without separator 70 | fc | sepOn | dc | ldc | nl // local separator add 71 | sepEnable | fc | dc | ldc | nl // complex with separator 72 | fc | sepOff | dc | ldc | nl // local separator removal 73 | s1 | sepOff | s2 | nl // local separator removal 74 | s1 | "" | s2; // local separator removal 75 75 sout | nl; 76 76 … … 79 79 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 80 80 sout | " to \"" | sep | "\""; 81 sout | f | d | ld ;82 sout | fc | dc | ldc;83 sout | s1 | s2;84 sout| t1 | t2; // print tuple81 sout | f | d | ld | nl 82 | fc | dc | ldc | nl 83 | s1 | s2 | nl 84 | t1 | t2; // print tuple 85 85 sout | nl; 86 86 sout | "from \"" | sep | "\" " | nonl; 87 87 sepSet( sout, " " ); // restore separator 88 88 sout | "to \"" | sep | "\""; 89 sout | f | d | ld ;90 sout | fc | dc | ldc;91 sout | s1 | s2;92 sout| t1 | t2; // print tuple89 sout | f | d | ld | nl 90 | fc | dc | ldc | nl 91 | s1 | s2 | nl 92 | t1 | t2; // print tuple 93 93 sout | nl; 94 94 -
tests/math1.cfa
r9d6497a r014bb94 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 16:28:49201813 // Update Count : 8 912 // Last Modified On : Tue Dec 11 10:24:31 2018 13 // Update Count : 88 14 14 // 15 15 … … 22 22 long double l; 23 23 24 sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | nonl; 25 sout | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ); 24 sout | "fmod:" | 5.0F % -2.0F | fmod( 5.0F, -2.0F ) | 5.0D % -2.0D | fmod( 5.0D, -2.0D ) | 5.0L % -2.0L | fmod( 5.0L, -2.0L ); 26 25 sout | "remainder:" | remainder( 2.0F, 3.0F ) | remainder( 2.0D, 3.0D ) | remainder( 2.0L, 3.0L ); 27 26 int quot; … … 39 38 //---------------------- Exponential ---------------------- 40 39 41 sout | "exp:" | exp( 1.0F ) | exp( 1.0D ) | exp( 1.0L ) | nonl; 42 sout | exp( 1.0F+1.0FI ) | exp( 1.0D+1.0DI ) | exp( 1.0DL+1.0LI ); 40 sout | "exp:" | exp( 1.0F ) | exp( 1.0D ) | exp( 1.0L ) | exp( 1.0F+1.0FI ) | exp( 1.0D+1.0DI ) | exp( 1.0DL+1.0LI ); 43 41 sout | "exp2:" | exp2( 1.0F ) | exp2( 1.0D ) | exp2( 1.0L ); 44 42 sout | "expm1:" | expm1( 1.0F ) | expm1( 1.0D ) | expm1( 1.0L ); 45 sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | nonl; 46 sout | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.5DL+1.5LI, 1.5DL+1.5LI ); 43 sout | "pow:" | pow( 1.0F, 1.0F ) | pow( 1.0D, 1.0D ) | pow( 1.0L, 1.0L ) | pow( 1.0F+1.0FI, 1.0F+1.0FI ) | pow( 1.0D+1.0DI, 1.0D+1.0DI ) | pow( 1.5DL+1.5LI, 1.5DL+1.5LI ); 47 44 48 45 int b = 4; … … 50 47 b \= e; 51 48 sout | "\\" | b | b \ e; 52 sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | nonl; 53 sout | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi); 49 sout | "\\" | 'a' \ 3u | 2 \ 8u | 4 \ 3u | -4 \ 3u | 4 \ -3 | -4 \ -3 | 4.0 \ 2.1 | (1.0f+2.0fi) \ (3.0f+2.0fi); 54 50 } // main 55 51 -
tests/math2.cfa
r9d6497a r014bb94 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 16:11:35201813 // Update Count : 8 712 // Last Modified On : Tue Dec 4 23:11:12 2018 13 // Update Count : 85 14 14 // 15 15 … … 24 24 //---------------------- Logarithm ---------------------- 25 25 26 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | nonl; 27 sout | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ); 26 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ); 28 27 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ); 29 28 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ); … … 32 31 sout | "logb:" | logb( 8.0F ) | logb( 8.0D ) | logb( 8.0L ); 33 32 34 sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | nonl; 35 sout | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ); 33 sout | "sqrt:" | sqrt( 1.0F ) | sqrt( 1.0D ) | sqrt( 1.0L ) | sqrt( 1.0F+1.0FI ) | sqrt( 1.0D+1.0DI ) | sqrt( 1.0DL+1.0LI ); 36 34 sout | "cbrt:" | cbrt( 27.0F ) | cbrt( 27.0D ) | cbrt( 27.0L ); 37 35 sout | "hypot:" | hypot( 1.0F, -1.0F ) | hypot( 1.0D, -1.0D ) | hypot( 1.0L, -1.0L ); … … 39 37 //---------------------- Trigonometric ---------------------- 40 38 41 sout | "sin:" | sin( 1.0F ) | sin( 1.0D ) | sin( 1.0L ) | nonl; 42 sout | sin( 1.0F+1.0FI ) | sin( 1.0D+1.0DI ) | sin( 1.0DL+1.0LI ); 43 sout | "cos:" | cos( 1.0F ) | cos( 1.0D ) | cos( 1.0L ) | nonl; 44 sout | cos( 1.0F+1.0FI ) | cos( 1.0D+1.0DI ) | cos( 1.0DL+1.0LI ); 45 sout | "tan:" | tan( 1.0F ) | tan( 1.0D ) | tan( 1.0L ) | nonl; 46 sout | tan( 1.0F+1.0FI ) | tan( 1.0D+1.0DI ) | tan( 1.0DL+1.0LI ); 47 sout | "asin:" | asin( 1.0F ) | asin( 1.0D ) | asin( 1.0L ) | nonl; 48 sout | asin( 1.0F+1.0FI ) | asin( 1.0D+1.0DI ) | asin( 1.0DL+1.0LI ); 49 sout | "acos:" | acos( 1.0F ) | acos( 1.0D ) | acos( 1.0L ) | nonl; 50 sout | acos( 1.0F+1.0FI ) | acos( 1.0D+1.0DI ) | acos( 1.0DL+1.0LI ); 51 sout | "atan:" | atan( 1.0F ) | atan( 1.0D ) | atan( 1.0L ) | nonl; 52 sout | atan( 1.0F+1.0FI ) | atan( 1.0D+1.0DI ) | atan( 1.0DL+1.0LI ); 39 sout | "sin:" | sin( 1.0F ) | sin( 1.0D ) | sin( 1.0L ) | sin( 1.0F+1.0FI ) | sin( 1.0D+1.0DI ) | sin( 1.0DL+1.0LI ); 40 sout | "cos:" | cos( 1.0F ) | cos( 1.0D ) | cos( 1.0L ) | cos( 1.0F+1.0FI ) | cos( 1.0D+1.0DI ) | cos( 1.0DL+1.0LI ); 41 sout | "tan:" | tan( 1.0F ) | tan( 1.0D ) | tan( 1.0L ) | tan( 1.0F+1.0FI ) | tan( 1.0D+1.0DI ) | tan( 1.0DL+1.0LI ); 42 sout | "asin:" | asin( 1.0F ) | asin( 1.0D ) | asin( 1.0L ) | asin( 1.0F+1.0FI ) | asin( 1.0D+1.0DI ) | asin( 1.0DL+1.0LI ); 43 sout | "acos:" | acos( 1.0F ) | acos( 1.0D ) | acos( 1.0L ) | acos( 1.0F+1.0FI ) | acos( 1.0D+1.0DI ) | acos( 1.0DL+1.0LI ); 44 sout | "atan:" | atan( 1.0F ) | atan( 1.0D ) | atan( 1.0L ) | atan( 1.0F+1.0FI ) | atan( 1.0D+1.0DI ) | atan( 1.0DL+1.0LI ); 53 45 sout | "atan2:" | atan2( 1.0F, 1.0F ) | atan2( 1.0D, 1.0D ) | atan2( 1.0L, 1.0L ) | nonl; 54 46 sout | "atan:" | atan( 1.0F, 1.0F ) | atan( 1.0D, 1.0D ) | atan( 1.0L, 1.0L ); -
tests/math3.cfa
r9d6497a r014bb94 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Dec 12 16:30:41201813 // Update Count : 8 612 // Last Modified On : Tue Dec 11 10:15:49 2018 13 // Update Count : 85 14 14 // 15 15 … … 24 24 //---------------------- Hyperbolic ---------------------- 25 25 26 sout | "sinh:" | sinh( 1.0F ) | sinh( 1.0D ) | sinh( 1.0L ) | nonl; 27 sout | sinh( 1.0F+1.0FI ) | sinh( 1.0D+1.0DI ) | sinh( 1.0DL+1.0LI ); 28 sout | "cosh:" | cosh( 1.0F ) | cosh( 1.0D ) | cosh( 1.0L ) | nonl; 29 sout | cosh( 1.0F+1.0FI ) | cosh( 1.0D+1.0DI ) | cosh( 1.0DL+1.0LI ); 30 sout | "tanh:" | tanh( 1.0F ) | tanh( 1.0D ) | tanh( 1.0L ) | nonl; 31 sout | tanh( 1.0F+1.0FI ) | tanh( 1.0D+1.0DI ) | tanh( 1.0DL+1.0LI ); 32 sout | "acosh:" | acosh( 1.0F ) | acosh( 1.0D ) | acosh( 1.0L ) | nonl; 33 sout | acosh( 1.0F+1.0FI ) | acosh( 1.0D+1.0DI ) | acosh( 1.0DL+1.0LI ); 34 sout | "asinh:" | asinh( 1.0F ) | asinh( 1.0D ) | asinh( 1.0L ) | nonl; 35 sout | asinh( 1.0F+1.0FI ) | asinh( 1.0D+1.0DI ) | asinh( 1.0DL+1.0LI ); 36 sout | "atanh:" | atanh( 1.0F ) | atanh( 1.0D ) | atanh( 1.0L ) | nonl; 37 sout | atanh( 1.0F+1.0FI ) | atanh( 1.0D+1.0DI ) | atanh( 1.0DL+1.0LI ); 26 sout | "sinh:" | sinh( 1.0F ) | sinh( 1.0D ) | sinh( 1.0L ) | sinh( 1.0F+1.0FI ) | sinh( 1.0D+1.0DI ) | sinh( 1.0DL+1.0LI ); 27 sout | "cosh:" | cosh( 1.0F ) | cosh( 1.0D ) | cosh( 1.0L ) | cosh( 1.0F+1.0FI ) | cosh( 1.0D+1.0DI ) | cosh( 1.0DL+1.0LI ); 28 sout | "tanh:" | tanh( 1.0F ) | tanh( 1.0D ) | tanh( 1.0L ) | tanh( 1.0F+1.0FI ) | tanh( 1.0D+1.0DI ) | tanh( 1.0DL+1.0LI ); 29 sout | "acosh:" | acosh( 1.0F ) | acosh( 1.0D ) | acosh( 1.0L ) | acosh( 1.0F+1.0FI ) | acosh( 1.0D+1.0DI ) | acosh( 1.0DL+1.0LI ); 30 sout | "asinh:" | asinh( 1.0F ) | asinh( 1.0D ) | asinh( 1.0L ) | asinh( 1.0F+1.0FI ) | asinh( 1.0D+1.0DI ) | asinh( 1.0DL+1.0LI ); 31 sout | "atanh:" | atanh( 1.0F ) | atanh( 1.0D ) | atanh( 1.0L ) | atanh( 1.0F+1.0FI ) | atanh( 1.0D+1.0DI ) | atanh( 1.0DL+1.0LI ); 38 32 39 33 //---------------------- Error / Gamma ----------------------
Note:
See TracChangeset
for help on using the changeset viewer.