#QUALITY by exept
authorClaus Gittinger <cg@exept.de>
Tue, 20 Aug 2019 09:46:37 +0200
changeset 2388 6ac280a6d988
parent 2387 977c661d3399
child 2389 481588f3ca33
#QUALITY by exept class: RegressionTests::StringTests added: #test82f_expanding changed: #test42c_includesSeparator
RegressionTests__StringTests.st
--- a/RegressionTests__StringTests.st	Sun Aug 18 00:20:42 2019 +0200
+++ b/RegressionTests__StringTests.st	Tue Aug 20 09:46:37 2019 +0200
@@ -1028,6 +1028,31 @@
 !
 
 test42c_includesSeparator
+    self assert:('' includesSeparator not).
+    self assert:('a' includesSeparator not).
+    self assert:('ab' includesSeparator not).
+    self assert:('abc' includesSeparator not).
+    self assert:('abcd' includesSeparator not).
+    self assert:('abcde' includesSeparator not).
+    self assert:('abcdef' includesSeparator not).
+    self assert:('abcdefg' includesSeparator not).
+    self assert:('abcdefgh' includesSeparator not).
+    self assert:('a ' includesSeparator).
+    self assert:('ab ' includesSeparator).
+    self assert:('abc ' includesSeparator).
+    self assert:('abcd ' includesSeparator).
+    self assert:('abcde ' includesSeparator).
+    self assert:('abcdef ' includesSeparator).
+    self assert:('abcdefg ' includesSeparator).
+    self assert:('abcdefgh ' includesSeparator).
+    self assert:(' a' includesSeparator).
+    self assert:(' ab' includesSeparator).
+    self assert:(' abc' includesSeparator).
+    self assert:(' abcd' includesSeparator).
+    self assert:(' abcde' includesSeparator).
+    self assert:(' abcdef' includesSeparator).
+    self assert:(' abcdefg' includesSeparator).
+    self assert:(' abcdefgh' includesSeparator).
     self assert:('hello' includesSeparator not).
     self assert:('he llo' includesSeparator).
     self assert:(' hello' includesSeparator).
@@ -2065,6 +2090,41 @@
     self assert:(rslt = ('abc',String crlf,'def')).
 !
 
+test82f_expanding
+    "special cases:"
+
+    | rslt |
+
+    rslt := '%' bindWith:'aaa'.
+    self assert:(rslt = '%').
+
+    rslt := '%1' bindWith:'aaa'.
+    self assert:(rslt = 'aaa').
+    rslt := '%1b' bindWith:'aaa'.
+    self assert:(rslt = 'aaab').
+    rslt := '%2' bindWith:'aaa'.
+    self assert:(rslt = '').
+    rslt := '%9' bindWith:'aaa'.
+    self assert:(rslt = '').
+    rslt := '%9' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9).  
+    self assert:(rslt = 'i9').
+    rslt := '%1x' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9 j10).
+    self assert:(rslt = 'a1x').
+    rslt := '%10' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9 j10).
+    self assert:(rslt = 'j10').
+    rslt := '%10x' bindWithArguments:#(a1 b2 c3 d4 e5 f6 g7 h8 i9 j10).
+    self assert:(rslt = 'j10x').
+
+    rslt := 'hello %10%9%8' expandPlaceholders:$% with:{ 'x1' . 'x2' . 'x3' . 'x4' . 'x5' . 'x6' . 'x7' . 'x8' . 'x9' . 'x10' }.
+    self assert:(rslt = 'hello x10x9x8').
+    rslt := 'hello %10' expandPlaceholders:$% with:{ 'x1' . 'x2' . 'x3' . 'x4' . 'x5' . 'x6' . 'x7' . 'x8' . 'x9' . 'x10' }.
+    self assert:(rslt = 'hello x10').
+    rslt := 'hello %(1)x' expandPlaceholders:$% with:{ 'x1' . 'x2' . 'x3' . 'x4' . 'x5' . 'x6' . 'x7' . 'x8' . 'x9' . 'x10' }.
+    self assert:(rslt = 'hello x1x').
+
+    self should:[ rslt := '%(' bindWith:'aaa' ] raise:Error.
+!
+
 test83_padding
     | rslt |