--- a/CustomMock.st Thu Feb 05 22:42:42 2015 +0100
+++ b/CustomMock.st Thu Feb 05 22:50:23 2015 +0100
@@ -84,14 +84,13 @@
mockClass := Smalltalk classNamed: mockClassName.
self createMockMethodWithSingleValue: mockClass.
- self createMockMethodWithBlockValue: mockClass.
self createMockMethodWithCompileMethod: mockClass.
].
^ mockClass
"Created: / 15-06-2014 / 19:15:52 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
- "Modified: / 24-01-2015 / 19:40:02 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
+ "Modified: / 05-02-2015 / 22:46:05 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
createMockGetters: aMockClass forSelectors: aSelectors
@@ -124,29 +123,6 @@
"Modified: / 24-09-2014 / 21:26:12 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
!
-createMockMethodWithBlockValue: aMockClass
- "Generates mock method for given mock class
- to support custom method implementation by block value"
-
- | instVarName classVarName |
-
- classVarName := self variableNameForClassMockedSelectors.
-
- self
- createMockMethod: aMockClass theMetaclass
- methodSource: (self blockValueMethodSource: classVarName)
- mockedSelectorsVariableName: classVarName.
-
- instVarName := self variableNameForInstanceMockedSelectors.
-
- self
- createMockMethod: aMockClass theNonMetaclass
- methodSource: (self blockValueMethodSource: instVarName)
- mockedSelectorsVariableName: instVarName.
-
- "Created: / 21-09-2014 / 22:51:39 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
-!
-
createMockMethodWithCompileMethod: aMockClass
"Generates mock method for given mock class
to support custom method implementation by given method source"
@@ -189,65 +165,6 @@
!CustomMock methodsFor:'code generation - sources'!
-blockValueMethodSource: aMockedSelectorsVariableName
- "Returns mock method source code for given variable name
- which holds mocked selectors and its block values.
- These values are so called blocks which contains executable code."
-
- ^ 'mockSelector: aSelector withBlockValue: aBlock
-
- | valueMethod mockSelector argNumber |
-
- self error: ''Do not use this method - makes always test pass!!!!!!''.
-
- `mockedSelectorsVariableName isNil ifTrue: [
- `mockedSelectorsVariableName := Dictionary new
- ].
-
- `mockedSelectorsVariableName at: aSelector asSymbol put: aBlock.
- Transcript showCR: ''SRC: '', aBlock source.
- valueMethod := ''value''.
- mockSelector := ''''.
- argNumber := 0.
- (aSelector asString subStrings: $:) do: [ :param |
- | argName |
-
- argName := ''arg'', argNumber asString.
-
- (argNumber > 0) ifTrue: [
- mockSelector := mockSelector, '':'', argName, '' '', param.
-
- (argNumber > 1) ifTrue: [
- valueMethod := valueMethod, '' value:'', argName.
- ]
- ifFalse: [
- valueMethod := valueMethod, '':'', argName.
- ].
- ]
- ifFalse: [
- mockSelector := param.
- ].
-
- valueMethod := valueMethod.
- argNumber := argNumber + 1.
- ].
-
- (CodeGenerator new
- class: self class;
- protocol: ''mocks'';
- source: (''`@selector
-
- ^ (`mockedSelectorsVariableName at: `#selector) `@value'');
- replace: ''`@selector'' with: mockSelector asSymbol;
- replace: ''`#selector'' with: ($#, aSelector);
- replace: ''`@value'' with: valueMethod asSymbol;
- replace: ''`mockedSelectorsVariableName'' with: ''' , aMockedSelectorsVariableName , ''';
- change) execute.'.
-
- "Created: / 10-07-2014 / 22:28:27 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
- "Modified: / 25-09-2014 / 22:43:27 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
-!
-
compileMockMethodSource
"Returns mock method source code which will compile method source."