home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / eiffel / smalleif.97 / se.t / SmallEiffel / lib_test / test_general1.e < prev    next >
Encoding:
Text File  |  1996-05-02  |  3.3 KB  |  124 lines

  1. -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C) 
  2. -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
  3. --
  4. class TEST_GENERAL1
  5.  
  6. creation {ANY}
  7.    make
  8.    
  9. feature {ANY}
  10.    
  11.    any: ANY;
  12.    
  13.    ai: ARRAY[INTEGER];
  14.    
  15.    ar: ARRAY[REAL];
  16.    
  17.    d: DICTIONARY[STRING,STRING];
  18.    
  19.    cat: CAT;
  20.    
  21.    dog: DOG;
  22.    
  23.    make is
  24.       local
  25.      i: INTEGER;
  26.       do
  27.      -- Testing `generating_type' ----------------------------- :
  28.      is_true(generating_type.is_equal("TEST_GENERAL1"));
  29.      
  30.      !!ai.make(1,2);
  31.      is_true(("ARRAY[INTEGER]").is_equal(ai.generating_type));
  32.      
  33.      !!ar.make(1,2);
  34.      is_true(("ARRAY[REAL]").is_equal(ar.generating_type));
  35.      
  36.      !!d.make;
  37.      is_true(d.generating_type.is_equal("DICTIONARY[STRING,STRING]"));
  38.  
  39.      is_true(i.generating_type.is_equal("INTEGER"));
  40.      
  41.      is_true(i.to_real.generating_type.is_equal("REAL"));
  42.      
  43.      is_true(i.to_double.generating_type.is_equal("DOUBLE"));
  44.      
  45.      is_true(i.digit.generating_type.is_equal("CHARACTER"));
  46.  
  47.      is_true(i.to_string.generating_type.is_equal("STRING"));
  48.      
  49.      is_true(i.to_string.to_integer.generating_type.is_equal("INTEGER"));
  50.      
  51.      any := i.to_string;
  52.      is_true(any.generating_type.is_equal("STRING"));
  53.      
  54.      any := i;
  55.      is_true(any.generating_type.is_equal("INTEGER_REF"));
  56.      
  57.       
  58.      -- Testing `generator' ----------------------------------- :
  59.      is_true(generator.is_equal("TEST_GENERAL1"));
  60.      is_true(("ARRAY").is_equal(ai.generator));
  61.      is_true(("ARRAY").is_equal(ar.generator));
  62.      is_true(d.generator.is_equal("DICTIONARY"));
  63.      is_true(i.generator.is_equal("INTEGER"));
  64.      is_true(i.to_real.generator.is_equal("REAL"));
  65.      is_true(i.to_double.generator.is_equal("DOUBLE"));
  66.      is_true(i.digit.generator.is_equal("CHARACTER"));
  67.      is_true(i.to_string.generator.is_equal("STRING"));
  68.      any := i.to_string;
  69.      is_true(any.generator.is_equal("STRING"));
  70.      any := i;
  71.      is_true(any.generator.is_equal("INTEGER_REF"));
  72.      
  73.      -- Testing `object_id' and `id_object'-------------------- :
  74.      is_true(Current = id_object(object_id));
  75.      is_true(("ARRAY").object_id /= ("ARRAY").object_id);
  76.      i := ar.object_id;
  77.      is_true(id_object(i) = ar);
  78.      
  79.      -- Testing `object_size' --------------------------------- :
  80.      !!cat;
  81.      !!dog;
  82.      is_true((1).object_size = (true).object_size);
  83.      is_true(('a').object_size = 1);
  84.      is_true(dog.object_size = cat.object_size);
  85.      is_true(dog.object_size >= i.object_size);
  86.      is_true(object_size > i.object_size);
  87.      any := dog;
  88.      is_true(dog.object_size = any.object_size);
  89.           
  90.      -- Testing `same_type' ----------------------------------- :
  91.      is_true(same_type(Current));
  92.      is_true(ai.same_type(<<1,2>>));
  93.      is_true(ar.same_type(<<0.5>>));
  94.      is_true(not ar.same_type(ai));
  95.      is_true(d.same_type(clone(d)));
  96. -- ***     is_true(i.same_type(3+1));
  97. -- ***     is_true(i.to_real.same_type(3.5));
  98. -- ***     is_true(i.to_double.same_type((4).to_double));
  99.      i := 7;
  100. -- ***     is_true(i.digit.same_type('a'));
  101.      is_true(i.to_string.same_type("foo"));
  102.      any := i;
  103.      is_true(any.same_type(i));
  104.      any := ar;
  105.      is_true(any.same_type(ar));
  106.      
  107.       end;
  108.    
  109.    is_true(b: BOOLEAN) is
  110.       do
  111.      cpt := cpt + 1;
  112.      if not b then
  113.         std_output.put_string("TEST_GENERAL1: ERROR Test # ");
  114.         std_output.put_integer(cpt);
  115.         std_output.put_string("%N");
  116.      else
  117.         -- std_output.put_string("Yes%N");
  118.      end;
  119.       end;
  120.    
  121.    cpt: INTEGER;
  122.    
  123. end -- class TEST_GENERAL1
  124.