SmallSense__EditSupportTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 04 Mar 2015 09:51:20 +0000
changeset 444 a47f43af21d6
parent 374 e65bd2bf892a
child 447 2d45c613a5bd
permissions -rw-r--r--
Smalltalk electric snippets: make iterator variable naming logic more configurable * UserPreferences current smallSenseSmalltalkIterationVariableNamePrefixWithEach: If set, then variable name is prefixed with "each", i.e., `eachPerson`. Defaults to `false`. Thanks Alexander Zottnick for suggestion. * UserPreferences current smallSenseSmalltalkIterationVariableNameMaxLength: Length limit for generated variable name, if the name is longer than this limit, fall back to generic `each` to make the code more concise. Defaults to 14 (subject to change). These preferences are "hidden" for now, i.e., there is no configuration UI for them. One has to add the setting to her/his user startup file.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
444
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
     1
"{ Encoding: utf8 }"
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
     2
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 273
diff changeset
     5
Copyright (C) 2013-2015 Jan Vrany
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
This library is free software; you can redistribute it and/or
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
modify it under the terms of the GNU Lesser General Public
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
License as published by the Free Software Foundation; either
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
version 2.1 of the License. 
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
This library is distributed in the hope that it will be useful,
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
but WITHOUT ANY WARRANTY; without even the implied warranty of
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
Lesser General Public License for more details.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
You should have received a copy of the GNU Lesser General Public
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
License along with this library; if not, write to the Free Software
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
"{ Package: 'stx:goodies/smallsense' }"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
"{ NameSpace: SmallSense }"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
273
404662b42ddf Added AbstractTestCase which saves/restores preferences in setUp/tearDown...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 257
diff changeset
    25
AbstractTestCase subclass:#EditSupportTests
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	instanceVariableNames:'codeView codeViewInteractor editService editSupport'
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	classVariableNames:''
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
	poolDictionaries:''
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
	category:'SmallSense-Tests'
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    30
!
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
!EditSupportTests class methodsFor:'documentation'!
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
copyright
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
374
e65bd2bf892a Updated copyright notice.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 273
diff changeset
    37
Copyright (C) 2013-2015 Jan Vrany
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
This library is free software; you can redistribute it and/or
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
modify it under the terms of the GNU Lesser General Public
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
License as published by the Free Software Foundation; either
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
version 2.1 of the License. 
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
This library is distributed in the hope that it will be useful,
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
but WITHOUT ANY WARRANTY; without even the implied warranty of
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
Lesser General Public License for more details.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
You should have received a copy of the GNU Lesser General Public
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
License along with this library; if not, write to the Free Software
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
! !
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
!EditSupportTests methodsFor:'accessing-classes'!
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
editSupportClass
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
    self subclassResponsibility
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
    "Created: / 23-07-2014 / 07:15:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
! !
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
!EditSupportTests methodsFor:'running'!
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
setUp
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
    | topView |
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
444
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
    68
    super setUp.
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
    69
273
404662b42ddf Added AbstractTestCase which saves/restores preferences in setUp/tearDown...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 257
diff changeset
    70
    Smalltalk loadPackage: 'stx:goodies/sunitext/ui'.
404662b42ddf Added AbstractTestCase which saves/restores preferences in setUp/tearDown...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 257
diff changeset
    71
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    topView := StandardSystemView new.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
    topView extent: 320 @ 200.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
    topView label: self printString.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
    codeView := Tools::CodeView2 origin: 0.0@0.0 extent: 1.0@1.0 in: topView.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
    codeViewInteractor := codeView interactor.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    editService := EditService new.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
    editSupport := self editSupportClass new.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
    codeView services: (Array with: editService).
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    codeView language: editSupport language.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
    editService updateSupport: editSupport.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    topView open.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    topView waitUntilVisible.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    "Created: / 23-07-2014 / 07:15:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
444
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
    88
    "Modified (format): / 04-03-2015 / 09:42:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
!
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
tearDown
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    editService := nil.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
    editSupport := nil.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
    codeView topView destroy.
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
444
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
    97
    super tearDown
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
    98
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
    "Created: / 23-07-2014 / 07:17:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
444
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   100
    "Modified: / 04-03-2015 / 09:43:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
257
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
! !
623cefc35e2e Fix for DNU when indent-on-paste is enabled.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
444
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   103
!EditSupportTests class methodsFor:'documentation'!
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   104
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   105
version_HG
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   106
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   107
    ^ '$Changeset: <not expanded> $'
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   108
! !
a47f43af21d6 Smalltalk electric snippets: make iterator variable naming logic more configurable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 374
diff changeset
   109