TestAsserter.st
author Claus Gittinger <cg@exept.de>
Sun, 26 Aug 2018 19:19:00 +0200
changeset 721 c11e3a43a1b4
parent 718 b37f66696d9b
child 729 5df0b62db3d7
permissions -rw-r--r--
#FEATURE by cg class: TestAsserter added: #assert:isAtLeast: class: TestAsserter class changed: #assert:description:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
708
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
     1
"{ Encoding: utf8 }"
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
     2
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:goodies/sunit' }"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
     5
"{ NameSpace: Smalltalk }"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
     6
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
Object subclass:#TestAsserter
376
3fff80e1b3be removed leftover rubbish
Claus Gittinger <cg@exept.de>
parents: 333
diff changeset
     8
	instanceVariableNames:''
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	category:'SUnit-Base'
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
TestAsserter comment:''
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
!TestAsserter class methodsFor:'asserting'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
    20
assert: aBooleanOrBlock description: aString
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    21
        "Minimal clone of the instance-side assert protocol so that class-side methods can use it."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
    23
        aBooleanOrBlock value ifFalse: [
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    24
            self logFailure: aString.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    25
            TestResult failure sunitSignalWith: aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    26
        ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    27
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    28
    "Modified (format): / 13-07-2017 / 15:03:51 / cg"
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
    29
    "Modified: / 26-08-2018 / 18:06:18 / Claus Gittinger"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!TestAsserter class methodsFor:'logging'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
failureLog
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
	^SUnitNameResolver defaultLogDevice
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
isLogging
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
	"By default, we're not logging failures. Override in subclasses as desired."
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
	^false
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
logFailure: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
	self isLogging ifTrue:
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
		[self failureLog cr; nextPutAll: aString; flush].
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    47
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    48
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    49
logSkipped: aString
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    50
        self isLogging ifTrue:
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
    51
                [self failureLog cr; nextPutAll: aString; flush].
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    54
!TestAsserter class methodsFor:'private'!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    55
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    56
comparingCollectionBetween: left and: right
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    57
    "helper to generate a nice description, if 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    58
     a collection is not the expected one."
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    59
     
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    60
    | additionalLeft additionalRight sortBlock|
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    61
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    62
    "use a very slow sort block"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    63
    sortBlock := [ :a :b | a asString <= b asString ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    64
    additionalLeft := (left difference: right) sorted: sortBlock.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    65
    additionalRight := (right difference: left) sorted: sortBlock. 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    66
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    67
    ^ String 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    68
        streamContents: [:stream |
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    69
            stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    70
                nextPutAll: 'Given Collections do not match.'; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    71
                tab; nextPutAll: 'Got left := '; print: left; nextPut: $.; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    72
                nextPutAll: ' instead of '; lf;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    73
                tab; nextPutAll: 'right :='; print: right; nextPut: $.; lf.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    74
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    75
            left size = right size ifFalse: [ 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    76
                stream 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    77
                    nextPutAll: 'Collection size does not match: left='; 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    78
                    print: left size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    79
                    nextPutAll: ' vs. right=';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    80
                    print: right size; lf 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    81
            ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    82
            additionalLeft notEmpty ifTrue:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    83
                  stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    84
                      nextPutAll:'Got ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    85
                      print:additionalLeft size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    86
                      nextPutAll:' additional element(s) in the left collection: ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    87
                      tab;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    88
                      print:additionalLeft
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    89
            ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    90
            additionalRight notEmpty ifTrue:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    91
                  stream
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    92
                      nextPutAll:'Got ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    93
                      print:additionalRight size;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    94
                      nextPutAll:' additional element(s) in the right collection: ';
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    95
                      tab;
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    96
                      print:additionalRight
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    97
            ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    98
        ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
    99
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   100
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   101
     self basicNew comparingCollectionBetween:#(1 2 3) and:#(1 2 3 4)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   102
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   103
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   104
    "Modified: / 13-07-2017 / 14:13:15 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   105
! !
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   106
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
!TestAsserter methodsFor:'asserting'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   109
assert: aBooleanOrBlock
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   110
    "fail the testcase if aBooleanOrBlock evaluates to false"
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   111
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   114
    aBooleanOrBlock value ifFalse:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   115
        self logFailure: 'Assertion failed'.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   116
        TestResult failure sunitSignalWith: 'Assertion failed'
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   117
    ].
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   119
    "Modified: / 05-12-2009 / 18:14:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   120
    "Modified: / 13-07-2017 / 13:50:13 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   121
    "Modified (comment): / 13-07-2017 / 15:05:33 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   124
assert:aBooleanOrBlock description:aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   125
    "fail the testCase if aBooleanOrBlock evaluates to false, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   126
     and report aStringOrBlock's value as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
708
35643bf43d6a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 692
diff changeset
   128
    <resource: #skipInDebuggersWalkBack>
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
692
781228855c60 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 687
diff changeset
   130
    ^ self assert:aBooleanOrBlock description:aString resumable: false.
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   131
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   132
    "Modified: / 11-09-2010 / 15:34:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
692
781228855c60 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 687
diff changeset
   133
    "Modified (format): / 09-11-2017 / 10:03:58 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   136
assert:aBooleanOrBlock description:aStringOrBlock resumable:resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   137
    "fail the testCase if aBooleanOrBlock evaluates to false, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   138
     and report aStringOrBlock's value as failure-description.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   139
     If resumableBoolean is true, the test can be resumed in the debugger (if it was started by 'Debug')"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   143
    | exception |
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   144
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   145
    aBooleanOrBlock value ifFalse:[
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   146
        |string|
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   148
        string := aStringOrBlock value.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   149
        self logFailure: string.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   150
        exception := resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   151
                        ifTrue: [TestResult resumableFailure]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   152
                        ifFalse: [TestResult failure].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   153
        exception sunitSignalWith: string
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   154
    ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   155
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   156
    "Modified: / 05-12-2009 / 18:15:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   157
    "Modified: / 13-07-2017 / 13:49:38 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   158
    "Modified (comment): / 13-07-2017 / 15:07:33 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   159
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   161
deny: aBooleanOrBlock
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   162
    "fail the testcase if aBooleanOrBlock evaluates to true"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
    <resource: #skipInDebuggersWalkBack>
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   165
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   166
    self assert:(aBooleanOrBlock value not).
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   167
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   168
    "Modified: / 05-12-2009 / 18:16:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   169
    "Modified (comment): / 13-07-2017 / 15:06:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   170
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   171
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   172
deny: aBooleanOrBlock description: aString
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   173
    "fail the testCase if aBooleanOrBlock evaluates to true, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   174
     and report aStringOrBlock's value as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   178
    self assert:(aBooleanOrBlock value not) description:aString.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   179
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   180
    "Modified: / 05-12-2009 / 18:17:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   181
    "Modified (comment): / 13-07-2017 / 15:06:30 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   182
!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   183
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   184
deny:aBooleanOrBlock description:aString resumable:resumableBoolean
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   185
    "fail the testCase if aBooleanOrBlock evaluates to true, 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   186
     and report aStringOrBlock's value as failure-description.
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   187
     If resumableBoolean is true, the test can be resumed in the debugger (if it was started by 'Debug')"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   188
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   189
    <resource: #skipInDebuggersWalkBack>
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   190
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   191
    self assert:(aBooleanOrBlock value not) description:aString resumable:resumableBoolean.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
    "Modified: / 05-12-2009 / 18:17:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   194
    "Modified (comment): / 13-07-2017 / 15:07:38 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
should: aBlock raise: anExceptionalEvent
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   198
    "during the execution of aBlock, the anExceptionalEvent should be raised"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    "Modified: / 05-12-2009 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
should: aBlock raise: anExceptionalEvent description: aString
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   208
    "during the execution of aBlock, the anExceptionalEvent should be raised.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   209
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   214
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent)
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   215
        description: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    "Modified: / 05-12-2009 / 18:18:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
should: aBlock raise: anExceptionalEvent suchThat: condBlock
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   221
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   222
     and condBlock should return true on the exception instance"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent suchThat: condBlock).
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    "Created: / 05-05-2011 / 20:14:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
should: aBlock raise: anExceptionalEvent suchThat: condBlock description: description
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   232
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   233
     and condBlock should return true on the exception instance.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   234
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
    self assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent suchThat: condBlock)
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   239
         description: description
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    "Created: / 05-05-2011 / 20:14:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   244
should: aBlock raise: anExceptionalEvent whoseDescriptionIncludes: aStringFragment
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   245
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   246
     and aStringFragment should be contained in the exception-instances description."
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   247
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   248
    <resource: #skipInDebuggersWalkBack>
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   249
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   250
    ^ self should: aBlock 
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   251
           raise: anExceptionalEvent
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   252
           suchThat:[:ex | ex description includesString: aStringFragment]
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   253
!
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   254
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   255
should:aBlock raise:anExceptionalEvent whoseDescriptionIncludes:aStringFragment description:aString
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   256
    "during the execution of aBlock, the anExceptionalEvent should be raised,
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   257
     and aStringFragment should be contained in the exception-instances description.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   258
     If not, report aString as failure-description."
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   259
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   260
    <resource: #skipInDebuggersWalkBack>
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   261
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   262
    ^ self should: aBlock 
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   263
           raise: anExceptionalEvent
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   264
           suchThat:[:ex | ex description includesString: aStringFragment]
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   265
           description: aString.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   266
!
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   267
718
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   268
should:aBlock raise:anExceptionalEvent withExceptionDo:exCheckAction
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   269
    "during the execution of aBlock, the anExceptionalEvent should be raised,
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   270
     then exCheckAction is evaluated on the exception (which usually includes more checks).
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   271
     If not, report aString as failure-description."
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   272
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   273
    <resource: #skipInDebuggersWalkBack>
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   274
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   275
    ^ self should: aBlock 
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   276
           raise: anExceptionalEvent
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   277
           suchThat:[:ex | exCheckAction value:ex. true]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   278
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   279
    "should fail:
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   280
    
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   281
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   282
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   283
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   284
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   285
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   286
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   287
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   288
     should fail:   
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   289
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   290
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   291
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   292
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   293
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   294
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   295
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   296
     should pass:   
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   297
         self new
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   298
            should:[ 1 / Float zero]
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   299
            raise:ZeroDivide
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   300
            withExceptionDo:[:ex |
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   301
                ex description should equal:'hello world'
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   302
            ].
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   303
    "
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   304
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   305
    "Created: / 01-07-2018 / 12:18:18 / Claus Gittinger"
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   306
!
b37f66696d9b #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 708
diff changeset
   307
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   308
shouldnt: aBlock raise: anExceptionalEvent
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   309
    "during the execution of aBlock, the anExceptionalEvent should NOT be raised"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   310
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   311
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   312
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   313
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   314
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   315
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
    "Modified: / 05-12-2009 / 18:18:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
shouldnt: aBlock raise: anExceptionalEvent description: aString
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   320
    "during the execution of aBlock, the anExceptionalEvent should NOT be raised.
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   321
     If not, report aString as failure-description."
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    self
566
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   326
        assert: (self executeShould: aBlock inScopeOf: anExceptionalEvent) not
85fa38b16283 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   327
        description: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   328
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   329
    "Modified: / 05-12-2009 / 18:18:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   330
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   331
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   332
skip
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   333
    "skip this test"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   334
    
650
20c408a44d5d #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 649
diff changeset
   335
    self skipIf:true description:'Test Skipped'.
649
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   336
!
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   337
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   338
skip:messageString
649
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   339
    "skip this test"
a69fdedffe06 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 647
diff changeset
   340
    
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   341
    self skipIf:true description:messageString
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   342
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   343
    "Modified (format): / 12-02-2017 / 22:44:11 / cg"
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   344
!
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   345
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   346
skipIf:aCondition description:messageString
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   347
    "skip this test, if some condition is met"
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   348
    
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   349
    aCondition value ifTrue: [
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   350
        self logSkipped: 'Skipped - ',messageString.
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   351
        TestResult skipped sunitSignalWith: messageString
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   352
    ].
674
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   353
ddf31755804e #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 650
diff changeset
   354
    "Modified (format): / 12-02-2017 / 22:44:17 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
!TestAsserter methodsFor:'convenience'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   359
assert:anObject equals:anotherObject
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   360
    ^ self 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   361
        assert: anObject = anotherObject
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   362
        description: [ anObject printString, ' is not equal to ', anotherObject printString ].
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   363
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   364
    "Modified: / 13-07-2017 / 15:12:26 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   365
!
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   366
721
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   367
assert:anObject isAtLeast:anotherObject
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   368
    ^ self 
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   369
        assert: anObject >= anotherObject
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   370
        description: [ anObject printString, ' is less than ', anotherObject printString ].
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   371
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   372
    "Created: / 26-08-2018 / 18:01:14 / Claus Gittinger"
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   373
!
c11e3a43a1b4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 718
diff changeset
   374
687
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   375
assertCollection:actual equals:expected
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   376
    "specialized test method that generates a proper error message for collection"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   377
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   378
    ^ self 
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   379
        assert:(expected = actual)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   380
        description:[ self class comparingCollectionBetween:actual and:expected ]
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   381
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   382
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   383
     self basicNew assertCollection:#(1 2 3) equals:#(1 2 3)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   384
     self basicNew assertCollection:#(1 2 3) equals:#(1 2 3 4)
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   385
    "
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   386
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   387
    "Created: / 13-07-2017 / 13:46:51 / cg"
e8513ab11939 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 674
diff changeset
   388
    "Modified (comment): / 13-07-2017 / 15:03:28 / cg"
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
!TestAsserter methodsFor:'logging'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
logFailure: aString
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
	self class logFailure: aString.
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   395
!
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   396
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   397
logSkipped: aString
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   398
        self class logSkipped: aString.
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
!TestAsserter methodsFor:'private'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
executeShould: execBlock inScopeOf: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
    <resource: #skipInDebuggersWalkBack>
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   406
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
    ^ self
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
	executeShould: execBlock
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
	inScopeOf: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
	suchThat: [:ex | true ]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
    "Modified: / 05-05-2011 / 20:23:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
executeShould: execBlock inScopeOf: exceptionalEvent suchThat: conditionBlock
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
	^[execBlock value.
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
	false]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
		sunitOn: exceptionalEvent
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
		do:
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
		    [:ex |
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
		    ex sunitExitWith:(conditionBlock value: ex)]
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   423
    "Created: / 05-05-2011 / 20:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
! !
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
!TestAsserter class methodsFor:'documentation'!
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
286
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   428
version
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   429
    ^ '$Header$'
286
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   430
!
01b3ae052203 changed: #executionTime
Claus Gittinger <cg@exept.de>
parents: 284
diff changeset
   431
223
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   432
version_CVS
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   433
    ^ '$Header$'
223
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   434
!
354de0061492 initial checkin
Claus Gittinger <cg@exept.de>
parents: 222
diff changeset
   435
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
version_SVN
647
f825e6333193 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 566
diff changeset
   437
    ^ '$Id$'
222
8e6f482297fa Jan's 4.1 version
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
! !
551
29cd2a10af89 class: TestAsserter
Claus Gittinger <cg@exept.de>
parents: 416
diff changeset
   439