SmallSense__SmalltalkEditSupportTests.st
author Claus Gittinger <cg@exept.de>
Mon, 15 Jul 2019 15:33:58 +0200
branchcvs_MAIN
changeset 1091 8c18b8f6ff0c
parent 274 2cfcd8eb9761
child 374 e65bd2bf892a
permissions -rw-r--r--
#OTHER by cg unneeded subProjects method removed (already inherited)

"
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
Copyright (C) 2013-2014 Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
"{ Package: 'stx:goodies/smallsense' }"

"{ NameSpace: SmallSense }"

EditSupportTests subclass:#SmalltalkEditSupportTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'SmallSense-Tests'
!

!SmalltalkEditSupportTests class methodsFor:'documentation'!

copyright
"
stx:goodies/smallsense - A productivity plugin for Smalltalk/X IDE
Copyright (C) 2013-2014 Jan Vrany

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License. 

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
"
! !

!SmalltalkEditSupportTests methodsFor:'accessing-classes'!

editSupportClass
    "superclass SmallSense::EditSupportTests says that I am responsible to implement this method"

    ^ SmalltalkEditSupport

    "Created: / 23-07-2014 / 07:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmalltalkEditSupportTests methodsFor:'tests - completion'!

test_complete_if_unambiguous_01    

    UserPreferences current smallSenseCompleteIfUnambiguous: true.  
    codeView editedMethodOrClass: self class.
    codeView contents:'editService'.
    codeView setCursorCol: 12.

    codeViewInteractor type: #(Return Tab).
    codeViewInteractor type: 't'.
    Delay waitForMilliseconds: 250.
    codeViewInteractor type: 'h'.
    self assert: (codeView list at: 2) = '    thisContext'.
    Delay waitForMilliseconds: 250.
    codeViewInteractor type: 'isContext'.
    self assert: (codeView list at: 2) = '    thisContext'.

    "Created: / 23-07-2014 / 23:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:58:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_complete_if_unambiguous_02

    UserPreferences current smallSenseCompleteIfUnambiguous: true.  
    codeView editedMethodOrClass: self class.
    codeView contents:'editService'.
    codeView setCursorCol: 12.

    codeViewInteractor type: #(Return Tab).
    codeViewInteractor type: 't'.
    Delay waitForMilliseconds: 250.
    codeViewInteractor type: 'h'.
    self assert: (codeView list at: 2) = '    thisContext'.
    Delay waitForMilliseconds: 250.
    codeViewInteractor type: 'is receiver'.
    self assert: (codeView list at: 2) = '    thisContext receiver'.

    "Created: / 11-08-2014 / 15:00:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_complete_if_unambiguous_03

    UserPreferences current smallSenseCompleteIfUnambiguous: true.  
    codeView editedMethodOrClass: self class.
    codeView contents:'editService'.
    codeView setCursorCol: 12.

    codeViewInteractor type: #(Return Tab).
    codeViewInteractor type: 't'.
    Delay waitForMilliseconds: 250.
    codeViewInteractor type: 'h'.
    self assert: (codeView list at: 2) = '    thisContext'.
    Delay waitForMilliseconds: 250.
    codeViewInteractor type: 'isValue'.
    self assert: (codeView list at: 2) = '    thisValue'.

    "Created: / 11-08-2014 / 15:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmalltalkEditSupportTests methodsFor:'tests - indent-on-paste'!

test_indent_on_paste_01a

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 

    ].
    self halt.'.

    codeView selectFromLine: 5 col: 5 toLine: 5 col: 14.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        self halt.'.

    "Created: / 23-07-2014 / 09:46:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_01b

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 

    ].
    self halt.'.

    codeView selectFromLine:5 col:1 toLine:6 col:0.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        self halt.'.

    "Created: / 23-07-2014 / 09:47:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_02a

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 

    ].
    param isNil ifTrue:[
        self halt.
    ]'.

    codeView selectFromLine: 5 col: 5 toLine: 7 col: 5.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        param isNil ifTrue:['.
    self assert: (codeView list at: 4) = '            self halt.'.
    self assert: (codeView list at: 5) = '        ]'.

    "Created: / 23-07-2014 / 10:20:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_02b

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 

    ].
    param isNil ifTrue:[
        self halt.
    ]'.

    codeView selectFromLine: 5 col: 1 toLine: 8 col: 0.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        param isNil ifTrue:['.
    self assert: (codeView list at: 4) = '            self halt.'.
    self assert: (codeView list at: 5) = '        ]'.

    "Created: / 23-07-2014 / 10:20:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_03a

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 

    ].
    param isNil ifTrue:[
        self halt.
    ]'.

    codeView selectFromLine: 5 col: 5 toLine: 6 col: 18.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        param isNil ifTrue:['.
    self assert: (codeView list at: 4) = '            self halt.'.

    "Created: / 23-07-2014 / 23:28:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_03b

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 

    ].
    param isNil ifTrue:[
        self halt.
    ]'.

    codeView selectFromLine: 5 col: 1 toLine: 7 col: 0.


    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        param isNil ifTrue:['.
    self assert: (codeView list at: 4) = '            self halt.'.

    "Created: / 23-07-2014 / 23:28:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_04a

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 
        Transcript showCR:''XXX''.
    ].
    self halt.'.

    codeView selectFromLine: 5 col: 5 toLine: 5 col: 14.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '    self halt.    Transcript showCR:''XXX''.'.

    "Created: / 24-07-2014 / 10:18:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_04b

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 
        Transcript showCR:''XXX''.
    ].
    self halt.'.

    codeView selectFromLine: 5 col: 5 toLine: 6 col: 0.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '    self halt.'.
    self assert: (codeView list at: 4) = '    Transcript showCR:''XXX''.'.

    "Created: / 24-07-2014 / 10:21:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_indent_on_paste_04c

    UserPreferences current smallSenseSmalltalkIndentOnPasteEnabled: true.
    codeView contents:'test
    Debug ifTrue:[ 
        Transcript showCR:''XXX''.
    ].
    self halt.'.

    codeView selectFromLine: 5 col: 5 toLine: 6 col: 0.

    codeViewInteractor type: #Cut.
    codeViewInteractor type: #(CursorUp CursorUp CursorRight CursorRight CursorRight CursorRight).
    codeViewInteractor type: #Paste.

    self assert: (codeView list at: 3) = '        self halt.'.
    self assert: (codeView list at: 4) = 'Transcript showCR:''XXX''.'.

    "Created: / 24-07-2014 / 10:22:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 11-08-2014 / 14:26:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !