Issue 3666 in pharo: Ensure that classOrTraitNamed: doesn't return globals.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 3666 in pharo: Ensure that classOrTraitNamed: doesn't return globals.

pharo
Status: Accepted
Owner: [hidden email]
Labels: Milestone-1.3

New issue 3666 by [hidden email]: Ensure that classOrTraitNamed:  
doesn't return globals.
http://code.google.com/p/pharo/issues/detail?id=3666

Ensure that classOrTraitNamed: doesn't return globals.

=============== Diff against System-ul.409 ===============

Item was changed:
  ----- Method: SystemDictionary>>classOrTraitNamed: (in category 'classes  
and traits') -----
  classOrTraitNamed: aString
        "aString is either a class or trait name or a class or trait name  
followed by ' class' or 'classTrait' respectively.
        Answer the class or metaclass it names."

+       | meta baseName |
-       | meta baseName baseClass |
        (aString endsWith: ' class')
                ifTrue: [meta := true.
                                baseName := aString copyFrom: 1 to: aString  
size - 6]
                ifFalse: [
                        (aString endsWith: ' classTrait')
                                ifTrue: [
                                        meta := true.
                                        baseName := aString copyFrom: 1 to:  
aString size - 11]
                                ifFalse: [
                                        meta := false.
                                        baseName := aString]].
+
+       ^self at: baseName asSymbol ifPresent:
+               [ :global |
+               global isBehavior ifTrue:
+                       [ meta
+                               ifFalse: [ global ]
+                               ifTrue: [ global classSide ]]]!
-       baseClass := Smalltalk at: baseName asSymbol ifAbsent: [^ nil].
-       meta
-               ifTrue: [^ baseClass classSide]
-               ifFalse: [^ baseClass]!


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3666 in pharo: Ensure that classOrTraitNamed: doesn't return globals.

pharo
Updates:
        Labels: Type-Squeak Difficulty-Easy

Comment #1 on issue 3666 by [hidden email]: Ensure that  
classOrTraitNamed: doesn't return globals.
http://code.google.com/p/pharo/issues/detail?id=3666

(No comment was entered for this change.)


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3666 in pharo: Ensure that classOrTraitNamed: doesn't return globals.

pharo

Comment #2 on issue 3666 by [hidden email]: Ensure that  
classOrTraitNamed: doesn't return globals.
http://code.google.com/p/pharo/issues/detail?id=3666

Tests for System-fbs.108: ensuring that classOrTraitNamed: doesn't return  
globals.

=============== Diff against Tests-ar.108 ===============

Item was added:
+ TestCase subclass: #SystemDictionaryTest
+       instanceVariableNames: ''
+       classVariableNames: ''
+       poolDictionaries: ''
+       category: 'Tests-System-Support'!

Item was added:
+ ----- Method:  
SystemDictionaryTest>>testClassOrTraitNamedReturnsClassForClasses (in  
category 'testing - classes and traits') -----
+ testClassOrTraitNamedReturnsClassForClasses
+       self assert: Object ==  (Smalltalk globals  
classOrTraitNamed: 'Object').
+       self assert: Object ==  (Smalltalk globals classOrTraitNamed:  
#Object).!

Item was added:
+ ----- Method:  
SystemDictionaryTest>>testClassOrTraitNamedReturnsNilForGlobals (in  
category 'testing - classes and traits') -----
+ testClassOrTraitNamedReturnsNilForGlobals
+       self assert: nil = (Smalltalk globals  
classOrTraitNamed: 'Undeclared').
+       self assert: nil = (Smalltalk globals classOrTraitNamed:  
#Undeclared).!


Reply | Threaded
Open this post in threaded view
|

Re: Issue 3666 in pharo: Ensure that classOrTraitNamed: doesn't return globals.

pharo
Updates:
        Status: closed

Comment #3 on issue 3666 by [hidden email]: Ensure that  
classOrTraitNamed: doesn't return globals.
http://code.google.com/p/pharo/issues/detail?id=3666

in 13040