refactoring_custom/SmallSense__CustomVisitorCodeGeneratorTests.st
author convert-repo
Wed, 11 Dec 2019 04:28:36 +0000
changeset 1116 b51ace366efc
parent 1072 a44c741ee5ef
permissions -rw-r--r--
update tags
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
829
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     1
"
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     2
A custom code generation and refactoring support for Smalltalk/X
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     3
Copyright (C) 2013-2015 Jakub Nesveda
1072
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 833
diff changeset
     4
Copyright (C) 2015 Jan Vrany
829
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     5
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     6
This library is free software; you can redistribute it and/or
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     7
modify it under the terms of the GNU Lesser General Public
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     8
License as published by the Free Software Foundation; either
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
     9
version 2.1 of the License.
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    10
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    11
This library is distributed in the hope that it will be useful,
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    12
but WITHOUT ANY WARRANTY; without even the implied warranty of
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    14
Lesser General Public License for more details.
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    15
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    16
You should have received a copy of the GNU Lesser General Public
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    17
License along with this library; if not, write to the Free Software
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    19
"
833
297eb38e4eee Package jn:refactoring_custom renamed to stx:goodies/smallsense/refactoring_custom
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 830
diff changeset
    20
"{ Package: 'stx:goodies/smallsense/refactoring_custom' }"
496
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    21
830
1a88f5e65fe2 Classes moved to namespace SmallSense
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 829
diff changeset
    22
"{ NameSpace: SmallSense }"
803
95cdac772759 Fixed failing tests caused by new STX release
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
    23
634
d77d9a7561be move refactoryBuilder and codeBuilder to CustomCodeGeneratorOrRefactoring
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 621
diff changeset
    24
CustomCodeGeneratorOrRefactoringTestCase subclass:#CustomVisitorCodeGeneratorTests
496
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    25
	instanceVariableNames:''
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    26
	classVariableNames:''
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    27
	poolDictionaries:''
734
f8b10fc1ab0e update TestCase categories with respect to their tested subjects ( classes )
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    28
	category:'Interface-Refactoring-Custom-Generators-Tests'
496
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    29
!
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    30
829
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    31
!CustomVisitorCodeGeneratorTests class methodsFor:'documentation'!
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    32
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    33
copyright
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    34
"
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    35
A custom code generation and refactoring support for Smalltalk/X
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    36
Copyright (C) 2013-2015 Jakub Nesveda
1072
a44c741ee5ef Copyright updates
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 833
diff changeset
    37
Copyright (C) 2015 Jan Vrany
829
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    38
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    39
This library is free software; you can redistribute it and/or
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    40
modify it under the terms of the GNU Lesser General Public
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    41
License as published by the Free Software Foundation; either
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    42
version 2.1 of the License.
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    43
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    44
This library is distributed in the hope that it will be useful,
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    45
but WITHOUT ANY WARRANTY; without even the implied warranty of
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    46
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    47
Lesser General Public License for more details.
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    48
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    49
You should have received a copy of the GNU Lesser General Public
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    50
License along with this library; if not, write to the Free Software
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    51
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    52
"
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    53
! !
59bfd92fcef0 Test fixes (all test pass now)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 803
diff changeset
    54
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    55
!CustomVisitorCodeGeneratorTests methodsFor:'accessing'!
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    56
634
d77d9a7561be move refactoryBuilder and codeBuilder to CustomCodeGeneratorOrRefactoring
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 621
diff changeset
    57
generatorOrRefactoring
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    58
    ^ CustomVisitorCodeGenerator new
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    59
! !
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    60
500
8c2b58d6b2d5 Code reogranization, Defined CustomContext & basic API.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 498
diff changeset
    61
!CustomVisitorCodeGeneratorTests methodsFor:'tests'!
496
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    62
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    63
test_accept_visitor_method_generated_with_comment_and_with_parameter
496
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    64
    "check if methods for visitor pattern are correctly generated"
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    65
    | expectedSource class |
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    66
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    67
    userPreferences generateComments: true.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    68
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    69
    expectedSource := 'acceptVisitor:visitor with:parameter 
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    70
    "Double dispatch back to the visitor, passing my type encoded in
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    71
the selector (visitor pattern)"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    72
    "stub code automatically generated - please change if required"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    73
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
    74
    ^ visitor visitDummyTestClassForVisitorMethod:self with:parameter'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    75
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
    76
    class := model createClassImmediate: 'DummyTestClassForVisitorMethod'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    77
634
d77d9a7561be move refactoryBuilder and codeBuilder to CustomCodeGeneratorOrRefactoring
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 621
diff changeset
    78
    generatorOrRefactoring
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    79
        buildAcceptVisitorMethod: 'visitDummyTestClassForVisitorMethod:'
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    80
        withParameter: true 
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    81
        forClass: class.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    82
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
    83
    generatorOrRefactoring model execute.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    84
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    85
    self assertMethodSource: expectedSource atSelector: #acceptVisitor:with: forClass: class
498
fd9d3f261d36 improved VisitorCodeGeneratorTests - now the test is repeatable
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 496
diff changeset
    86
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    87
    "Created: / 27-07-2014 / 12:32:22 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
    88
    "Modified: / 29-08-2014 / 20:59:10 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    89
!
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    90
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    91
test_accept_visitor_method_generated_with_comment_and_without_parameter
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    92
    "check if methods for visitor pattern are correctly generated"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    93
    | expectedSource class |
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    94
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    95
    userPreferences generateComments: true.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    96
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    97
    expectedSource := 'acceptVisitor:visitor 
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    98
    "Double dispatch back to the visitor, passing my type encoded in
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
    99
the selector (visitor pattern)"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   100
    "stub code automatically generated - please change if required"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   101
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
   102
    ^ visitor visitDummyTestClassForVisitorMethod:self'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   103
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
   104
    class := model createClassImmediate: 'DummyTestClassForVisitorMethod'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   105
634
d77d9a7561be move refactoryBuilder and codeBuilder to CustomCodeGeneratorOrRefactoring
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 621
diff changeset
   106
    generatorOrRefactoring
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   107
        buildAcceptVisitorMethod: 'visitDummyTestClassForVisitorMethod:'
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   108
        withParameter: false 
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   109
        forClass: class.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   110
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
   111
    generatorOrRefactoring model execute.
579
cb85913263cb comment incomplete tests
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 534
diff changeset
   112
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   113
    self assertMethodSource: expectedSource atSelector: #acceptVisitor: forClass: class
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   114
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   115
    "Created: / 03-08-2014 / 22:50:06 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
   116
    "Modified: / 29-08-2014 / 20:59:36 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   117
!
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   118
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   119
test_accept_visitor_method_generated_without_comment_and_with_parameter
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   120
    "check if methods for visitor pattern are correctly generated"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   121
    | expectedSource class |
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   122
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   123
    userPreferences generateComments: false.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   124
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   125
    expectedSource := 'acceptVisitor:visitor with:parameter 
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
   126
    ^ visitor visitDummyTestClassForVisitorMethod:self with:parameter'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   127
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
   128
    class := model createClassImmediate: 'DummyTestClassForVisitorMethod'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   129
634
d77d9a7561be move refactoryBuilder and codeBuilder to CustomCodeGeneratorOrRefactoring
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 621
diff changeset
   130
    generatorOrRefactoring
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   131
        buildAcceptVisitorMethod: 'visitDummyTestClassForVisitorMethod:'
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   132
        withParameter: true 
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   133
        forClass: class.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   134
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
   135
    generatorOrRefactoring model execute.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   136
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   137
    self assertMethodSource: expectedSource atSelector: #acceptVisitor:with: forClass: class
504
3525d97ae194 - added interface canGenerate, generate to CustomCodeGenrator with context object instead of a class
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 500
diff changeset
   138
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   139
    "Created: / 03-08-2014 / 22:53:36 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
   140
    "Modified: / 29-08-2014 / 20:59:55 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   141
!
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   142
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   143
test_accept_visitor_method_generated_without_comment_and_without_parameter
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   144
    "check if methods for visitor pattern are correctly generated"
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   145
    | expectedSource class |
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   146
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   147
    userPreferences generateComments: false.  
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   148
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   149
    expectedSource := 'acceptVisitor:visitor
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
   150
    ^ visitor visitDummyTestClassForVisitorMethod:self'.
498
fd9d3f261d36 improved VisitorCodeGeneratorTests - now the test is repeatable
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 496
diff changeset
   151
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
   152
    class := model createClassImmediate: 'DummyTestClassForVisitorMethod'.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   153
634
d77d9a7561be move refactoryBuilder and codeBuilder to CustomCodeGeneratorOrRefactoring
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 621
diff changeset
   154
    generatorOrRefactoring
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   155
        buildAcceptVisitorMethod: 'visitDummyTestClassForVisitorMethod:'
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   156
        withParameter: false 
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   157
        forClass: class.
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   158
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 654
diff changeset
   159
    generatorOrRefactoring model execute.
621
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   160
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   161
    self assertMethodSource: expectedSource atSelector: #acceptVisitor: forClass: class
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   162
35092c77ce85 make possible parsing of method code ( not just expressions ) for better replacements and code formatting
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 579
diff changeset
   163
    "Created: / 03-08-2014 / 22:51:18 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
654
39e40ece4ae9 all tests pass - instace-like formatter CustomSourceCodeFormatter and its two implementations
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 634
diff changeset
   164
    "Modified: / 29-08-2014 / 21:00:06 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
496
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   165
! !
4fd9b31beefb code for generating visitor method and a test case
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   166