diff --git a/collects/tests/honu/ideas.honu b/collects/tests/honu/ideas.honu index d4e448cf2f..9105138c7e 100644 --- a/collects/tests/honu/ideas.honu +++ b/collects/tests/honu/ideas.honu @@ -1,5 +1,10 @@ #honu +/* +a f(a x, a b) { return (obj)x; } +((obj)f)(1, "again"); +*/ + /* Some examples to consider when writing a test suite. //T means the example should be a type error. //R means the example should be a run-time error. */ @@ -17,6 +22,11 @@ int b(int y) { 1 + y; } +if (true) 1; else 2; +if ((obj)true) 1; else 2; +//T if (10) 1; else 2; +//R if ((obj)10) 1; else 2; + int f(int x, (string -> int) g) { if (x == 0) 1; else g("a"); } @@ -31,7 +41,9 @@ obj h = j; f(1, g); f(1, { obj g2 = g; g2; }); +//T f(1, j); f(0, h); +//R f(1, h); string function(string x) { return x; }; @@ -61,15 +73,29 @@ else 1 < 2 && 7 > 6; - b poly(a n) { if (n) poly(false); else { obj x = 12; x;} } -poly (1); + b polyX(a n) { if ((obj)n) (obj)1; else (obj)2; } + +/* + +//T b poly0(a n) { if (n) (obj)1; else (obj)2; } +//T b poly0(a n) { if ((obj)n) 1; else 2; } + b polyX(a n) { if ((obj)n) (obj)1; else (obj)2; } +/* but there's no valid way to use polyX... */ +//R polyX (true); + + b polyY(bool t, a n) { if (t) polyY(false, true); else { obj x = 12; x;} } +/* similarly, no valid way to use polyY... */ +//R polyY (true, 1); + + c poly(bool t, a n, c res) { if (t) poly(false, true, res); else res; } +poly (true, 1, -1); obj paly(obj n, obj m) { return n; } -obj pf0((a b c >-> (a -> b)) g) { return g(10); } +obj pf0((a b c >-> (bool a c -> c)) g) { return g(true, 10, -3); } //R pf0(poly); -obj pf((a b c >-> (a -> b)) g) { return g(10); } +obj pf((a b c >-> (bool a c -> c)) g) { return g(true, 10, -3); } pf(poly); //T pf(paly); pf({ obj x = poly; x; } ); @@ -95,6 +121,19 @@ time loop3(1000000, false); } time loop2(1000000, false); +/* Compare this one, too: */ + (int a -> a) getLoop() +{ + a loop2(int n, a res) { + if (n == 0) + return res; + else + return loop2(n - 1, res); + } + return loop2; +} +time getloop()(1000000, false); + int app((int int -> int) f) { return f(0, 1); } app(int function(int a, int b) { return a; }); @@ -122,3 +161,5 @@ int make_adder((int -> int) x) { x(10); } (int function(int b, int a) { return a + b; }) (1, 2); provide make_adder; + + */