JavaMethodRefTests.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Nov 2011 12:54:59 +0100
changeset 2305 c11e70f81f74
parent 2152 1cbdfbcc685c
child 2353 fa7400d022a0
permissions -rw-r--r--
fixed: #version_SVN ($ to ยง)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
749
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     1
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     3
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     4
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     5
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     6
 Parts of the code written by Claus Gittinger are under following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     7
 license:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     8
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
     9
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    10
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    11
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    12
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    13
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    14
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    15
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    16
 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    17
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    18
 Permission is hereby granted, free of charge, to any person
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    19
 obtaining a copy of this software and associated documentation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    20
 files (the 'Software'), to deal in the Software without
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    21
 restriction, including without limitation the rights to use,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    22
 copy, modify, merge, publish, distribute, sublicense, and/or sell
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    23
 copies of the Software, and to permit persons to whom the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    24
 Software is furnished to do so, subject to the following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    25
 conditions:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    26
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    27
 The above copyright notice and this permission notice shall be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    28
 included in all copies or substantial portions of the Software.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    29
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    30
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    31
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    32
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    33
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    34
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    35
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    36
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    37
 OTHER DEALINGS IN THE SOFTWARE.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    38
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    39
 [1] Code written at SWING Research Group contain a signature
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    40
     of one of the above copright owners.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    41
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    42
"{ Package: 'stx:libjava' }"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    43
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    44
AbstractJavaTestCase subclass:#JavaMethodRefTests
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    45
	instanceVariableNames:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    46
	classVariableNames:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    47
	poolDictionaries:''
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    48
	category:'Languages-Java-Tests-RuntimeConstantPool'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    49
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    50
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    51
!JavaMethodRefTests class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    52
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    53
copyright
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    54
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    55
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    56
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    57
                            SWING Research Group, Czech Technical University in Prague
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    58
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    59
 Parts of the code written by Claus Gittinger are under following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    60
 license:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    61
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    62
 This software is furnished under a license and may be used
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    63
 only in accordance with the terms of that license and with the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    64
 inclusion of the above copyright notice.   This software may not
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    65
 be provided or otherwise made available to, or used by, any
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    66
 other person.  No title to or ownership of the software is
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    67
 hereby transferred.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    68
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    69
 Parts of the code written at SWING Reasearch Group [1] are MIT licensed:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    70
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    71
 Permission is hereby granted, free of charge, to any person
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    72
 obtaining a copy of this software and associated documentation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    73
 files (the 'Software'), to deal in the Software without
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    74
 restriction, including without limitation the rights to use,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    75
 copy, modify, merge, publish, distribute, sublicense, and/or sell
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    76
 copies of the Software, and to permit persons to whom the
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    77
 Software is furnished to do so, subject to the following
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    78
 conditions:
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    79
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    80
 The above copyright notice and this permission notice shall be
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    81
 included in all copies or substantial portions of the Software.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    82
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    83
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    84
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    85
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    86
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    87
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    88
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    89
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    90
 OTHER DEALINGS IN THE SOFTWARE.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    91
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    92
 [1] Code written at SWING Research Group contain a signature
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    93
     of one of the above copright owners.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    94
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    95
"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    96
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    97
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    98
!JavaMethodRefTests methodsFor:'permission tests'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    99
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   100
testAccessingPPFromOutside
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   101
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   102
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   103
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   104
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   105
        should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   106
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   107
                        getMethodRefNamed: 'packagePrivateMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   108
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   109
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   110
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   111
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   112
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   113
        suchThat: [:e | e messageText = 'IllegalAccessError' ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   114
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   115
    "Created: / 14-04-2011 / 15:10:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   116
    "Modified: / 23-05-2011 / 17:15:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   117
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   118
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   119
testAccessingPPFromSubclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   120
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   121
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   122
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   123
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   124
        shouldnt: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   125
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   126
                        getMethodRefNamed: 'packagePrivateMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   127
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   128
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   129
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   130
                owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   131
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   132
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   133
        .
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   134
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   135
    "Created: / 14-04-2011 / 15:10:55 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   136
    "Modified: / 23-05-2011 / 17:14:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   137
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   138
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   139
testAccessingPrivateFromOutside
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   140
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   141
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   142
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   143
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   144
        should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   145
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   146
                        getMethodRefNamed: 'privateMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   147
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   148
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   149
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   150
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   151
        suchThat: [:e | e messageText = 'IllegalAccessError' ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   152
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   153
    "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   154
    "Modified: / 23-05-2011 / 17:16:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   155
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   156
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   157
testAccessingPrivateFromOutsideInNonPublic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   158
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   159
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   160
    initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   161
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   162
        should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   163
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   164
                        getMethodRefNamed: 'privateMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   165
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   166
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   167
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   168
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   169
        suchThat: [:e | e messageText = 'IllegalAccessError' ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   170
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   171
    "Created: / 13-04-2011 / 14:47:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   172
    "Modified: / 23-05-2011 / 17:17:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   173
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   174
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   175
testAccessingPrivateFromSubclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   176
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   177
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   178
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   179
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   180
        should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   181
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   182
                        getMethodRefNamed: 'privateMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   183
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   184
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   185
                javaMethodRef owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   186
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   187
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   188
        suchThat: [:e | e messageText = 'IllegalAccessError' ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   189
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   190
    "Created: / 13-04-2011 / 14:49:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   191
    "Modified: / 23-05-2011 / 17:13:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   192
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   193
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   194
testAccessingProtectedFromOutside
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   195
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   196
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   197
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   198
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   199
        should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   200
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   201
                        getMethodRefNamed: 'protectedMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   202
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   203
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   204
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   205
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   206
        suchThat: [:e | e messageText = 'IllegalAccessError' ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   207
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   208
    "Created: / 13-04-2011 / 14:44:48 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   209
    "Modified: / 23-05-2011 / 17:12:44 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   210
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   211
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   212
testAccessingProtectedFromOutsideInNonPublic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   213
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   214
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   215
    initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   216
    self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   217
        should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   218
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   219
                        getMethodRefNamed: 'protectedMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   220
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   221
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   222
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   223
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   224
        raise: Error
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   225
        suchThat: [:e | e messageText = 'IllegalAccessError' ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   226
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   227
    "Created: / 13-04-2011 / 14:47:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   228
    "Modified: / 23-05-2011 / 17:12:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   229
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   230
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   231
testAccessingProtectedFromPackage
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   232
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   233
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   234
initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   235
    self shouldnt: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   236
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   237
                        getMethodRefNamed: 'publicMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   238
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   239
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   240
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   241
                owner: (Java classForName: 'stx.libjava.tests.mocks.Crate').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   242
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   243
        raise: Error.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   244
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   245
    "Created: / 14-04-2011 / 15:09:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   246
    "Modified: / 23-05-2011 / 17:11:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   247
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   248
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   249
testAccessingProtectedFromSubclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   250
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   251
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   252
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   253
    self shouldnt: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   254
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   255
                        getMethodRefNamed: 'protectedMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   256
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   257
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   258
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   259
                owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   260
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   261
        raise: Error.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   262
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   263
    "Created: / 13-04-2011 / 14:49:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   264
    "Modified: / 23-05-2011 / 17:11:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   265
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   266
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   267
testAccessingPublicFromOutside
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   268
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   269
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   270
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   271
    self shouldnt: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   272
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   273
                        getMethodRefNamed: 'publicMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   274
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   275
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   276
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   277
                owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   278
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   279
        raise: Error.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   280
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   281
    "Created: / 13-04-2011 / 14:44:31 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   282
    "Modified: / 23-05-2011 / 17:10:40 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   283
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   284
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   285
testAccessingPublicFromOutsideInNonPublic
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   286
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   287
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   288
    initString := 'Lstx/libjava/tests/mocks/NonPublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   289
    self shouldnt: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   290
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   291
                        getMethodRefNamed: 'publicMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   292
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   293
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   294
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   295
                owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   296
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   297
        raise: Error.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   298
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   299
    "Created: / 13-04-2011 / 14:48:05 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   300
    "Modified: / 23-05-2011 / 17:10:29 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   301
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   302
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   303
testAccessingPublicFromSubclass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   304
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   305
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   306
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   307
    self shouldnt: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   308
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   309
                        getMethodRefNamed: 'publicMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   310
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   311
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   312
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   313
                owner: (Java classForName: 'stx.libjava.tests.mocks.SubclassOfPublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   314
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   315
        raise: Error.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   316
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   317
    "Created: / 13-04-2011 / 14:49:11 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   318
    "Modified: / 23-05-2011 / 17:10:14 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   319
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   320
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   321
testAccessingPublicInterfaceFromOutside
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   322
    | javaMethodRef  initString |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   323
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   324
    initString := 'Lstx/libjava/tests/mocks/PublicInterface;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   325
    self should: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   326
            [ javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   327
                        getMethodRefNamed: 'publicMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   328
                        typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   329
                        inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   330
            javaMethodRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   331
                owner: (Java classForName: 'stx.libjava.tests.mocks.PublicClass').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   332
            javaMethodRef resolve. ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   333
        raise: Error suchThat: [:e | e messageText = 'IncompatibleClassChangeError'].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   334
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   335
    "Created: / 23-05-2011 / 17:54:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   336
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   337
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   338
!JavaMethodRefTests methodsFor:'resolving static tests'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   339
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   340
testCorrectStaticResolving
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   341
    | initString  javaMethodRef  expectedResult  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   342
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   343
    initString := 'Lstx/libjava/tests/mocks/PublicClass;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   344
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   345
    javaMethodRef :=  self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   346
                getMethodRefNamed: 'publicStaticMethod'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   347
                typed: '()Ljava/lang/String;'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   348
                inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   349
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   350
    result := javaMethodRef resolveStatic.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   351
    expectedResult := (Java 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   352
                classForName: 'stx.libjava.tests.mocks.PublicClass') methodDictionary 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   353
                at: #'publicStaticMethod()Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   354
    self assertTrue: (result = expectedResult).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   355
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   356
    "Created: / 28-04-2011 / 22:46:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   357
    "Modified: / 23-05-2011 / 17:08:18 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   358
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   359
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   360
!JavaMethodRefTests methodsFor:'resolving tests'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   361
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   362
testCorrectInstanceCreation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   363
    | initString  javaMethodRef |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   364
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   365
    initString := 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   366
    javaMethodRef := self getMethodRefNamed: '<init>' typed: '()V' inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   367
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   368
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   369
    self assertTrue: (javaMethodRef valueCache isNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   370
    self assertTrue: (javaMethodRef name = '<init>').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   371
    self assertTrue: (javaMethodRef descriptor = '()V').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   372
    self assertTrue: (javaMethodRef classRef name = 'Ljava/lang/String;').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   373
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   374
    "Created: / 08-04-2011 / 14:01:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   375
    "Modified: / 23-05-2011 / 17:03:10 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   376
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   377
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   378
testCorrectResolving
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   379
    | initString  javaMethodRef  expectedResult  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   380
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   381
    initString := 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   382
    javaMethodRef :=  self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   383
                getMethodRefNamed: '<init>'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   384
                typed: '()V'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   385
                inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   386
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   387
    result := javaMethodRef resolve.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   388
    expectedResult := (Java classForName: 'java.lang.String') methodDictionary 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   389
                at: #'<init>()V'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   390
    self assertTrue: (result = expectedResult).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   391
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   392
    "Created: / 08-04-2011 / 14:07:57 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   393
    "Modified: / 23-05-2011 / 17:06:23 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   394
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   395
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   396
testInvalidation
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   397
    | javaMethodRef  initString|
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   398
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   399
    initString := 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   400
     javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   401
                getMethodRefNamed: '<init>'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   402
                typed: '()V'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   403
                inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   404
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   405
    javaMethodRef resolve.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   406
    self assertTrue: (javaMethodRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   407
    self assertTrue: (javaMethodRef classRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   408
    javaMethodRef invalidate.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   409
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   410
    self assertTrue: (javaMethodRef classRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   411
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   412
    "Created: / 08-04-2011 / 14:09:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   413
    "Modified: / 23-05-2011 / 17:06:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   414
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   415
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   416
testInvalidationForClassNegative
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   417
    | javaMethodRef  initString|
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   418
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   419
    initString := 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   420
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   421
    javaMethodRef :=  self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   422
                getMethodRefNamed: '<init>'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   423
                typed: '()V'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   424
                inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   425
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   426
    javaMethodRef resolve.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   427
    self assertTrue: (javaMethodRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   428
    javaMethodRef invalidateForClass: 'Ljava/lang/Object;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   429
    self assertTrue: (javaMethodRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   430
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   431
    "Created: / 08-04-2011 / 16:23:06 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   432
    "Modified: / 23-05-2011 / 17:07:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   433
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   434
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   435
testInvalidationForClassPositive
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   436
    | javaMethodRef  initString|
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   437
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   438
    initString := 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   439
    javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   440
                getMethodRefNamed: '<init>'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   441
                typed: '()V'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   442
                inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   443
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   444
    javaMethodRef resolve.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   445
    self assertTrue: (javaMethodRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   446
    javaMethodRef invalidateForClass: 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   447
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   448
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   449
    "Created: / 08-04-2011 / 16:23:19 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   450
    "Modified: / 23-05-2011 / 17:07:46 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   451
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   452
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   453
testResolving
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   454
    | initString javaMethodRef |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   455
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   456
    initString := 'Ljava/lang/String;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   457
    javaMethodRef := self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   458
                getMethodRefNamed: '<init>'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   459
                typed: '()V'
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   460
                inClass: initString.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   461
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   462
    self assertTrue: (javaMethodRef isResolved not).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   463
    javaMethodRef resolve.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   464
    self assertTrue: (javaMethodRef classRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   465
    self assertTrue: (javaMethodRef isResolved).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   466
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   467
    "Created: / 08-04-2011 / 14:04:01 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   468
    "Modified: / 23-05-2011 / 17:05:49 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   469
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   470
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   471
!JavaMethodRefTests class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   472
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   473
version_SVN
2152
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
   474
    ^ '$Id: JavaMethodRefTests.st,v 1.1 2011-08-18 19:06:53 vrany Exp $'
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
   475
! !