Hi,

I've imported a file with STLoader and while I've tried to print the ProxyNamespace
it never ended. I've changed the print function that only prints the
name (like a classical namespace) and the examineOn: function
display all the objects inside the namespace.

Cheers,
Gwen

>From 2732fe58d25db710fe648010e187efc52fb026e4 Mon Sep 17 00:00:00 2001
From: Gwenael Casaccio <mrg...@gmail.com>
Date: Tue, 3 Sep 2013 14:58:42 +0200
Subject: [PATCH] Fix an inifinite recursion while printing ProxyNamespace

---
 packages/stinst/parser/ChangeLog            |  5 +++
 packages/stinst/parser/STLoaderObjs.st      | 25 +++++++------
 packages/stinst/parser/STLoaderObjsTests.st | 55 +++++++++++++++++++++++++++++
 packages/stinst/parser/package.xml          |  2 ++
 tests/stcompiler.ok                         |  3 +-
 5 files changed, 77 insertions(+), 13 deletions(-)
 create mode 100644 packages/stinst/parser/STLoaderObjsTests.st

diff --git a/packages/stinst/parser/ChangeLog b/packages/stinst/parser/ChangeLog
index 9c73d6f..072a89c 100644
--- a/packages/stinst/parser/ChangeLog
+++ b/packages/stinst/parser/ChangeLog
@@ -1,5 +1,10 @@
 2013-08-10  Gwenael Casaccio <gwenael.casac...@gmail.com>
 
+	* STLoaderObjs.st: Fix ProxyNamespace>>#printOn: and add ProxyNamespace>>#examineOn:.
+	* STLoaderObjsTests.st: Add testcase for ProxyNamespace>>#printOn:.
+
+2013-08-10  Gwenael Casaccio <gwenael.casac...@gmail.com>
+
 	* RBParser.st: Fix RBScanner>>#scanNumberValue.
 	* RewriteTests.st: Add testcase for number and array literal parsing.
 
diff --git a/packages/stinst/parser/STLoaderObjs.st b/packages/stinst/parser/STLoaderObjs.st
index 9bbb0ea..1bbf91d 100644
--- a/packages/stinst/parser/STLoaderObjs.st
+++ b/packages/stinst/parser/STLoaderObjs.st
@@ -1507,19 +1507,22 @@ name
 
 printOn: aStream
     "Print a representation of the receiver on aStream"
-    aStream nextPutAll: self class storeString , '[', proxy name, '] (' ; nl.
+    aStream nextPutAll: self class storeString , '[', proxy name, ']'.
+!
+
+examineOn: aStream
+    "Print a representation of the receiver on aStream"
+    aStream 
+        print: self;
+        nextPutAll: ' ('.
     self myKeysAndValuesDo:
         [ :key :value |
-            "The ProxyNamespace is linked to itself in
-             ProxyNamespace class>>#on:for: so we need to skip ourself
-             here or we will loop forever."
-            value == self ifFalse: [
-                aStream tab;
-                    print: key;
-                    nextPutAll: '->';
-                    print: value;
-                    nl ].
-        ].
+            aStream 
+                tab;
+                print: key;
+                nextPutAll: '->';
+                print: value;
+                nl ].
     aStream nextPut: $)
 !
 
diff --git a/packages/stinst/parser/STLoaderObjsTests.st b/packages/stinst/parser/STLoaderObjsTests.st
new file mode 100644
index 0000000..5a10e0a
--- /dev/null
+++ b/packages/stinst/parser/STLoaderObjsTests.st
@@ -0,0 +1,55 @@
+"======================================================================
+|
+|   STLoaderObjsTests tests
+|
+|
+ ======================================================================"
+
+"======================================================================
+|
+| Copyright (C) 2007,2013 Free Software Foundation, Inc.
+| Written by Stephen Compall.
+|
+| This file is part of the GNU Smalltalk class library.
+|
+| The GNU Smalltalk class library is free software; you can redistribute it
+| and/or modify it under the terms of the GNU Lesser General Public License
+| as published by the Free Software Foundation; either version 2.1, or (at
+| your option) any later version.
+| 
+| The GNU Smalltalk class library is distributed in the hope that it will be
+| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
+| General Public License for more details.
+| 
+| You should have received a copy of the GNU Lesser General Public License
+| along with the GNU Smalltalk class library; see the file COPYING.LIB.
+| If not, write to the Free Software Foundation, 59 Temple Place - Suite
+| 330, Boston, MA 02110-1301, USA.  
+|
+ ======================================================================"
+
+
+
+Namespace current: STInST.Tests [
+
+    TestCase subclass: TestSTLoaderObjects [
+    
+        testProxyNamespacePrinting [
+	    <category: 'testing'>
+
+            | stream |
+
+            stream := WriteStream on: String new.
+            class := (STClassLoader new
+                    parseSmalltalkStream: 'Object subclass: Xork.Bar.TestData [
+                        logManager [
+                            ^Osmo.LogManager default
+                        ]
+                    ]' readStream with: GSTFileInParser) first.
+
+            class environment printOn: stream.
+            self assert: stream contents = 'STInST.STClassLoaderObjects.ProxyNamespace[Bar]'.
+        ]
+    ]
+]
diff --git a/packages/stinst/parser/package.xml b/packages/stinst/parser/package.xml
index a57efbb..e4881fd 100644
--- a/packages/stinst/parser/package.xml
+++ b/packages/stinst/parser/package.xml
@@ -35,9 +35,11 @@
    <sunit>STInST.Tests.TestDefaultPoolResolution</sunit>
    <sunit>STInST.Tests.TestClassicPoolResolution</sunit>
    <sunit>STInST.Tests.TestDebugInformation</sunit>
+   <sunit>STInST.Tests.TestSTLoaderObjects</sunit>
    <filein>RewriteTests.st</filein>
    <filein>PoolResolutionTests.st</filein>
    <filein>DebugInformationTests.st</filein>
+   <filein>STLoaderObjsTests.st</filein>
   </test>
 
   <file>ChangeLog</file>
diff --git a/tests/stcompiler.ok b/tests/stcompiler.ok
index 4587736..ee3769e 100644
--- a/tests/stcompiler.ok
+++ b/tests/stcompiler.ok
@@ -52,8 +52,7 @@ Execution begins...
 returned value is 'an'
 
 Execution begins...
-STInST.STClassLoaderObjects.ProxyNamespace[Smalltalk] (
-)
+STInST.STClassLoaderObjects.ProxyNamespace[Smalltalk]
 returned value is ProxyNamespace new: 32 "<0>"
 
 Execution begins...
-- 
1.8.1.2

_______________________________________________
help-smalltalk mailing list
help-smalltalk@gnu.org
https://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to