home *** CD-ROM | disk | FTP | other *** search
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- class TEST_REAL
-
- creation {ANY}
- make
-
- feature {ANY}
-
- make is
- local
- i: INTEGER;
- r: REAL;
- do
- is_true(1. = 1.);
- is_true(0.0 = 0.);
- is_true(1.05 = 1.050);
-
-
- r := 1.6;
- is_true(r = r);
- is_true(r = 1.6);
- is_true(r >= 1.59);
- is_true(r <= 1.61);
-
- is_true(1. < 1.1);
- is_true(1. <= 1.1);
- is_true(0. < 0.5);
- is_true(0. <= 0.5);
- is_true(-0.5 < 0.);
- is_true(-0.5 <= 0.5);
- is_true(-1.5 < 1.5);
- is_true(-1.5 <= 1.5);
-
- is_true(1.1 > 1.);
- is_true(1.1 > 1);
- is_true(1.1 >= 1.);
- is_true(1.1 >= 1);
- is_true(0.5 > 0.);
- is_true(0.5 > 0);
- is_true(0. > -0.5);
- is_true(0.5 >= -0.5);
- is_true(1.5 > -1.5);
- is_true(1.5 >= -1.5);
-
-
- is_true(1. + 1. = 2.0);
-
- is_true(+1.5 = 1.5);
- is_true(-1.5 = - +1.5);
-
- r := 2;
- is_true(r = 2.0);
-
- i := 2;
- r := i;
- is_true(r = 2);
- is_true(r = 2.0);
-
- is_true((3.5).floor = 3);
- is_true((3.5).ceiling = 4);
-
- is_true((-3.5).floor = -4);
- is_true((-3.5).ceiling = -3);
-
- is_true((0.6).floor = 0);
- is_true((0.4).ceiling = 1);
-
- is_true((0.4).truncated_to_integer = 0);
- is_true((0.51).truncated_to_integer = 1);
- is_true((1.49).truncated_to_integer = 1);
- is_true((1.51).truncated_to_integer = 2);
-
- r := (1.51).to_string.to_real;
- is_true(r < 1.511);
- is_true(r > 1.509);
-
- r := (-1.51).to_string.to_real;
- is_true(r > -1.52);
- is_true(r < -1.50);
-
- is_true(r.abs < 1.52);
- is_true(r.abs > 1.50);
- is_true((-r).abs < 1.52);
- is_true((-r).abs > 1.50);
-
- is_true((3.5).min(4.5) = 3.5);
- is_true((4.5).min(3.5) = 3.5);
-
- is_true((3.5).max(4.5) = 4.5);
- is_true((4.5).max(3.5) = 4.5);
-
- is_true((-3.5).min(-4.5) = -4.5);
- is_true((-4.5).min(-3.5) = -4.5);
-
- is_true((-3.5).max(-4.5) = -3.5);
- is_true((-4.5).max(-3.5) = -3.5);
-
- r := 3.1 ^ 2;
- is_true(r > 9.6099989);
- is_true(r < 9.6199999);
-
- is_true((4.0).sqrt = 2.0);
- end;
-
- is_true(b: BOOLEAN) is
- do
- cpt := cpt + 1;
- if not b then
- std_output.put_string("TEST_REAL: ERROR Test # ");
- std_output.put_integer(cpt);
- std_output.put_string("%N");
- else
- -- std_output.put_string("Yes%N");
- end;
- end;
-
- cpt: INTEGER;
-
- end -- TEST_REAL
-