add create immediate private class in CustomNamespace
fix generating test case method for private classes in CustomTestCaseMethodCodeGenerator
--- a/CustomNamespace.st Thu Oct 30 21:21:45 2014 +0100
+++ b/CustomNamespace.st Sat Nov 01 15:41:43 2014 +0100
@@ -200,19 +200,52 @@
createClassImmediate: aClassName superClassName: aSuperClassName instanceVariableNames: instVarNames classVariableNames: classVarNames poolDictionaries: poolDict category: category
"Creates class immediately and returns the real class"
- changes addChange: (InteractiveAddClassChange definition:
- aSuperClassName asString, ' subclass:#', aClassName asString, '
- instanceVariableNames:''', instVarNames asString, '''
- classVariableNames:''', classVarNames asString, '''
- poolDictionaries:''', poolDict asString, '''
- category:''', category asString, '''
- ').
+ ^ self createClassImmediate: aClassName superClassName: aSuperClassName instanceVariableNames: instVarNames classVariableNames: classVarNames poolDictionaries: poolDict category: category privateIn: nil
+
+ "Created: / 19-10-2014 / 20:47:51 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified: / 30-10-2014 / 21:46:09 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+createClassImmediate: aClassName superClassName: aSuperClassName instanceVariableNames: instVarNames classVariableNames: classVarNames poolDictionaries: poolDict category: category privateIn: privateInClassName
+ "Creates class immediately and returns the real class"
+ | newClassName |
+
+ newClassName := aClassName.
+
+ privateInClassName isNil ifTrue: [
+ changes addChange: (InteractiveAddClassChange definition:
+ aSuperClassName asString, ' subclass:#', aClassName asString, '
+ instanceVariableNames:''', instVarNames asString, '''
+ classVariableNames:''', classVarNames asString, '''
+ poolDictionaries:''', poolDict asString, '''
+ category:''', category asString, '''
+ ')
+ ] ifFalse: [
+ changes addChange: (InteractiveAddClassChange definition:
+ aSuperClassName asString, ' subclass:#', aClassName asString, '
+ instanceVariableNames:''', instVarNames asString, '''
+ classVariableNames:''', classVarNames asString, '''
+ poolDictionaries:''', poolDict asString, '''
+ privateIn:', privateInClassName asString, '
+ ').
+
+ newClassName := privateInClassName asString, '::', aClassName asString.
+ ].
self execute.
- ^ Smalltalk classNamed: aClassName
+ ^ Smalltalk classNamed: newClassName
+
+ "Created: / 30-10-2014 / 21:28:40 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified: / 31-10-2014 / 00:17:53 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
- "Created: / 19-10-2014 / 20:47:51 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+createClassImmediate: aClassName superClassName: aSuperClassName privateIn: privateInClassName
+ "Creates class immediately and returns the real class"
+
+ ^ self createClassImmediate: aClassName superClassName: aSuperClassName instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: '' privateIn: privateInClassName
+
+ "Created: / 30-10-2014 / 21:47:55 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
createMethodImmediate: aClass protocol: aProtocol source: aSource
--- a/CustomNamespaceTests.st Thu Oct 30 21:21:45 2014 +0100
+++ b/CustomNamespaceTests.st Sat Nov 01 15:41:43 2014 +0100
@@ -531,6 +531,48 @@
"Modified: / 27-07-2014 / 12:42:53 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
+test_create_class_immediate_super_class_name_instance_variable_names_class_variable_names_pool_dictionaries_category_private_in_private_class
+ | mockClass |
+
+ mockClass := model
+ createClassImmediate: 'MockClassForTestCase'
+ superClassName: 'Object'
+ instanceVariableNames: 'instVar'
+ classVariableNames: 'ClassVar'
+ poolDictionaries: 'pollDict01'
+ category: 'Some-Category01'
+ privateIn: 'Object'.
+
+ self assert: mockClass name = 'Object::MockClassForTestCase'.
+ self assert: mockClass superclass name = 'Object'.
+ self assert: mockClass instanceVariableString = 'instVar'.
+ self assert: mockClass classVariableString = 'ClassVar'.
+ self assert: mockClass poolDictionaries = 'pollDict01'.
+ self assert: mockClass category = Object category.
+ self assert: (mockClass owningClass name) = 'Object'.
+
+ "Modified: / 31-10-2014 / 00:19:37 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_create_class_immediate_super_class_name_private_in
+ | mockClass |
+
+ mockClass := model
+ createClassImmediate: 'MockClassForTestCase'
+ superClassName: 'Object'
+ privateIn: 'Object'.
+
+ self assert: mockClass name = 'Object::MockClassForTestCase'.
+ self assert: mockClass superclass name = 'Object'.
+ self assert: mockClass instanceVariableString = ''.
+ self assert: mockClass classVariableString = ''.
+ self assert: mockClass poolDictionaries = ''.
+ self assert: mockClass category = Object category.
+ self assert: (mockClass owningClass name) = 'Object'.
+
+ "Modified: / 31-10-2014 / 00:20:36 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
test_create_class_immediate_with_category
| mockClass |
--- a/CustomTestCaseMethodCodeGenerator.st Thu Oct 30 21:21:45 2014 +0100
+++ b/CustomTestCaseMethodCodeGenerator.st Sat Nov 01 15:41:43 2014 +0100
@@ -112,10 +112,11 @@
buildInContext: aCustomContext
aCustomContext selectedMethods do:[ :method |
- | className testClass |
+ | class className testClass |
- className := method mclass theNonMetaclass name.
+ class := method mclass owningClassOrYourself.
+ className := class theNonMetaclass name.
(className endsWith: 'Tests') ifFalse: [
| testClass |
@@ -125,8 +126,7 @@
| testSelector |
testSelector := self testMethodSelector: method selector.
-
- (testClass includesSelector: testSelector asSymbol) ifFalse: [
+ (testClass includesSelector: testSelector asSymbol) ifFalse: [
model createMethod
package: method package;
class: testClass;
@@ -142,7 +142,7 @@
].
"Created: / 24-08-2014 / 16:24:04 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
- "Modified: / 15-10-2014 / 09:17:30 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified: / 01-11-2014 / 15:19:21 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
! !
!CustomTestCaseMethodCodeGenerator methodsFor:'executing - private'!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CustomTestCaseMethodCodeGeneratorTests.st Sat Nov 01 15:41:43 2014 +0100
@@ -0,0 +1,40 @@
+"{ Package: 'jn:refactoring_custom' }"
+
+CustomCodeGeneratorOrRefactoringTestCase subclass:#CustomTestCaseMethodCodeGeneratorTests
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Refactoring-Custom-Generators-Tests'
+!
+
+!CustomTestCaseMethodCodeGeneratorTests methodsFor:'accessing'!
+
+generatorOrRefactoring
+ ^ CustomTestCaseMethodCodeGenerator new
+! !
+
+!CustomTestCaseMethodCodeGeneratorTests methodsFor:'tests'!
+
+test_generate_test_method_for_private_class
+ | expectedSource privateClass method superclass testClass |
+
+ superclass := model createClassImmediate: #MockClassForTestCase01 superClassName: #Object.
+ privateClass := model createClassImmediate: #PrivateClass01 superClassName: #MockClassForTestCase01 privateIn: #MockClassForTestCase01.
+ testClass := model createClassImmediate: #MockClassForTestCase01Tests.
+ method := model createMethodImmediate: privateClass source: 'selector_01 ^ 1'.
+
+ context selectedMethods: (Array with: method).
+
+ expectedSource := 'test_selector_01
+ "/ something selector_01.
+
+ self assert:1 = 2.'.
+
+ generatorOrRefactoring executeInContext: context.
+
+ self assertMethodSource:expectedSource atSelector:#test_selector_01 forClass:testClass
+
+ "Created: / 31-10-2014 / 00:30:29 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified (format): / 01-11-2014 / 14:55:46 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+
--- a/Make.proto Thu Oct 30 21:21:45 2014 +0100
+++ b/Make.proto Sat Nov 01 15:41:43 2014 +0100
@@ -192,7 +192,7 @@
$(OUTDIR)CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
$(OUTDIR)CustomVisitorCodeGeneratorAcceptVisitor.$(O) CustomVisitorCodeGeneratorAcceptVisitor.$(H): CustomVisitorCodeGeneratorAcceptVisitor.st $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGenerator.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)/jn/refactoring_custom/CustomVisitorCodeGenerator.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
-$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/AddClassChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/AddMethodChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/RefactoryChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/RefactoryClassChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBAbstractClass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBClass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBMetaclass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBMethod.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/SystemBrowser.$(H) $(INCLUDE_TOP)/stx/libtool/Tools__NewSystemBrowser.$(H) $(INCLUDE_TOP)/stx/libview2/ApplicationModel.$(H) $(INCLUDE_TOP)/stx/libview2/Model.$(H) $(STCHDR)
+$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/AddClassChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/AddMethodChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/RefactoryChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/changes/RefactoryClassChange.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBAbstractClass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBClass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBMetaclass.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/helpers/RBMethod.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/refactoring/RefactoryBuilder.$(H) $(INCLUDE_TOP)/stx/goodies/refactoryBrowser/refactoring/RefactoryBuilder.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(INCLUDE_TOP)/stx/libtool/SystemBrowser.$(H) $(INCLUDE_TOP)/stx/libtool/Tools__NewSystemBrowser.$(H) $(INCLUDE_TOP)/stx/libview2/ApplicationModel.$(H) $(INCLUDE_TOP)/stx/libview2/Model.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
--- a/abbrev.stc Thu Oct 30 21:21:45 2014 +0100
+++ b/abbrev.stc Sat Nov 01 15:41:43 2014 +0100
@@ -63,6 +63,7 @@
CustomSubContext CustomSubContext jn:refactoring_custom 'Interface-Refactoring-Custom' 0
CustomSubclassResponsibilityCodeGeneratorTests CustomSubclassResponsibilityCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
CustomTestCaseCodeGeneratorTests CustomTestCaseCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Generators-Tests' 1
+CustomTestCaseMethodCodeGeneratorTests CustomTestCaseMethodCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Generators-Tests' 1
CustomUserDialog CustomUserDialog jn:refactoring_custom 'Interface-Refactoring-Custom' 0
CustomValueHolderAccessMethodsCodeGeneratorTests CustomValueHolderAccessMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
CustomValueHolderGetterMethodsCodeGeneratorTests CustomValueHolderGetterMethodsCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
--- a/bc.mak Thu Oct 30 21:21:45 2014 +0100
+++ b/bc.mak Sat Nov 01 15:41:43 2014 +0100
@@ -138,7 +138,7 @@
$(OUTDIR)CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationGetterMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(O) CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.$(H): CustomValueHolderWithChangeNotificationSetterMethodsCodeGenerator.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomAccessMethodsCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
$(OUTDIR)CustomVisitorCodeGeneratorAcceptVisitor.$(O) CustomVisitorCodeGeneratorAcceptVisitor.$(H): CustomVisitorCodeGeneratorAcceptVisitor.st $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGenerator.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomCodeGeneratorOrRefactoring.$(H) $(INCLUDE_TOP)\jn\refactoring_custom\CustomVisitorCodeGenerator.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
-$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\AddClassChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\AddMethodChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\RefactoryChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\RefactoryClassChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBAbstractClass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBClass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBMetaclass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBMethod.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\SystemBrowser.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__NewSystemBrowser.$(H) $(INCLUDE_TOP)\stx\libview2\ApplicationModel.$(H) $(INCLUDE_TOP)\stx\libview2\Model.$(H) $(STCHDR)
+$(OUTDIR)extensions.$(O): extensions.st $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\AddClassChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\AddMethodChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\RefactoryChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\changes\RefactoryClassChange.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBAbstractClass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBClass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBMetaclass.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\helpers\RBMethod.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\refactoring\RefactoryBuilder.$(H) $(INCLUDE_TOP)\stx\goodies\refactoryBrowser\refactoring\RefactoryBuilder.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(INCLUDE_TOP)\stx\libtool\SystemBrowser.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__NewSystemBrowser.$(H) $(INCLUDE_TOP)\stx\libview2\ApplicationModel.$(H) $(INCLUDE_TOP)\stx\libview2\Model.$(H) $(STCHDR)
# ENDMAKEDEPEND --- do not remove this line
--- a/extensions.st Thu Oct 30 21:21:45 2014 +0100
+++ b/extensions.st Sat Nov 01 15:41:43 2014 +0100
@@ -520,6 +520,12 @@
"Created: / 06-10-2014 / 08:37:54 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
! !
+!RefactoryBuilder::MethodProtocolSearcher class methodsFor:'documentation'!
+
+documentation
+""
+! !
+
!Tools::NewSystemBrowser methodsFor:'menus extensions-custom refactorings'!
classMenuExtensionCustomGenerators:aMenu
--- a/jn_refactoring_custom.st Thu Oct 30 21:21:45 2014 +0100
+++ b/jn_refactoring_custom.st Sat Nov 01 15:41:43 2014 +0100
@@ -42,7 +42,7 @@
#'stx:goodies/refactoryBrowser/changes' "AddClassChange - extended"
#'stx:goodies/refactoryBrowser/helpers' "RBAbstractClass - extended"
#'stx:goodies/refactoryBrowser/parser' "ParseTreeRewriter - superclass of CustomParseTreeRewriter"
- #'stx:goodies/refactoryBrowser/refactoring' "RefactoryBuilder - superclass of CustomRefactoryBuilder"
+ #'stx:goodies/refactoryBrowser/refactoring' "RefactoryBuilder - extended"
#'stx:goodies/sunit' "TestAsserter - superclass of CustomAccessMethodsCodeGeneratorTests"
#'stx:libbasic' "LibraryDefinition - superclass of jn_refactoring_custom"
#'stx:libtool' "CodeGenerator - superclass of CustomSourceCodeGenerator"
@@ -148,6 +148,7 @@
CustomSubContext
(CustomSubclassResponsibilityCodeGeneratorTests autoload)
(CustomTestCaseCodeGeneratorTests autoload)
+ (CustomTestCaseMethodCodeGeneratorTests autoload)
CustomUserDialog
(CustomValueHolderAccessMethodsCodeGeneratorTests autoload)
(CustomValueHolderGetterMethodsCodeGeneratorTests autoload)
@@ -236,6 +237,7 @@
RBMethod package:
RBAbstractClass inheritsFrom:
RBAbstractClass isSubclassOf:
+ 'RefactoryBuilder::MethodProtocolSearcher class' documentation
)
! !
--- a/patches/patches.rc Thu Oct 30 21:21:45 2014 +0100
+++ b/patches/patches.rc Sat Nov 01 15:41:43 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
VALUE "ProductName", "LibraryName\0"
VALUE "ProductVersion", "6.2.4.1378\0"
- VALUE "ProductDate", "Tue, 28 Oct 2014 18:29:28 GMT\0"
+ VALUE "ProductDate", "Sat, 01 Nov 2014 14:22:41 GMT\0"
END
END
--- a/refactoring_custom.rc Thu Oct 30 21:21:45 2014 +0100
+++ b/refactoring_custom.rc Sat Nov 01 15:41:43 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
VALUE "ProductName", "ProductName\0"
VALUE "ProductVersion", "6.2.4.1378\0"
- VALUE "ProductDate", "Tue, 28 Oct 2014 18:29:25 GMT\0"
+ VALUE "ProductDate", "Sat, 01 Nov 2014 14:22:38 GMT\0"
END
END