PageRenderTime 21ms CodeModel.GetById 18ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/test/language/unclassified/test_general1.e

http://github.com/tybor/Liberty
Specman e | 128 lines | 74 code | 12 blank | 42 comment | 1 complexity | ed9cbee64cd7c3306c1661f024e4a8d7 MD5 | raw file
  1-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries.
  2-- See the Copyright notice at the end of this file.
  3--
  4class TEST_GENERAL1
  5
  6create {}
  7   make
  8
  9feature {ANY}
 10   any: ABSTRACT_STRING
 11
 12   ai8: ARRAY[INTEGER_8]
 13
 14   ai: ARRAY[INTEGER]
 15
 16   ar: ARRAY[REAL]
 17
 18   d: DICTIONARY[STRING, STRING]
 19
 20   cat: CAT
 21
 22   dog: DOG
 23
 24   make
 25      local
 26         i: INTEGER
 27      do
 28         -- Testing `generating_type' ----------------------------- :
 29         assert(generating_type.is_equal("TEST_GENERAL1"))
 30         create ai.make(1, 2)
 31         assert(("ARRAY[INTEGER_32]").is_equal(ai.generating_type))
 32         create ai8.make(1, 2)
 33         assert(("ARRAY[INTEGER_8]").is_equal(ai8.generating_type))
 34         create ar.make(1, 2)
 35         assert(("ARRAY[REAL_64]").is_equal(ar.generating_type))
 36         create {HASHED_DICTIONARY[STRING, STRING]} d.make
 37         assert(d.generating_type.is_equal("HASHED_DICTIONARY[STRING,STRING]"))
 38         assert(i.generating_type.is_equal("INTEGER_32"))
 39         assert(i.force_to_real_32.generating_type.is_equal("REAL_32"))
 40         assert(i.to_real_64.generating_type.is_equal("REAL_64"))
 41         assert(i.digit.generating_type.is_equal("CHARACTER"))
 42         assert(i.to_string.generating_type.is_equal("STRING"))
 43         assert(i.to_string.to_integer.generating_type.is_equal("INTEGER_32"))
 44         any := i.to_string
 45         assert(any.generating_type.is_equal("STRING"))
 46         -- INTEGER does not conform to ANY (Vincent Croizier, 02/11/2004)
 47         --any := i
 48         --assert(any.generating_type.has_prefix("reference INTEGER"))
 49         assert(i.generating_type.has_prefix("INTEGER"))
 50         -- Testing `generator' ----------------------------------- :
 51         assert(generator.is_equal("TEST_GENERAL1"))
 52         assert(("ARRAY").is_equal(ai.generator))
 53         assert(("ARRAY").is_equal(ar.generator))
 54         assert(d.generator.is_equal("HASHED_DICTIONARY"))
 55         assert(i.generator.is_equal("INTEGER_32"))
 56         assert(i.force_to_real_32.generator.is_equal("REAL_32"))
 57         assert(i.to_real_64.generator.is_equal("REAL_64"))
 58         assert(i.to_real_64.generating_type.is_equal("REAL_64"))
 59         assert(i.digit.generator.is_equal("CHARACTER"))
 60         assert(i.to_string.generator.is_equal("STRING"))
 61         any := i.to_string
 62         assert(any.generator.is_equal("STRING"))
 63         -- INTEGER does not conform to ANY (Vincent Croizier, 02/11/2004)
 64         --any := i
 65         --assert(any.generator.is_equal("INTEGER_32"))
 66         --assert(any.generating_type.is_equal("reference INTEGER"))
 67         assert(i.generating_type.is_equal("INTEGER_32"))
 68         -- Testing `object_size' --------------------------------- :
 69         create cat
 70         create dog
 71         assert(1.object_size >= True.object_size)
 72         assert('a'.object_size = 1)
 73         assert(dog.object_size = cat.object_size)
 74         assert(object_size > i.object_size)
 75         -- *** Correctly rejected *** (Dom. nov 10th 2004) *** any := dog
 76         assert(dog.object_size /= any.object_size)
 77         -- Testing `same_dynamic_type' --------------------------- :
 78         assert(same_dynamic_type(Current))
 79         assert(ai8.same_dynamic_type({ARRAY[INTEGER_8] 1, << 1, 2 >> }))
 80         assert(ai.same_dynamic_type({ARRAY[INTEGER] 1, << 1, 2 >> }))
 81         assert(ar.same_dynamic_type({ARRAY[REAL] 1, << 0.5 >> }))
 82         -- *** ARRAY[INTEGER] doesn't conform to ARRAY[REAL] (Vincent Croizier, 05/11/2004) ***
 83         -- assert(not ar.same_dynamic_type(ai))
 84         assert(d.same_dynamic_type(d.twin))
 85         i := 7
 86         assert(i.to_string.same_dynamic_type("foo"))
 87         -- INTEGER does not conform to ANY (Vincent Croizier, 02/11/2004)
 88         --any := i
 89         --assert(any.same_dynamic_type(i))
 90         -- ARRAY[REAL] does not conform to ANY
 91         --any := ar
 92         --assert(any.same_dynamic_type(ar))
 93      end
 94
 95   assert (b: BOOLEAN)
 96      do
 97         cpt := cpt + 1
 98         if not b then
 99            sedb_breakpoint
100            std_output.put_string("TEST_GENERAL1: ERROR Test # ")
101            std_output.put_integer(cpt)
102            std_output.put_string("%N")
103         else
104            --std_output.put_string("Yes%N")
105         end
106      end
107
108   cpt: INTEGER
109
110end -- class TEST_GENERAL1
111--
112-- ------------------------------------------------------------------------------------------------------------------------------
113-- Copyright notice below. Please read.
114--
115-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
116-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
117-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
118-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
119-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
120-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
121--
122-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
123-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
124--
125-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
126--
127-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
128-- ------------------------------------------------------------------------------------------------------------------------------