diff options
author | Xavier Clerc <xavier.clerc@inria.fr> | 2010-04-08 12:48:54 +0000 |
---|---|---|
committer | Xavier Clerc <xavier.clerc@inria.fr> | 2010-04-08 12:48:54 +0000 |
commit | 1cc7dffb2d97ce8a34dff983eb30c29fa1314e32 (patch) | |
tree | 24b1dba3b00e4bb61ae7d9b48dde6e998ffe5c2a /test/Moretest | |
parent | f3fc27c47c1aefa2fe847cae531d8eddaf9576a4 (diff) |
Tests moved to 'interactive'
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10257 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'test/Moretest')
-rw-r--r-- | test/Moretest/graph_example.ml | 131 | ||||
-rw-r--r-- | test/Moretest/graph_test.ml | 288 | ||||
-rw-r--r-- | test/Moretest/signals.ml | 32 |
3 files changed, 0 insertions, 451 deletions
diff --git a/test/Moretest/graph_example.ml b/test/Moretest/graph_example.ml deleted file mode 100644 index 6fbe988ce..000000000 --- a/test/Moretest/graph_example.ml +++ /dev/null @@ -1,131 +0,0 @@ -(* To run this example: - ******************** - 1. Select all the text in this window. - 2. Drag it to the toplevel window. - 3. Watch the colors. - 4. Drag the mouse over the graphics window and click here and there. - 5. Type any key to the graphics window to stop the program. -*) - -open Graphics;; -open_graph " 480x270";; - -let xr = size_x () / 2 - 30 -and yr = size_y () / 2 - 26 -and xg = size_x () / 2 + 30 -and yg = size_y () / 2 - 26 -and xb = size_x () / 2 -and yb = size_y () / 2 + 26 -;; - -let point x y = - let dr = (x-xr)*(x-xr) + (y-yr)*(y-yr) - and dg = (x-xg)*(x-xg) + (y-yg)*(y-yg) - and db = (x-xb)*(x-xb) + (y-yb)*(y-yb) - in - if dr > dg && dr > db then set_color (rgb 255 (255*dg/dr) (255*db/dr)) - else if dg > db then set_color (rgb (255*dr/dg) 255 (255*db/dg)) - else set_color (rgb (255*dr/db) (255*dg/db) 255); - fill_rect x y 2 2; -;; - -for y = (size_y () - 1) / 2 downto 0 do - for x = 0 to (size_x () - 1) / 2 do - point (2*x) (2*y); - done -done -;; - -let n = 0x000000 -and w = 0xFFFFFF -and b = 0xFFCC99 -and y = 0xFFFF00 -and o = 0xCC9966 -and v = 0x00BB00 -and g = 0x888888 -and c = 0xDDDDDD -and t = transp -;; - -let caml = make_image [| - [|t;t;t;t;t;t;t;t;t;t;t;n;n;n;n;n;n;t;t;t;t;t;t;t;t;t;t;t;t;t;t;t;|]; - [|t;t;t;t;t;t;t;t;t;t;n;n;n;n;n;n;n;n;n;t;t;t;t;t;t;t;t;t;t;t;t;t;|]; - [|t;t;t;t;t;t;t;t;n;n;n;n;n;n;n;n;n;n;n;n;t;t;t;t;t;t;t;t;t;t;t;t;|]; - [|n;n;n;n;n;n;t;n;n;n;n;n;b;b;b;b;b;b;b;n;n;t;t;t;t;t;n;n;n;n;n;t;|]; - [|n;o;o;o;o;o;n;n;n;n;b;b;b;b;b;b;b;b;b;b;b;n;n;n;n;n;n;n;n;n;n;t;|]; - [|n;o;o;o;o;o;o;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;t;|]; - [|n;o;o;o;o;o;o;o;n;n;n;g;g;g;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;t;t;|]; - [|n;n;o;o;o;o;o;o;o;n;n;n;c;c;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;t;t;|]; - [|t;n;n;o;o;o;o;o;o;o;n;n;n;c;n;n;n;n;n;n;n;b;b;n;n;n;n;n;n;t;t;t;|]; - [|t;t;n;n;n;o;o;o;o;o;o;n;n;n;n;n;n;n;n;n;b;b;b;b;n;n;n;n;t;t;t;t;|]; - [|t;t;t;t;n;n;o;o;o;o;o;o;n;n;n;n;n;n;n;n;b;b;b;b;b;b;n;n;t;t;t;t;|]; - [|t;t;t;t;t;n;n;o;o;o;o;o;o;n;n;n;n;n;n;o;o;b;b;b;b;b;b;n;n;t;t;t;|]; - [|t;t;t;t;t;n;n;o;o;o;o;o;o;b;b;b;b;b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;n;n;v;o;v;o;o;o;o;o;o;o;o;o;o;o;n;n;n;b;n;n;n;n;b;n;t;|]; - [|t;t;t;t;t;n;v;o;o;v;o;o;o;o;o;o;o;o;o;o;o;o;n;n;n;n;n;n;n;n;t;t;|]; - [|t;t;t;t;n;n;o;o;o;o;o;o;o;o;o;o;o;o;o;o;o;n;n;n;n;n;n;t;t;t;t;t;|]; - [|t;t;t;t;n;o;o;o;o;o;o;o;o;o;o;o;o;o;o;o;n;n;t;t;t;t;t;t;t;t;t;t;|]; - [|t;t;t;t;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;n;t;t;t;t;t;t;t;t;t;t;t;|]; -|];; - -(* -let x = ref 0 and y = ref 0;; -let bg = get_image !x !y 32 32;; -while true do - let st = wait_next_event [Mouse_motion; Button_down] in - if not st.button then draw_image bg !x !y; - x := st.mouse_x; - y := st.mouse_y; - blit_image bg !x !y; - draw_image caml !x !y; -done;; -*) -set_color (rgb 0 0 0); -remember_mode false; -try while true do - let st = wait_next_event [Mouse_motion; Button_down; Key_pressed] in - synchronize (); - if st.keypressed then raise Exit; - if st.button then begin - remember_mode true; - draw_image caml st.mouse_x st.mouse_y; - remember_mode false; - end; - let x = st.mouse_x + 16 and y = st.mouse_y + 16 in - - moveto 0 y; - lineto (x - 25) y; - moveto 10000 y; - lineto (x + 25) y; - - moveto x 0; - lineto x (y - 25); - moveto x 10000; - lineto x (y + 25); - - draw_image caml st.mouse_x st.mouse_y; -done with Exit -> () -;; - -(* To run this example: - ******************** - 1. Select all the text in this window. - 2. Drag it to the toplevel window. - 3. Watch the colors. - 4. Drag the mouse over the graphics window and click here and there. - 5. Type any key to the graphics window to stop the program. -*) diff --git a/test/Moretest/graph_test.ml b/test/Moretest/graph_test.ml deleted file mode 100644 index cd4c0813d..000000000 --- a/test/Moretest/graph_test.ml +++ /dev/null @@ -1,288 +0,0 @@ -(***********************************************************************) -(* *) -(* Objective Caml *) -(* *) -(* Pierre Weis, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2000 Institut National de Recherche en Informatique et *) -(* en Automatique. All rights reserved. This file is distributed *) -(* under the terms of the GNU Library General Public License, with *) -(* the special exception on linking described in file ../../LICENSE. *) -(* *) -(***********************************************************************) - -(* graph_test.ml : tests various drawing and filling primitives of the - Graphics library. *) - -(* To run this example just load this file into a suitable toplevel. - Alternatively execute - ocamlc graphics.cma graph_test.ml *) - -open Graphics;; - -auto_synchronize false;; -display_mode false;; -remember_mode true;; - -let sz = 450;; - -open_graph (Printf.sprintf " %ix%i" sz sz);; - -(* To be defined for older versions of O'Caml - Lineto, moveto and draw_rect. - -let rlineto x y = - let xc, yc = current_point () in - lineto (x + xc) (y + yc);; - -let rmoveto x y = - let xc, yc = current_point () in - moveto (x + xc) (y + yc);; - -let draw_rect x y w h = - let x0, y0 = current_point () in - moveto x y; - rlineto w 0; - rlineto 0 h; - rlineto (- w) 0; - rlineto 0 (-h); - moveto x0 y0;; -*) - -(* A set of points. *) - -set_color foreground;; - -let dashes y = - for i = 1 to 100 do - plot y (2 * i); - plot y (3 * i); - plot y (4 * i); - done;; - -dashes 3;; - -set_line_width 20;; -dashes (sz - 20);; - -(* Drawing chars *) - -draw_char 'C'; -draw_char 'a'; -draw_char 'm'; -draw_char 'l';; - -(* More and more red enlarging squares *) -moveto 10 10;; -set_line_width 5;; - -let carre c = - rlineto 0 c; - rlineto c 0; - rlineto 0 (- c); - rlineto (- c) 0;; - -for i = 1 to 10 do - moveto (10 * i) (10 * i); - set_color (rgb (155 + 10 * i) 0 0); - carre (10 * i) -done;; - -(* Blue squares in arithmetic progression *) -moveto 10 210;; -set_color blue;; -set_line_width 1;; - -for i = 1 to 10 do - carre (10 * i) -done;; - -(* Tiny circles filled or not *) -rmoveto 0 120;; -(* Must not change the current point *) -fill_circle 20 190 10;; -set_color green;; -rlineto 0 10;; -rmoveto 50 10;; -let x, y = current_point () in -(* Must not change the current point *) -draw_circle x y 20;; -set_color black;; -rlineto 0 20;; - -(* Cyan rectangles as a kind of graphical representation *) -set_color cyan;; - -let lw = 15;; -set_line_width lw;; -let go_caption l = moveto 210 (130 - lw + l);; -let go_legend () = go_caption (- 3 * lw);; - -go_caption 0;; -fill_rect 210 130 5 10;; -fill_rect 220 130 10 20;; -fill_rect 235 130 15 40;; -fill_rect 255 130 20 80;; -fill_rect 280 130 25 160;; -(* A green rectangle below the graph. *) -set_color green;; -rlineto 50 0;; - -(* A black frame for each of our rectangles *) -set_color black;; -set_line_width (lw / 4);; - -draw_rect 210 130 5 10;; -draw_rect 220 130 10 20;; -draw_rect 235 130 15 40;; -draw_rect 255 130 20 80;; -draw_rect 280 130 25 160;; - -(* A black rectangle after the green one, below the graph. *) -set_line_width lw;; -rlineto 50 0;; - -(* Write a text in yellow on a blue background. *) -(* x = 210, y = 70 *) -go_legend ();; -set_text_size 10;; -set_color (rgb 150 100 250);; -let x,y = current_point () in -fill_rect x (y - 5) (8 * 20) 25;; -set_color yellow;; -go_legend ();; -draw_string "Graphics (Caml)";; - -(* Pie parts in different colors. *) -let draw_green_string s = set_color green; draw_string s;; -let draw_red_string s = set_color red; draw_string s;; - -moveto 120 210;; -set_color red;; -fill_arc 150 260 25 25 60 300; -draw_green_string "A "; -draw_red_string "red"; -draw_green_string " pie."; - -set_text_size 5; -moveto 180 240; -draw_red_string "A "; draw_green_string "green"; draw_red_string " slice.";; -set_color green; -fill_arc 200 260 25 25 0 60; -set_color black; -set_line_width 2; -draw_arc 200 260 27 27 0 60;; - -(* Should do nothing since this is a line *) -set_color red;; -fill_poly [| (40, 10); (150, 70); (150, 10); (40, 10) |];; -set_color blue;; - -(* Drawing polygones. *) -(* Redefining the draw_poly primitive for the usual library. *) -let draw_poly v = - let l = Array.length v in - if l > 0 then begin - let x0, y0 = current_point () in - let p0 = v.(0) in - let x, y = p0 in moveto x y; - for i = 1 to l - 1 do - let x, y = v.(i) in lineto x y - done; - lineto x y; - moveto x0 y0 - end;; - -draw_poly [| (150, 10); (150, 70); (260, 10); (150, 10) |];; - -(* Filling polygones. *) -(* Two equilateral triangles, one red and one blue, and their inside - filled in black. *) -let equi x y l = - [| (x - l / 2, y); - (x, y + int_of_float (float_of_int l *. (sqrt 3.0 /. 2.0))); - (x + l / 2, y) |];; - -set_color black;; -fill_poly (Array.append (equi 300 20 40) (equi 300 44 (- 40)));; - -set_line_width 1;; -set_color cyan;; -draw_poly (equi 300 20 40);; -set_color red;; -draw_poly (equi 300 44 (- 40));; - -(* Drawing and filling ellipses. *) -let x, y = current_point () in -rlineto 10 10; moveto x y; - -moveto 395 100;; - -let x, y = current_point () in -fill_ellipse x y 25 15;; - -set_color (rgb 0xFF 0x00 0xFF);; -rmoveto 0 (- 50);; - -let x, y = current_point () in -fill_ellipse x y 15 30;; - -rmoveto (- 45) 0;; -let x, y = current_point () in -draw_ellipse x y 25 10;; - -(* Drawing and filling arcs. *) - -let draw_arc_ellipse x y r1 r2 = - set_color green; - draw_arc x y r1 r2 60 120; - set_color black; - draw_arc x y r1 r2 120 420;; - -set_line_width 3;; - -let draw_arc_ellipses x y r1 r2 = - let step = 5 in - for i = 0 to (r1 - step) / (2 * step) do - for j = 0 to (r2 - step) / (2 * step) do - draw_arc_ellipse x y (3 * i * step) (3 * j * step) - done - done;; - -draw_arc_ellipses 20 128 15 50;; - -let fill_arc_ellipse x y r1 r2 c1 c2 = - set_color c1; - fill_arc x y r1 r2 60 120; - set_color c2; - fill_arc x y r1 r2 120 420;; - -let fill_arc_ellipses x y r1 r2 = - let step = 3 in - let c1 = ref black - and c2 = ref yellow in - let exchange r1 r2 = let tmp = !r1 in r1 := !r2; r2 := tmp in - for i = r1 / (2 * step) downto 10 do - for j = r2 / (2 * step) downto 30 do - exchange c1 c2; - fill_arc_ellipse x y (3 * i) (3 * j) !c1 !c2 - done - done;; - -fill_arc_ellipses 400 240 150 200;; - - -synchronize ();; - -(* transparent color drawing *) -set_color transp;; -draw_circle 400 240 50;; -draw_circle 400 240 40;; -draw_circle 400 240 30;; -(* try to go back a normal color *) -set_color red;; -draw_circle 400 240 20;; - -synchronize ();; - -input_line stdin;; diff --git a/test/Moretest/signals.ml b/test/Moretest/signals.ml deleted file mode 100644 index ce93a27e2..000000000 --- a/test/Moretest/signals.ml +++ /dev/null @@ -1,32 +0,0 @@ -let rec tak (x, y, z as tuple) = - if x > y then tak(tak (x-1, y, z), tak (y-1, z, x), tak (z-1, x, y)) - else z - -let break_handler _ = - print_string "Thank you for pressing ctrl-C."; print_newline(); - print_string "Allocating a bit..."; flush stdout; - tak(18,12,6); print_string "done."; print_newline() - -let stop_handler _ = - print_string "Thank you for pressing ctrl-Z."; print_newline(); - print_string "Now raising an exception..."; print_newline(); - raise Exit - -let _ = - Sys.signal Sys.sigint (Sys.Signal_handle break_handler); - Sys.signal Sys.sigtstp (Sys.Signal_handle stop_handler); - begin try - print_string "Computing like crazy..."; print_newline(); - for i = 1 to 1000 do tak(18,12,6) done; - print_string "Reading on input..."; print_newline(); - for i = 1 to 5 do - try - let s = read_line () in - print_string ">> "; print_string s; print_newline() - with Exit -> - print_string "Got Exit, continuing."; print_newline() - done - with Exit -> - print_string "Got Exit, exiting."; print_newline() - end; - exit 0 |