CustomCodeSelectionToResourceTranslationTests.st
author Jakub Nesveda <jakubnesveda@seznam.cz>
Sun, 25 Jan 2015 13:39:42 +0100
changeset 803 95cdac772759
parent 777 8f212cf1bb45
child 829 59bfd92fcef0
permissions -rw-r--r--
Fixed failing tests caused by new STX release * RBParser cannot parse expressions like #NameSpace::Class - changed to #'NameSpace::Class' * AddClassChange has renamed variables instanceVariableNames -> instanceVariableString, classVariableNames -> classVariableString
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
     1
"{ Package: 'jn:refactoring_custom' }"
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
     2
803
95cdac772759 Fixed failing tests caused by new STX release
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 777
diff changeset
     3
"{ NameSpace: Smalltalk }"
95cdac772759 Fixed failing tests caused by new STX release
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 777
diff changeset
     4
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
     5
CustomCodeGeneratorOrRefactoringTestCase subclass:#CustomCodeSelectionToResourceTranslationTests
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
     6
	instanceVariableNames:''
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
     7
	classVariableNames:''
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
     8
	poolDictionaries:''
734
f8b10fc1ab0e update TestCase categories with respect to their tested subjects ( classes )
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 726
diff changeset
     9
	category:'Interface-Refactoring-Custom-Refactorings-Tests'
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    10
!
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    11
726
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
    12
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    13
!CustomCodeSelectionToResourceTranslationTests methodsFor:'accessing'!
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    14
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    15
generatorOrRefactoring
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    16
    ^ CustomCodeSelectionToResourceTranslation new
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    17
! !
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    18
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    19
!CustomCodeSelectionToResourceTranslationTests methodsFor:'tests'!
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    20
698
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    21
test_available_in_code_view_perspective
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    22
    | perspective |
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    23
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    24
    perspective := CustomPerspective codeViewPerspective.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    25
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    26
    self assert: (generatorOrRefactoring class availableInPerspective:perspective).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    27
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    28
    "Created: / 15-10-2014 / 08:10:35 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    29
!
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    30
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    31
test_available_in_context_empty
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    32
    
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    33
    self deny: (generatorOrRefactoring class availableInContext: context).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    34
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    35
    "Modified: / 15-10-2014 / 09:32:27 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    36
!
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    37
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    38
test_available_in_context_empty_selected_codes
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    39
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    40
    context selectedCodes: (Array
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    41
        with: CustomSourceCodeSelection new  
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    42
    ).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    43
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    44
    self deny: (generatorOrRefactoring class availableInContext: context).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    45
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    46
    "Created: / 15-10-2014 / 09:37:41 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
726
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
    47
    "Modified: / 05-11-2014 / 22:53:49 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
698
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    48
!
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    49
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    50
test_available_in_context_with_selected_codes
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    51
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    52
    context selectedCodes: (Array
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    53
        with: (CustomSourceCodeSelection new
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    54
            selectedInterval: (1 to: 5);
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    55
            currentSourceCode: 'selector_05 ^ 5';
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    56
            yourself)
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    57
    ).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    58
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    59
    self assert: (generatorOrRefactoring class availableInContext: context).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    60
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    61
    "Created: / 15-10-2014 / 09:41:44 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    62
!
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    63
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    64
test_code_selection_replaced_by_resource_translation_01
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    65
    | expectedSource originalSource codeSelection class |
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    66
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    67
    originalSource := 'selector
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    68
    self information: ''Translate this''.
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    69
    ^ self.'.
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    70
688
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 650
diff changeset
    71
    class := model createClassImmediate: 'DummyClassForTestCase01' instanceVariableNames: 'resources'.
6bd18ba5e56c completed - rewriting code generators to replace CustomSourceCodeBuilder, but RBClass, RBMetaclass, RBNamespace and CodeGenerator
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 650
diff changeset
    72
    model createMethodImmediate: class source: originalSource.
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    73
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    74
    codeSelection := CustomSourceCodeSelection new.
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    75
    codeSelection
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    76
        currentSourceCode: originalSource;
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    77
        selectedClass: class;
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    78
        selectedInterval: (32 to: 48);
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    79
        selectedMethod: (class compiledMethodAt: #selector);
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    80
        selectedSelector: #selector.
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    81
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    82
    context selectedCodes: (Array with: codeSelection).  
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    83
    generatorOrRefactoring executeInContext: context.  
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    84
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    85
    expectedSource := 'selector
777
8f212cf1bb45 Improvemens in CustomRefactoryBuilder - no complete reformatting of method source code, but only the replacement parts
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
    86
    self information: (resources string:''Translate this'').
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    87
    ^ self.'.
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    88
650
7514c13d6dd8 working refactoring CustomCodeSelectionToResourceTranslation - wraps code selection in code editor (codeView) to translation call, finished code selection search/replace API in CustomRefactoryBuilder
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 645
diff changeset
    89
    self assertMethodSource:expectedSource atSelector:#selector forClass:class
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    90
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
    91
    "Created: / 23-08-2014 / 20:09:06 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
777
8f212cf1bb45 Improvemens in CustomRefactoryBuilder - no complete reformatting of method source code, but only the replacement parts
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
    92
    "Modified: / 10-12-2014 / 20:14:32 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
698
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    93
!
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    94
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    95
test_code_selection_replaced_by_resource_translation_02
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    96
    | expectedSource originalSource codeSelection class |
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    97
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    98
    originalSource := 'selector
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
    99
    self information: self theInformation.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   100
    ^ self.'.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   101
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   102
    class := model createClassImmediate: 'DummyClassForTestCase01' instanceVariableNames: 'resources'.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   103
    model createMethodImmediate: class source: originalSource.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   104
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   105
    codeSelection := CustomSourceCodeSelection new.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   106
    codeSelection
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   107
        currentSourceCode: originalSource;
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   108
        selectedClass: class;
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   109
        selectedInterval: (32 to: 51);
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   110
        selectedMethod: (class compiledMethodAt: #selector);
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   111
        selectedSelector: #selector.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   112
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   113
    context selectedCodes: (Array with: codeSelection).  
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   114
    generatorOrRefactoring executeInContext: context.  
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   115
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   116
    expectedSource := 'selector
777
8f212cf1bb45 Improvemens in CustomRefactoryBuilder - no complete reformatting of method source code, but only the replacement parts
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
   117
    self information: (resources string:self theInformation).
698
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   118
    ^ self.'.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   119
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   120
    self assertMethodSource:expectedSource atSelector:#selector forClass:class
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   121
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   122
    "Created: / 15-10-2014 / 09:45:08 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
777
8f212cf1bb45 Improvemens in CustomRefactoryBuilder - no complete reformatting of method source code, but only the replacement parts
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
   123
    "Modified: / 10-12-2014 / 20:14:42 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
698
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   124
!
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   125
704
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   126
test_code_selection_replaced_by_resource_translation_with_keep_package
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   127
    | expectedSource originalSource codeSelection class method compiledMethod |
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   128
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   129
    originalSource := 'selector
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   130
    self information: self theInformation.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   131
    ^ self.'.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   132
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   133
    class := model createClassImmediate: 'DummyClassForTestCase01' instanceVariableNames: 'resources'.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   134
    method := model createMethodImmediate: class source: originalSource.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   135
    method package: #some_package.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   136
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   137
    codeSelection := CustomSourceCodeSelection new.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   138
    codeSelection
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   139
        currentSourceCode: originalSource;
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   140
        selectedClass: class;
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   141
        selectedInterval: (32 to: 51);
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   142
        selectedMethod: (class compiledMethodAt: #selector);
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   143
        selectedSelector: #selector.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   144
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   145
    context selectedCodes: (Array with: codeSelection).  
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   146
    generatorOrRefactoring executeInContext: context.  
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   147
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   148
    expectedSource := 'selector
777
8f212cf1bb45 Improvemens in CustomRefactoryBuilder - no complete reformatting of method source code, but only the replacement parts
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
   149
    self information: (resources string:self theInformation).
704
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   150
    ^ self.'.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   151
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   152
    self assertMethodSource:expectedSource atSelector:#selector forClass:class.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   153
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   154
    compiledMethod := class compiledMethodAt: #selector.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   155
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   156
    self assert: #some_package = (compiledMethod package).
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   157
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   158
    "Created: / 16-10-2014 / 21:46:23 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
777
8f212cf1bb45 Improvemens in CustomRefactoryBuilder - no complete reformatting of method source code, but only the replacement parts
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 734
diff changeset
   159
    "Modified: / 10-12-2014 / 20:14:50 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
704
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   160
!
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   161
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   162
test_code_selection_replaced_by_resource_translation_with_wrong_selection
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   163
    | expectedSource originalSource codeSelection class |
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   164
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   165
    originalSource := 'method: arg
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   166
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   167
    arg ifNil: [ 
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   168
        self warn: ''nil''.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   169
    ]
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   170
    ifNotNil: [ self information: ''info'' ]'.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   171
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   172
    class := model createClassImmediate: 'DummyClassForTestCase01' instanceVariableNames: 'resources'.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   173
    model createMethodImmediate: class source: originalSource.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   174
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   175
    codeSelection := CustomSourceCodeSelection new.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   176
    codeSelection
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   177
        currentSourceCode: originalSource;
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   178
        selectedClass: class;
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   179
        selectedInterval: (8 to: 10);
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   180
        selectedMethod: (class compiledMethodAt: #method:);
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   181
        selectedSelector: #selector.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   182
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   183
    context selectedCodes: (Array with: codeSelection).  
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   184
    generatorOrRefactoring executeInContext: context.  
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   185
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   186
    expectedSource := 'method: arg
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   187
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   188
    arg ifNil: [ 
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   189
        self warn: ''nil''.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   190
    ]
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   191
    ifNotNil: [ self information: ''info'' ]'.
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   192
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   193
    self assertMethodSource:expectedSource atSelector:#method: forClass:class
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   194
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   195
    "Created: / 17-10-2014 / 22:31:16 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   196
!
340954b48789 better comment in CustomNamespace >> execute
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 698
diff changeset
   197
698
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   198
test_not_available_in_class_perspective
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   199
    | perspective |
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   200
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   201
    perspective := CustomPerspective classPerspective.
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   202
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   203
    self deny: (generatorOrRefactoring class availableInPerspective:perspective).
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   204
525d39491ecc show CustomCodeSelectionToResourceTranslation refactoring only in code view menu and only if some code is selected
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 688
diff changeset
   205
    "Created: / 15-10-2014 / 08:11:43 / Jakub Nesveda <nesvejak@fit.cvut.cz>"
645
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   206
! !
38a38c28ddb1 work in progress - create selection replace API in CustomRefactoryBuilder and CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents:
diff changeset
   207
726
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   208
!CustomCodeSelectionToResourceTranslationTests class methodsFor:'documentation'!
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   209
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   210
version_HG
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   211
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   212
    ^ '$Changeset: <not expanded> $'
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   213
! !
d0dec838632e check for nil in availableInContext: and switch to replace in context for CustomCodeSelectionToResourceTranslation
Jakub Nesveda <jakubnesveda@seznam.cz>
parents: 704
diff changeset
   214