#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Wed, 22 May 2019 21:16:57 +0200
changeset 2235 6b741d3d1881
parent 2234 29e38f216660
child 2236 d678c6a536ef
#QUALITY by cg class: RegressionTests::ParserTests added: #test_121_scan_specialStrings #test_121b_parse_specialStrings
RegressionTests__ParserTests.st
--- a/RegressionTests__ParserTests.st	Wed May 22 03:27:42 2019 +0000
+++ b/RegressionTests__ParserTests.st	Wed May 22 21:16:57 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 2006 by eXept Software AG
 	      All Rights Reserved
@@ -943,7 +945,7 @@
     self deny:arguments isNil.
     self assert:arguments size = 0.
 
-    "Created: / 09-01-2010 / 12:41:53 / Pavel Pospíchal <Pavel.Pospichal@gmail.com>"
+    "Created: / 09-01-2010 / 12:41:53 / Pavel PospĂ­chal <Pavel.Pospichal@gmail.com>"
     "Modified: / 11-01-2010 / 23:15:24 / pp <Pavel.Pospichal@gmail.com>"
 !
 
@@ -1785,6 +1787,74 @@
     self assert:( Number readSmalltalkSyntaxFrom:'-(1/3)' ) = (-1/3).
     self assert:( Number readSmalltalkSyntaxFrom:'-(-1/-3)' ) = (-1/3).
     self assert:( Number readSmalltalkSyntaxFrom:'+00000123.45') = 00000123.45.  
+!
+
+test_121_scan_specialStrings    
+    |s tok str|
+
+    "/ c-strings in scanner
+    s := Scanner for:' c''\n\t\\\a'' '.
+    tok := s nextToken.
+    self assert:(tok == #String).
+    self assert:(s tokenValue = (String         
+                                    with:Character nl 
+                                    with:Character tab 
+                                    with:$\
+                                    with:$a)).
+
+    "/ c-strings in stc (if compiled)
+    str := c'\n\t\\\a'.
+    self assert:(str = (String         
+                                    with:Character nl 
+                                    with:Character tab 
+                                    with:$\
+                                    with:$a)).
+
+    "/ expanded-string
+    s := Scanner for:' e''one: \{ 123 } two: \{ 122+2 }\n'' '.
+    tok := s nextToken.
+    self assert:(tok == #StringFragment).
+    self assert:(s tokenValue = 'one: ').
+
+    tok := s nextToken.
+    self assert:(tok == #Integer).
+
+    tok := s nextToken.
+    self assert:(tok == $}).
+
+    tok := s continueEscapedString.
+    self assert:(tok == #StringFragment).
+    self assert:(s tokenValue = ' two: ').
+    
+    tok := s nextToken.
+    self assert:(tok == #Integer).
+    tok := s nextToken.
+    self assert:(tok == #BinaryOperator).
+    self assert:(s tokenName = '+').
+    tok := s nextToken.
+    self assert:(tok == #Integer).
+
+    tok := s nextToken.
+    self assert:(tok == $}).
+
+    tok := s continueEscapedString.
+    self assert:(tok == #String).
+    self assert:(s tokenValue = Character nl asString).
+
+    "Created: / 22-05-2019 / 20:10:24 / Claus Gittinger"
+!
+
+test_121b_parse_specialStrings    
+    |p expr|
+
+    "/ expanded-string
+    p := Parser for:' e''one: \{ 123 } two: \{ 122+2 }\n'' '.
+    p nextToken.
+    expr := p expression.
+    self assert:(expr isMessage).
+    self assert:(expr evaluate = c'one: 123 two: 124\n').
+
+    "Created: / 22-05-2019 / 20:56:40 / Claus Gittinger"
 ! !
 
 !ParserTests methodsFor:'tests - sysprim'!