PageRenderTime 20ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/regular_expression/test_substitute_01.e

http://github.com/tybor/Liberty
Specman e | 101 lines | 58 code | 17 blank | 26 comment | 0 complexity | 58b8fc6cfa65ca1633f7bb215d2e04c0 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_SUBSTITUTE_01
  5   --
  6   -- Testing:
  7   --   prepare_substitution
  8   --   substitute_for
  9   --   substitute_all_for
 10
 11insert
 12   EIFFELTEST_TOOLS
 13
 14create {}
 15   make
 16
 17feature {}
 18   make
 19      local
 20         aa_matcher: REGULAR_EXPRESSION
 21      do
 22         create {AUX_SUBSTITUTE_01} aa_matcher
 23         aa_matcher.prepare_substitution("\1bc")
 24         assert(not aa_matcher.match(text1))
 25         assert(aa_matcher.match(text2))
 26         aa_matcher.substitute_for(text2)
 27         assert(aa_matcher.last_substitution.is_equal(sub2))
 28         assert(aa_matcher.match(text3))
 29         aa_matcher.substitute_for(text3)
 30         assert(aa_matcher.last_substitution.is_equal(sub3))
 31         assert(aa_matcher.match(text4))
 32         aa_matcher.substitute_for(text4)
 33         assert(aa_matcher.last_substitution.is_equal(sub4))
 34         assert(aa_matcher.match(text5))
 35         aa_matcher.substitute_for(text5)
 36         assert(aa_matcher.last_substitution.is_equal(sub5))
 37         assert(aa_matcher.match(text6))
 38         aa_matcher.substitute_for(text6)
 39         assert(aa_matcher.last_substitution.is_equal(sub6))
 40         aa_matcher.substitute_all_for(text1)
 41         assert(aa_matcher.last_substitution.is_equal(text1))
 42         aa_matcher.substitute_all_for(text2)
 43         assert(aa_matcher.last_substitution.is_equal(sub2))
 44         aa_matcher.substitute_all_for(text3)
 45         assert(aa_matcher.last_substitution.is_equal(sub3))
 46         aa_matcher.substitute_all_for(text4)
 47         assert(aa_matcher.last_substitution.is_equal(sub4))
 48         aa_matcher.substitute_all_for(text5)
 49         assert(aa_matcher.last_substitution.is_equal(sub5))
 50         aa_matcher.substitute_all_for(text6)
 51         assert(aa_matcher.last_substitution.is_equal(suball6))
 52         assert(aa_matcher.match_from(text6, 2))
 53         aa_matcher.substitute_for(text6)
 54         assert(aa_matcher.last_substitution.is_equal(subfrom6))
 55      end
 56
 57   text1: STRING "Little message without the pattern."
 58
 59   text2: STRING "aa apears one time in the begining."
 60
 61   text3: STRING "The pattern aa in the middle."
 62
 63   text4: STRING "Here in the end aa"
 64
 65   text5: STRING "aa"
 66
 67   text6: STRING "aa pattern appears many times aa in the string."
 68
 69   sub2: STRING "abc apears one time in the begining."
 70
 71   sub3: STRING "The pattern abc in the middle."
 72
 73   sub4: STRING "Here in the end abc"
 74
 75   sub5: STRING "abc"
 76
 77   sub6: STRING "abc pattern appears many times aa in the string."
 78
 79   suball6: STRING "abc pattern appears many times abc in the string."
 80
 81   subfrom6: STRING "aa pattern appears many times abc in the string."
 82
 83end -- class TEST_SUBSTITUTE_01
 84--
 85-- ------------------------------------------------------------------------------------------------------------------------------
 86-- Copyright notice below. Please read.
 87--
 88-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License,
 89-- as published by the Free Software Foundation; either version 2, or (at your option) any later version.
 90-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty
 91-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
 92-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free
 93-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 94--
 95-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P.       - University of Nancy 1 - FRANCE
 96-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE
 97--
 98-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN
 99--
100-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr
101-- ------------------------------------------------------------------------------------------------------------------------------