help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] [PATCH] stinst: Make RBScanner>>#scanNumber work for th


From: Holger Hans Peter Freyther
Subject: [Help-smalltalk] [PATCH] stinst: Make RBScanner>>#scanNumber work for the ConcatenatedStream
Date: Sun, 10 Feb 2013 20:07:52 +0100

From: Holger Hans Peter Freyther <address@hidden>

The species of the ConcatenatedStream is Array so we will need to
convert the result of reading from the stream with >>#next: to a
String first before we can trim the separators.

2013-02-10  Holger Hans Peter Freyther  <address@hidden>

        * RBParser.st: Change RBScanner>>#scanNumber to convert
        the result to a String.
        * RewriteTests.st: Add testcase for RBScanner>>#scanNumber.
        * package.xml: Add the new test to the testsuite.
---
 packages/stinst/parser/ChangeLog       |    7 +++++++
 packages/stinst/parser/RBParser.st     |    2 +-
 packages/stinst/parser/RewriteTests.st |   23 ++++++++++++++++++++++-
 packages/stinst/parser/package.xml     |    1 +
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/packages/stinst/parser/ChangeLog b/packages/stinst/parser/ChangeLog
index 31a5b2e..c20da6c 100644
--- a/packages/stinst/parser/ChangeLog
+++ b/packages/stinst/parser/ChangeLog
@@ -1,3 +1,10 @@
+2013-02-10  Holger Hans Peter Freyther  <address@hidden>
+
+       * RBParser.st: Change RBScanner>>#scanNumber to convert
+       the result to a String.
+       * RewriteTests.st: Add testcase for RBScanner>>#scanNumber.
+       * package.xml: Add the new test to the testsuite.
+
 2013-02-08  Holger Hans Peter Freyther  <address@hidden>
 
        * RBFormatter.st: Use the RBToken>>#storeOn: for writing.
diff --git a/packages/stinst/parser/RBParser.st 
b/packages/stinst/parser/RBParser.st
index 6f2b1cb..258e039 100644
--- a/packages/stinst/parser/RBParser.st
+++ b/packages/stinst/parser/RBParser.st
@@ -1328,7 +1328,7 @@ Stream subclass: RBScanner [
 
         "Get the parsed source"
         stream position: tokenStart - 1.
-        string := (stream next: stop - start + 1) trimSeparators.
+        string := (stream next: stop - start + 1) asString trimSeparators.
         stream position: stop.
 
        ^RBNumberLiteralToken
diff --git a/packages/stinst/parser/RewriteTests.st 
b/packages/stinst/parser/RewriteTests.st
index 8964b07..47132e8 100644
--- a/packages/stinst/parser/RewriteTests.st
+++ b/packages/stinst/parser/RewriteTests.st
@@ -7,7 +7,7 @@
 
 "======================================================================
 |
-| Copyright (C) 2007 Free Software Foundation, Inc.
+| Copyright (C) 2007,2013 Free Software Foundation, Inc.
 | Written by Stephen Compall.
 |
 | This file is part of the GNU Smalltalk class library.
@@ -280,5 +280,26 @@ TestCase subclass: TestFormat [
     ]
 ]
 
+TestCase subclass: TestScanner [
+    <comment: 'Test aspects of the RBScanner'>
+
+    testScanner [
+        | scanner num |
+        scanner := RBScanner on: '3' readStream.
+        num := scanner next.
+        self assert: num value = 3.
+    ]
+
+    testScannerConcatStream [
+        | scanner num |
+        "This is different to >>#testScanner by using a different kind of 
stream with
+        a different species."
+
+        scanner := RBScanner on: (Kernel.ConcatenatedStream with: '3' 
readStream).
+        num := scanner next.
+        self assert: num value = 3.
+    ]
+]
+
 ]
 
diff --git a/packages/stinst/parser/package.xml 
b/packages/stinst/parser/package.xml
index 47c7fb6..f997197 100644
--- a/packages/stinst/parser/package.xml
+++ b/packages/stinst/parser/package.xml
@@ -29,6 +29,7 @@
    <namespace>STInST.Tests</namespace>
    <sunit>STInST.Tests.TestStandardRewrites</sunit>
    <sunit>STInST.Tests.TestFormat</sunit>
+   <sunit>STInST.Tests.TestScanner</sunit>
    <sunit>STInST.Tests.TestDefaultPoolResolution</sunit>
    <sunit>STInST.Tests.TestClassicPoolResolution</sunit>
    <filein>RewriteTests.st</filein>
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]