src/JavaExceptionTests.st
author vranyj1
Tue, 10 Apr 2012 10:21:41 +0000
branchjk_new_structure
changeset 1461 34a9c99d0295
parent 1459 9e24f4337d78
child 1477 cc9bd91382a2
permissions -rw-r--r--
- test cleanup - fix for finally handler
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 |
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   136
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
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
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   145
    self assert: caught == true
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   146
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   147
    "Created: / 18-03-2012 / 11:06:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   148
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   149
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   150
test_01b
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   151
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   152
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   153
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   154
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   155
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   156
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   157
    | thrower caught |
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   158
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   159
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   160
        thrower throw_me: false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   161
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   162
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   163
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   164
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   165
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   166
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   167
    self assert: caught == false
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   168
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   169
    "Created: / 18-03-2012 / 21:49:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   170
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   171
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   172
test_01c
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   173
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   174
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   175
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   176
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   177
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   178
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   179
    | thrower caught |
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   180
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   181
    [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   182
        thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   183
        caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   184
        
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   185
    ] on: JAVA java lang Throwable do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   186
        caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   187
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   188
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   189
    self assert: caught == true
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   190
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   191
    "Created: / 18-03-2012 / 22:11:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   192
!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   193
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   194
test_01d
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   195
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   196
    Scenario (method activation stack, last called at bottom)
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   197
        1) ST method, handles IllegalArgumentException
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   198
        2) Java method, does not IllegalArgumentException.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   199
    "
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   200
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   201
    | thrower caught |
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   202
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   203
    [
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   204
        [ 
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   205
            thrower throw_me: true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   206
            caught := false.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   207
            
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   208
        ] on: JAVA java lang ArrayIndexOutOfBoundsException do: [:ex|
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   209
            caught := true.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   210
        ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   211
    ] on: JavaUnhandledExceptionError do:[
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   212
        caught := 123.
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   213
    ].
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   214
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   215
    self assert: caught == 123
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   216
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   217
    "Created: / 18-03-2012 / 22:12:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   218
!
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   219
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   220
test_01e
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   221
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   222
    Scenario (method activation stack, last called at bottom)
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   223
        1) ST method, handles IllegalArgumentException
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   224
        2) Java method, throws IllegalArgumentException.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   225
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   226
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   227
    | thrower caught |
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   228
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   229
    [ 
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   230
        thrower call: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   231
        caught := false.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   232
        
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   233
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   234
        caught := true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   235
    ].
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   236
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   237
    self assert: caught == true
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   238
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   239
    "Created: / 03-04-2012 / 14:44:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   240
!
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   241
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   242
test_03a
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   243
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   244
    Scenario (method activation stack, last called at bottom)
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   245
        1) ST method, handles IllegalArgumentException
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   246
        2) Java method with finally
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   247
        3) Java method, throws IllegalArgumentException.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   248
    "
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   249
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   250
    | thrower caught |
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   251
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   252
    [ 
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   253
        thrower test_03: true.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   254
        caught := false.
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   255
        
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   256
    ] on: JAVA java lang IllegalArgumentException do: [:ex|
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   257
        caught := true.
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
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   261
    self assert: (thrower instVarNamed: #token) == 3.
1450
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   262
4817f2a363d6 More JavaExceptionTests
vranyj1
parents: 1440
diff changeset
   263
    "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
   264
!
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   265
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   266
test_04a
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   267
    "
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   268
    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
   269
        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
   270
        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
   271
        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
   272
    "
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   273
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   274
    | thrower caught |
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   275
    thrower := JAVA stx libjava tests SimpleExceptionThrower new.
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
        thrower test_04: self with: true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   278
        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
   279
    ] 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
   280
        caught := true.
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   281
    ].
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   282
69dcb9c33742 Some more support for finally block when a Smalltalk exception is thrown - not yet working correctly
vranyj1
parents: 1450
diff changeset
   283
    self assert: caught == true.
1455
0bd5fedc1d2c Temporary commit - some more finally support
vranyj1
parents: 1452
diff changeset
   284
    self assert: (thrower instVarNamed: #token) == 3.
1452
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
    "Created: / 03-04-2012 / 17:30:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1440
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   287
! !
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   288
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   289
!JavaExceptionTests class methodsFor:'documentation'!
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   290
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   291
version_SVN
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   292
    ^ '$Id$'
3737a6150f96 Added JavaExceptionTests
vranyj1
parents:
diff changeset
   293
! !