added convert to RBMethod when real methods are passed into CustomSubContext >> selectedMethods:
--- a/CustomRBMethodTests.st Wed Nov 19 19:39:02 2014 +0100
+++ b/CustomRBMethodTests.st Wed Nov 19 20:52:39 2014 +0100
@@ -335,6 +335,18 @@
"Created: / 08-10-2014 / 19:36:21 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
+test_mclass_for_model_class
+ | expectedClass actualClass |
+
+ expectedClass := 'unkwnown'.
+
+ actualClass := rbMethod mclass owningClassOrYourself.
+
+ self assert: expectedClass = actualClass
+
+ "Created: / 19-11-2014 / 09:54:49 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
test_method_arg_names_none_arg
| expectedArguments actualArguments |
--- a/CustomSubContext.st Wed Nov 19 19:39:02 2014 +0100
+++ b/CustomSubContext.st Wed Nov 19 20:52:39 2014 +0100
@@ -19,7 +19,7 @@
"Sets the list of classes"
| rbclasses |
- "classes is supposed to be a collection of RBClass. However, if real classes
+ "classes is supposed to be a collection of RBClass/RBMetaclass. However, if real classes
are passed, they are converted to RBClasses here for your convenience"
rbclasses := classes collect:[ :cls | cls isBehavior ifTrue:[ self asRBClass:cls ] ifFalse:[ cls ] ].
@@ -27,6 +27,7 @@
"Created: / 26-04-2014 / 16:05:34 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
"Modified: / 14-11-2014 / 19:26:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified (format): / 19-11-2014 / 20:08:07 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
selectedCodes: something
@@ -35,8 +36,22 @@
"Created: / 18-08-2014 / 23:53:25 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
-selectedMethods:something
- selectedMethods := something.
+selectedMethods: methods
+ "Sets the list of methods"
+ | rbMethods |
+
+ "methods is supposed to be a collection of RBMethod. However, if real methods (Method)
+ are passed, they are converted to RBMethod here for your convenience"
+
+ rbMethods := methods collect: [ :method |
+ method isMethod
+ ifTrue:[ self asRBMethod:method ]
+ ifFalse:[ method ]
+ ].
+
+ selectedMethods := rbMethods.
+
+ "Modified: / 19-11-2014 / 20:11:39 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
selectedPackages:something
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CustomSubContextTests.st Wed Nov 19 20:52:39 2014 +0100
@@ -0,0 +1,62 @@
+"{ Package: 'jn:refactoring_custom' }"
+
+TestCase subclass:#CustomSubContextTests
+ instanceVariableNames:'model context'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Interface-Refactoring-Custom-Tests'
+!
+
+!CustomSubContextTests methodsFor:'initialization & release'!
+
+setUp
+ super setUp.
+
+ model := CustomNamespace new.
+ context := CustomSubContext new
+ model: model;
+ yourself
+
+ "Modified: / 19-11-2014 / 19:59:15 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+
+!CustomSubContextTests methodsFor:'tests'!
+
+test_selected_methods_as_rb_method
+
+ |expectedMethods realMethod actualMethods modelClass modelMethod|
+
+ modelClass := model classNamed: self class name.
+ modelMethod := modelClass compiledMethodAt: #test_selected_methods_as_rb_method.
+ expectedMethods := Array with: modelMethod.
+
+ realMethod := self class compiledMethodAt: #test_selected_methods_as_rb_method.
+ context selectedMethods: (Array with: realMethod).
+ actualMethods := context selectedMethods.
+
+ "Cannot test coolection equality, because each contains different RBMethod instance
+ self assert: expectedMethods = actualMethods"
+ self assert: (expectedMethods size) = (actualMethods size).
+ self assert: (expectedMethods first selector) = (actualMethods first selector).
+ self assert: (expectedMethods first isKindOf: RBMethod).
+ self deny: expectedMethods first isMethod
+
+ "Modified: / 19-11-2014 / 20:29:40 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+!
+
+test_selected_methods_existing_rb_method
+
+ |expectedMethods actualMethods modelClass modelMethod|
+
+ modelClass := model classNamed: self class name.
+ modelMethod := modelClass compiledMethodAt: #test_selected_methods_as_rb_method.
+ expectedMethods := Array with: modelMethod.
+
+ context selectedMethods: (Array with: modelMethod).
+ actualMethods := context selectedMethods.
+
+ self assert: expectedMethods = actualMethods
+
+ "Created: / 19-11-2014 / 20:30:39 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+! !
+
--- a/CustomTestCaseMethodCodeGenerator.st Wed Nov 19 19:39:02 2014 +0100
+++ b/CustomTestCaseMethodCodeGenerator.st Wed Nov 19 20:52:39 2014 +0100
@@ -114,7 +114,10 @@
aCustomContext selectedMethods do:[ :method |
| class className testClass |
- class := method mclass owningClassOrYourself.
+ class := method modelClass realClass owningClassOrYourself.
+ "/ TODO implement these missing methods in RBMethod
+ "/ and replace it with:
+ "/ class := method mclass owningClassOrYourself.
className := class theNonMetaclass name.
(className endsWith: 'Tests') ifFalse: [
@@ -142,7 +145,7 @@
].
"Created: / 24-08-2014 / 16:24:04 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
- "Modified: / 01-11-2014 / 15:19:21 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified: / 19-11-2014 / 09:55:20 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
! !
!CustomTestCaseMethodCodeGenerator methodsFor:'executing - private'!
--- a/abbrev.stc Wed Nov 19 19:39:02 2014 +0100
+++ b/abbrev.stc Wed Nov 19 20:52:39 2014 +0100
@@ -31,6 +31,7 @@
CustomSourceCodeGeneratorTests CustomSourceCodeGeneratorTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
CustomSourceCodeSelection CustomSourceCodeSelection jn:refactoring_custom 'Interface-Refactoring-Custom' 0
CustomSourceCodeSelectionTests CustomSourceCodeSelectionTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
+CustomSubContextTests CustomSubContextTests jn:refactoring_custom 'Interface-Refactoring-Custom-Tests' 1
CustomTestCaseHelper CustomTestCaseHelper jn:refactoring_custom 'Interface-Refactoring-Custom-Helpers' 0
CustomTestCaseHelperTests CustomTestCaseHelperTests jn:refactoring_custom 'Interface-Refactoring-Custom-Helpers-Tests' 1
TestClass TestClass jn:refactoring_custom 'Interface-Refactoring-Custom' 1
--- a/jn_refactoring_custom.st Wed Nov 19 19:39:02 2014 +0100
+++ b/jn_refactoring_custom.st Wed Nov 19 20:52:39 2014 +0100
@@ -128,6 +128,7 @@
(CustomSourceCodeGeneratorTests autoload)
CustomSourceCodeSelection
(CustomSourceCodeSelectionTests autoload)
+ (CustomSubContextTests autoload)
CustomTestCaseHelper
(CustomTestCaseHelperTests autoload)
TestClass
--- a/patches/patches.rc Wed Nov 19 19:39:02 2014 +0100
+++ b/patches/patches.rc Wed Nov 19 20:52:39 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
VALUE "ProductName", "LibraryName\0"
VALUE "ProductVersion", "6.2.4.1420\0"
- VALUE "ProductDate", "Wed, 19 Nov 2014 17:49:45 GMT\0"
+ VALUE "ProductDate", "Wed, 19 Nov 2014 19:38:30 GMT\0"
END
END
--- a/refactoring_custom.rc Wed Nov 19 19:39:02 2014 +0100
+++ b/refactoring_custom.rc Wed Nov 19 20:52:39 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
VALUE "ProductName", "ProductName\0"
VALUE "ProductVersion", "6.2.4.1420\0"
- VALUE "ProductDate", "Wed, 19 Nov 2014 17:49:42 GMT\0"
+ VALUE "ProductDate", "Wed, 19 Nov 2014 19:38:27 GMT\0"
END
END