JavaExceptionTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 16 Jan 2013 22:06:41 +0000
branchrefactoring-vmdata
changeset 1977 526315e0a801
parent 1953 1e42ad3fc322
child 2069 75d40b7b986f
permissions -rw-r--r--
Fixed JavaNativeMethodImpl_OpenJDK6 class>>invoke:receiver:arguments:context:constructor:
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
1953
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
    68
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    69
!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
    70
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
    71
call: trhower with: aBoolean 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
    72
    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
    73
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    74
    "Created: / 03-04-2012 / 17:33:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
    75
    "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
    76
!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    77
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    78
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
    79
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    80
    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
    81
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    82
    "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
    83
! !
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    84
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    85
!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
    86
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    87
doesNotUnderstand:aMessage
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    88
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    89
    | 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
    90
    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
    91
    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
    92
    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
    93
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    94
    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
    95
        (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
    96
            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
    97
            ^nil                        
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
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   101
    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
   102
                directedTo: class
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   103
                for: self
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   104
                withArguments: args
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   105
                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
   106
                ilc: nil.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   107
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   108
    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
   109
        ^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
   110
    ] ifFalse:[
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   111
        ^ 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
   112
    ].
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   113
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   114
    "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
   115
    "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
   116
! !
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   117
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   118
!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
   119
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   120
setUp
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   121
    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
   122
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   123
    "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
   124
! !
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   125
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   126
!JavaExceptionTests methodsFor:'tests'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   127
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   128
test_01a
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   129
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   130
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   131
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   132
        2) Java method, throws IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   133
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   134
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   135
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   136
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   137
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   138
        thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   139
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   140
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   141
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   142
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   143
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   144
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   145
    self assert: caught == true.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   146
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   147
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   148
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   149
    "Created: / 18-03-2012 / 11:06:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   150
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   151
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   152
test_01b
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   153
    "
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   154
     Scenario (method activation stack, last called at bottom)
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   155
        1) ST method, handles IllegalArgumentException
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   156
        2) Java method, does not IllegalArgumentException."
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   157
    
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   158
    | thrower  caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   159
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   160
    [
1833
e943f214b868 removing forgotten halts..
hlopkmar
parents: 1832
diff changeset
   161
        thrower throw_me: false.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   162
        caught := false.
1840
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   163
    ] on: JAVA java lang IllegalArgumentException do: [:ex | 
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   164
        caught := true. 
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   165
    ].
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   166
    self assert: caught == false.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   167
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   168
                isEmptyOrNil.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   169
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   170
                isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   171
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   172
    "Created: / 18-03-2012 / 21:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1833
e943f214b868 removing forgotten halts..
hlopkmar
parents: 1832
diff changeset
   173
    "Modified: / 18-11-2012 / 18:17:22 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1840
abd3746f821f Added Boolean class>>javaWrapRequired.
vranyj1
parents: 1833
diff changeset
   174
    "Modified (format): / 29-11-2012 / 22:54:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   175
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   176
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   177
test_01c
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   178
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   179
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   180
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   181
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   182
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   183
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   184
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   185
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   186
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   187
        thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   188
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   189
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   190
    ] on: JAVA java lang Throwable do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   191
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   192
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   193
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   194
    self assert: caught == true.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   195
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   196
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   197
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   198
    "Created: / 18-03-2012 / 22:11:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   199
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   200
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   201
test_01d
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   202
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   203
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   204
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   205
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   206
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   207
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   208
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   209
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   210
    [
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   211
        [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   212
            thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   213
            caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   214
            
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   215
        ] on: JAVA java lang ArrayIndexOutOfBoundsException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   216
            caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   217
        ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   218
    ] on: JavaUnhandledExceptionError do:[
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   219
        caught := 123.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   220
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   221
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   222
    self assert: caught == 123.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   223
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   224
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   225
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   226
    "Created: / 18-03-2012 / 22:12:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   227
!
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   228
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   229
test_01e
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   230
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   231
    Scenario (method activation stack, last called at bottom)
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   232
        1) ST method, handles IllegalArgumentException
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   233
        2) Java method, throws IllegalArgumentException.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   234
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   235
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   236
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   237
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   238
    [ 
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   239
        thrower call: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   240
        caught := false.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   241
        
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   242
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   243
        caught := true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   244
    ].
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   245
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   246
    self assert: caught == true.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   247
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   248
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   249
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   250
    "Created: / 03-04-2012 / 14:44:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   251
!
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   252
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   253
test_03a
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   254
    "
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   255
     Scenario (method activation stack, last called at bottom)
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   256
        1) ST method, handles IllegalArgumentException
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   257
        2) Java method with finally
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   258
        3) Java method, throws IllegalArgumentException."
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   259
    
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   260
    | thrower  caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   261
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   262
    [
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   263
        thrower test_03: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   264
        caught := false.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   265
    ] on: JAVA java lang IllegalArgumentException do: [:ex | caught := true. ].
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   266
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   267
    self assert: (thrower instVarNamed: #token) == 3.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   268
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   269
                isEmptyOrNil.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   270
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   271
                isEmptyOrNil.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   272
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   273
    "Created: / 03-04-2012 / 15:39:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   274
    "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
   275
!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   276
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   277
test_04a
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   278
    "
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   279
     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
   280
        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
   281
        2) Java method with finally
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   282
        3) Smalltak method, throws 'signal'"
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   283
    
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   284
    | thrower  caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   285
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   286
    [
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   287
        thrower test_04: self with: true.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   288
        caught := false.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   289
    ] 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
   290
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   291
    self assert: (thrower instVarNamed: #token) == 3.
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   292
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   293
                isEmptyOrNil.
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   294
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) 
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   295
                isEmptyOrNil.
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   296
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   297
    "Created: / 03-04-2012 / 17:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1832
d7201987d0a0 exception tests fixes..
hlopkmar
parents: 1818
diff changeset
   298
    "Modified: / 18-11-2012 / 18:04:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   299
! !
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   300
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   301
!JavaExceptionTests class methodsFor:'documentation'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   302
1953
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
   303
version_HG
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
   304
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
   305
    ^ '$Changeset: <not expanded> $'
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
   306
!
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
   307
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   308
version_SVN
1953
1e42ad3fc322 Added support Java>>addToClassPath: & Java>>addToSourcePath:. Removed JavaPathElement.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1843
diff changeset
   309
    ^ '§Id§'
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   310
! !