src/JavaExceptionTests.st
author vranyj1
Fri, 06 Jul 2012 20:58:09 +0000
branchjk_new_structure
changeset 1515 f4ebf5cf3f89
parent 1477 cc9bd91382a2
child 1532 ae63ecbd509e
permissions -rw-r--r--
- JavaClassReaderTests class definition - JavaInterfaceMethodRefTests class definition - JavaClassRefTests class definition - JavaFieldRefTests class definition - JavaRuntimeConstantPoolTests class definition - JavaMethodRefTests class definition - JavaRefsAndConstantPoolTestCase class definition added: #isAbstract - JavaExceptionTests changed:7 methods - stx_libjava changed: #classNamesAndAttributes #extensionMethodNames #preRequisites - JavaByteCodeDisassemblerTests comment/format in: #testMultiBytePrintString - JavaMonitorsTests class definition changed: #test_releasing_01 #test_releasing_02 - extensions ...
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
1461
34a9c99d0295 - test cleanup
vranyj1
parents: 1459
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
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    71
call: trhower with: aBoolean
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
    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
    74
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
    75
    "Created: / 03-04-2012 / 17:33:00 / 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
    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
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   154
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   155
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   156
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   157
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   158
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   159
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   160
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   161
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   162
        thrower throw_me: false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   163
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   164
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   165
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   166
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   167
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   168
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   169
    self assert: caught == false.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   170
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   171
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   172
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   173
    "Created: / 18-03-2012 / 21:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   254
    Scenario (method activation stack, last called at bottom)
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
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   257
        3) Java method, throws IllegalArgumentException.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   258
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   259
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   260
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   261
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   262
    [ 
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   263
        thrower test_03: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   264
        caught := false.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   265
        
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   266
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   267
        caught := true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   268
    ].
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   269
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   270
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   271
    self assert: (thrower instVarNamed: #token) == 3.
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   272
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   273
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   274
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   275
    "Created: / 03-04-2012 / 15:39:08 / Jan Vrany <jan.vrany@fit.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
   276
!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   277
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   278
test_04a
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   279
    "
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   280
    Scenario (method activation stack, last called at bottom)
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   281
        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
   282
        2) Java method with finally
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   283
        3) Smalltak method, throws 'signal'
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   284
    "
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   285
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   286
    | thrower caught |
1515
f4ebf5cf3f89 - JavaClassReaderTests
vranyj1
parents: 1477
diff changeset
   287
    thrower := JAVA stx libjava tests lang ExceptionTests new.
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   288
    [ 
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   289
        thrower test_04: self with: true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   290
        caught := false.        
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   291
    ] on: signal do: [:ex|
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   292
        caught := true.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   293
    ].
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   294
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   295
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   296
    self assert: (thrower instVarNamed: #token) == 3.
1477
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   297
    self assert: (JavaVM enteredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
cc9bd91382a2 - JavaExceptionTests
vranyj1
parents: 1461
diff changeset
   298
    self assert: (JavaVM acquiredMonitorsOfProcess: Processor activeProcess) isEmptyOrNil.
1452
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   299
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   300
    "Created: / 03-04-2012 / 17:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   301
! !
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   302
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   303
!JavaExceptionTests class methodsFor:'documentation'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   304
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   305
version_SVN
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   306
    ^ '$Id$'
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   307
! !