JavaExceptionTests.st
author hlopkmar
Wed, 12 Dec 2012 23:26:59 +0000
branchdevelopment
changeset 1869 0ae14ac1c9af
parent 1843 eff50e345dff
child 1953 1e42ad3fc322
permissions -rw-r--r--
java compiler (javac wrapper) and basic class reloading tests
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     1
"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     3
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     4
 New code and modifications done at SWING Research Group [1]:
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     5
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     8
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    14
 hereby transferred.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    15
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    16
 [1] Code written at SWING Research Group contains a signature
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    17
     of one of the above copright owners. For exact set of such code,
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    18
     see the differences between this version and version stx:libjava
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    19
     as of 1.9.2010
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    20
"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    21
"{ Package: 'stx:libjava' }"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    22
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    23
TestCase subclass:#JavaExceptionTests
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    24
	instanceVariableNames:'signal'
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    25
	classVariableNames:''
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    26
	poolDictionaries:''
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    27
	category:'Languages-Java-Tests'
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    28
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    29
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    30
!JavaExceptionTests class methodsFor:'documentation'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    31
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    32
copyright
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    33
"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    34
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    35
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    36
 New code and modifications done at SWING Research Group [1]:
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    37
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    38
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    39
                            SWING Research Group, Czech Technical University in Prague
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    40
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    41
 This software is furnished under a license and may be used
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    42
 only in accordance with the terms of that license and with the
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    43
 inclusion of the above copyright notice.   This software may not
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    44
 be provided or otherwise made available to, or used by, any
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    45
 other person.  No title to or ownership of the software is
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    46
 hereby transferred.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    47
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    48
 [1] Code written at SWING Research Group contains a signature
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    49
     of one of the above copright owners. For exact set of such code,
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    50
     see the differences between this version and version stx:libjava
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    51
     as of 1.9.2010
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    52
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    53
"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    54
! !
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    55
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    56
!JavaExceptionTests class methodsFor:'accessing'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    57
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    58
resources
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    59
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    60
  ^ Array 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    61
        with: JavaInitializedResource 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    62
        with: JavaLibrariesResource
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    63
        with: JavaTestsResource
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    64
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    65
    "Created: / 30-03-2012 / 13:38:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    66
! !
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
    67
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    68
!JavaExceptionTests methodsFor:'callbacks'!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    69
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
    70
call: trhower with: aBoolean 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
    71
    aBoolean ifTrue: [ signal raise ].
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    72
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    73
    "Created: / 03-04-2012 / 17:33:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
    74
    "Modified: / 18-11-2012 / 18:04:47 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    75
!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    76
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    77
throw_me: aBoolean
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    78
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    79
    aBoolean ifTrue:[signal raise].
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    80
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    81
    "Created: / 03-04-2012 / 17:31:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    82
! !
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    83
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    84
!JavaExceptionTests methodsFor:'error handling (interop)'!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    85
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    86
doesNotUnderstand:aMessage
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    87
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    88
    | method  selector class args|
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    89
    selector := aMessage selector.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    90
    args := aMessage arguments.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    91
    class := self class.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    92
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    93
    JavaLookup isNil ifTrue:[
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    94
        (Smalltalk loadPackage: 'stx:libjava/experiments') ifFalse:[
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    95
            self error: 'You should load package stx:libjava/experiments if you want some interop - still experimental' mayProceed: true.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    96
            ^nil                        
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    97
        ]        
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    98
    ].
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    99
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   100
    method := JavaLookup instance lookupMethodForSelector: selector
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   101
                directedTo: class
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   102
                for: self
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   103
                withArguments: args
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   104
                from: thisContext sender sender
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   105
                ilc: nil.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   106
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   107
    method isNil ifTrue:[
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   108
        ^super doesNotUnderstand:aMessage
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   109
    ] ifFalse:[
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   110
        ^ method valueWithReceiver: self arguments: args
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   111
    ].
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   112
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   113
    "Created: / 06-09-2011 / 22:16:26 / Jan Kurs <kursjan@fit.cvut.cz>"
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   114
    "Modified: / 15-12-2011 / 23:42:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   115
! !
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   116
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   117
!JavaExceptionTests methodsFor:'running'!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   118
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   119
setUp
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   120
    signal := Signal new.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   121
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   122
    "Created: / 03-04-2012 / 17:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   123
! !
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   124
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   125
!JavaExceptionTests methodsFor:'tests'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   126
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   127
test_01a
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   128
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   129
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   130
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   131
        2) Java method, throws IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   132
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   133
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   134
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   135
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   136
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   137
        thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   138
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   139
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   140
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   141
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   142
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   143
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   144
    self assert: caught == true.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   145
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   146
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   147
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   148
    "Created: / 18-03-2012 / 11:06:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   149
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   150
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   151
test_01b
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   152
    "
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   153
     Scenario (method activation stack, last called at bottom)
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   154
        1) ST method, handles IllegalArgumentException
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   155
        2) Java method, does not IllegalArgumentException."
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   156
    
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   157
    | thrower  caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   158
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   159
    [
1833
e943f214b868 removing forgotten halts..
hlopkmar
parents: 1832
diff changeset
   160
        thrower throw_me: false.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   161
        caught := false.
1840
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   162
    ] on: JAVA java lang IllegalArgumentException do: [:ex | 
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   163
        caught := true. 
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   164
    ].
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   165
    self assert: caught == false.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   166
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   167
                isEmptyOrNil.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   168
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   169
                isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   170
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   171
    "Created: / 18-03-2012 / 21:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1833
e943f214b868 removing forgotten halts..
hlopkmar
parents: 1832
diff changeset
   172
    "Modified: / 18-11-2012 / 18:17:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1840
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   173
    "Modified (format): / 29-11-2012 / 22:54:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   174
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   175
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   176
test_01c
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   177
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   178
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   179
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   180
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   181
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   182
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   183
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   184
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   185
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   186
        thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   187
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   188
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   189
    ] on: JAVA java lang Throwable do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   190
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   191
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   192
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   193
    self assert: caught == true.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   194
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   195
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   196
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   197
    "Created: / 18-03-2012 / 22:11:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   198
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   199
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   200
test_01d
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   201
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   202
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   203
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   204
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   205
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   206
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   207
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   208
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   209
    [
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   210
        [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   211
            thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   212
            caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   213
            
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   214
        ] on: JAVA java lang ArrayIndexOutOfBoundsException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   215
            caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   216
        ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   217
    ] on: JavaUnhandledExceptionError do:[
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   218
        caught := 123.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   219
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   220
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   221
    self assert: caught == 123.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   222
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   223
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   224
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   225
    "Created: / 18-03-2012 / 22:12:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   226
!
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   227
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   228
test_01e
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   229
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   230
    Scenario (method activation stack, last called at bottom)
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   231
        1) ST method, handles IllegalArgumentException
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   232
        2) Java method, throws IllegalArgumentException.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   233
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   234
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   235
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   236
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   237
    [ 
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   238
        thrower call: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   239
        caught := false.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   240
        
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   241
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   242
        caught := true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   243
    ].
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   244
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   245
    self assert: caught == true.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   246
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   247
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   248
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   249
    "Created: / 03-04-2012 / 14:44:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   250
!
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   251
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   252
test_03a
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   253
    "
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   254
     Scenario (method activation stack, last called at bottom)
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   255
        1) ST method, handles IllegalArgumentException
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   256
        2) Java method with finally
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   257
        3) Java method, throws IllegalArgumentException."
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   258
    
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   259
    | thrower  caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   260
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   261
    [
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   262
        thrower test_03: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   263
        caught := false.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   264
    ] on: JAVA java lang IllegalArgumentException do: [:ex | caught := true. ].
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   265
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   266
    self assert: (thrower instVarNamed: #token) == 3.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   267
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   268
                isEmptyOrNil.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   269
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   270
                isEmptyOrNil.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   271
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   272
    "Created: / 03-04-2012 / 15:39:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   273
    "Modified (comment): / 18-11-2012 / 16:50:50 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   274
!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   275
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   276
test_04a
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   277
    "
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   278
     Scenario (method activation stack, last called at bottom)
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   279
        1) ST method, handles 'signal'
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   280
        2) Java method with finally
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   281
        3) Smalltak method, throws 'signal'"
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   282
    
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   283
    | thrower  caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   284
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   285
    [
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   286
        thrower test_04: self with: true.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   287
        caught := false.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   288
    ] on: signal do: [:ex | caught := true. ].
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   289
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   290
    self assert: (thrower instVarNamed: #token) == 3.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   291
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   292
                isEmptyOrNil.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   293
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   294
                isEmptyOrNil.
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   295
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   296
    "Created: / 03-04-2012 / 17:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   297
    "Modified: / 18-11-2012 / 18:04:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   298
! !
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   299
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   300
!JavaExceptionTests class methodsFor:'documentation'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   301
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   302
version_SVN
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   303
    ^ '$Id$'
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   304
! !