JavaClassReader2Tests.st
author Claus Gittinger <cg@exept.de>
Thu, 24 Nov 2011 12:54:59 +0100
changeset 2305 c11e70f81f74
parent 2152 1cbdfbcc685c
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:#JavaClassReader2Tests
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
!JavaClassReader2Tests 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
!JavaClassReader2Tests methodsFor:'tests'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
    99
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   100
_testJavaInitializationWithNewReader
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   101
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   102
    "Disabled by default, since it flushes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   103
     Java causing hudson test runner to fail
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   104
     (proxy testcases are already loaded)"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   105
    
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   106
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   107
    self assert: false.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   108
    JavaClassReader useNewClassReader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   109
    Java flushAllJavaResources.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   110
    Java initialize.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   111
    JavaVM initializeVM.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   112
    JavaClassReader useOldClassReader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   113
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   114
    "Modified: / 12-05-2011 / 18:21:32 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   115
    "Created: / 01-06-2011 / 21:48:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   116
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   117
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   118
_testJavaInitializationWithOldReader
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   119
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   120
    "Disabled by default, since it flushes
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   121
     Java causing hudson test runner to fail
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   122
     (proxy testcases are already loaded)"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   123
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   124
    JavaClassReader useOldClassReader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   125
    Java flushAllJavaResources.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   126
    Java initialize.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   127
    JavaVM initializeVM.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   128
    JavaClassReader useOldClassReader.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   129
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   130
    "Created: / 01-06-2011 / 21:47:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   131
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   132
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   133
testReadingClass
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   134
    | reader  constantPool  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   135
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   136
    reader := JavaClassReader new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   137
    constantPool := JavaConstantPool new: 1.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   138
    constantPool at: 1 put: 'Ljava/lang/Object;'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   139
    reader constants: constantPool.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   140
    reader stream: (ReadStream on: #( 1 0 )).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   141
    result := reader readConstant_Class.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   142
    self assertTrue: (result notNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   143
    self assertTrue: (result isJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   144
    self assertTrue: (result isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   145
    self assertTrue: (result name = 'Ljava/lang/Object;').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   146
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   147
    "Created: / 10-05-2011 / 13:52:35 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   148
    "Modified: / 08-08-2011 / 17:25:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   149
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   150
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   151
testReadingField
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   152
    | reader  constantPool  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   153
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   154
    reader := JavaClassReader new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   155
    constantPool := JavaConstantPool new: 5.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   156
    constantPool at: 1 put: 'class'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   157
    constantPool at: 2 put: (self getClassRefIn: constantPool withNameAt: 1).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   158
    constantPool at: 3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   159
        put: (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   160
                getNameAndTypeIn: constantPool
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   161
                withNameAt: 4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   162
                andTypeAt: 5).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   163
    constantPool at: 4 put: 'name'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   164
    constantPool at: 5 put: 'type'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   165
    constantPool owner: self javaLangObject.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   166
    reader constants: constantPool.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   167
    reader stream: (ReadStream on: #( 2 0 3 0 )).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   168
    result := reader readConstant_Fieldref.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   169
    self assertTrue: (result notNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   170
    self assertTrue: (result isJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   171
    self assertTrue: (result isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   172
    self assertTrue: (result classRef isJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   173
    self assertTrue: (result nameAndType isNewJavaNameAndType).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   174
    self assertTrue: (result nameAndType name = 'name').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   175
    self assertTrue: (result nameAndType descriptor = 'type').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   176
    self assertTrue: (result owner = self javaLangObject).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   177
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   178
    "Created: / 10-05-2011 / 14:12:07 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   179
    "Modified: / 23-05-2011 / 18:00:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   180
    "Modified: / 08-08-2011 / 17:25:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   181
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   182
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   183
testReadingInterfaceMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   184
    | reader  constantPool  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   185
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   186
    reader := JavaClassReader new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   187
    constantPool := JavaConstantPool new: 5.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   188
    constantPool at: 1 put: 'class'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   189
    constantPool at: 2 put: (self getClassRefIn: constantPool withNameAt: 1).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   190
    constantPool at: 3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   191
        put: (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   192
                getNameAndTypeIn: constantPool
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   193
                withNameAt: 4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   194
                andTypeAt: 5).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   195
    constantPool at: 4 put: 'name'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   196
    constantPool at: 5 put: 'type'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   197
    constantPool owner: self javaLangObject.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   198
    reader constants: constantPool.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   199
    reader stream: (ReadStream on: #( 2 0 3 0 )).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   200
    result := reader readConstant_InterfaceMethodref.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   201
    self assertTrue: (result notNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   202
    self assertTrue: (result isJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   203
    self assertTrue: (result isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   204
    self assertTrue: (result classRef isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   205
    self assertTrue: (result classRef isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   206
    self assertTrue: (result nameAndType isNewJavaNameAndType).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   207
    self assertTrue: (result nameAndType name = 'name').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   208
    self assertTrue: (result nameAndType descriptor = 'type').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   209
    self assertTrue: (result owner = self javaLangObject).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   210
    self assertTrue: (result owner = self javaLangObject).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   211
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   212
    "Created: / 10-05-2011 / 14:12:21 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   213
    "Modified: / 23-05-2011 / 18:00:28 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   214
    "Modified: / 08-08-2011 / 17:25:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   215
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   216
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   217
testReadingMethod
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   218
    | reader  constantPool  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   219
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   220
    reader := JavaClassReader new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   221
    constantPool := JavaConstantPool new: 5.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   222
    constantPool at: 1 put: 'class'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   223
    constantPool at: 2 put: (self getClassRefIn: constantPool withNameAt: 1).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   224
    constantPool at: 3
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   225
        put: (self 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   226
                getNameAndTypeIn: constantPool
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   227
                withNameAt: 4
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   228
                andTypeAt: 5).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   229
    constantPool at: 4 put: 'name'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   230
    constantPool at: 5 put: 'type'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   231
    constantPool owner: self javaLangObject.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   232
    reader constants: constantPool.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   233
    reader stream: (ReadStream on: #( 2 0 3 0 )).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   234
    result := reader readConstant_Methodref.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   235
    self assertTrue: (result notNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   236
    self assertTrue: (result isJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   237
    self assertTrue: (result isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   238
    self assertTrue: (result classRef isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   239
    self assertTrue: (result classRef isNewJavaRef).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   240
    self assertTrue: (result nameAndType isNewJavaNameAndType).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   241
    self assertTrue: (result nameAndType name = 'name').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   242
    self assertTrue: (result nameAndType descriptor = 'type').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   243
    self assertTrue: (result owner = self javaLangObject).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   244
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   245
    "Created: / 10-05-2011 / 14:10:25 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   246
    "Modified: / 23-05-2011 / 18:00:41 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   247
    "Modified: / 08-08-2011 / 17:25:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   248
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   249
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   250
testReadingNameAndType
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   251
    | reader  constantPool  result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   252
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   253
    reader := JavaClassReader new.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   254
    constantPool := JavaConstantPool new: 2.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   255
    constantPool at: 1 put: 'foo'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   256
    constantPool at: 2 put: 'bar'.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   257
    reader constants: constantPool.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   258
    reader stream: (ReadStream on: #( 1 0 2 0 )).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   259
    result := reader readConstant_NameAndType.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   260
    self assertTrue: (result notNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   261
    self assertTrue: (result isJavaNameAndType).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   262
    self assertTrue: (result isNewJavaNameAndType).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   263
    self assertTrue: (result name = 'foo').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   264
    self assertTrue: (result descriptor = 'bar').
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   265
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   266
    "Created: / 10-05-2011 / 13:56:37 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   267
    "Modified: / 08-08-2011 / 17:25:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   268
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   269
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   270
testReadingStream
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   271
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   272
    |result|    
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   273
    result := JavaClassReader readStream: self getCrateClassReadStream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   274
    self assertTrue: (result notNil).
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   275
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   276
    "Created: / 10-05-2011 / 12:16:43 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   277
    "Modified: / 08-08-2011 / 17:25:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   278
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   279
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   280
testWholeConstantPoolContainsFullyInitializedItems
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   281
    | result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   282
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   283
    result := JavaClassReader readStream: self getCrateClassReadStream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   284
    result constantPool do: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   285
            [:each | 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   286
            each isJavaRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   287
                ifTrue: [ self assertTrue: each isNewJavaRef. self assertTrue: each owner notNil. self assertTrue: each constantPool notNil.]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   288
                ifFalse: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   289
                    [ each isJavaNameAndType 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   290
                        ifTrue: [ self assertTrue: each isNewJavaNameAndType. self assertTrue: each owner notNil. self assertTrue: each constantPool notNil.] ] ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   291
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   292
    "Created: / 10-05-2011 / 17:01:12 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   293
!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   294
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   295
testWholeConstantPoolContainsOnlyNewRefs
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   296
    | result |
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   297
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   298
    result := JavaClassReader readStream: self getCrateClassReadStream.
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   299
    result constantPool do: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   300
            [:each | 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   301
            each isJavaRef 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   302
                ifTrue: [ self assertTrue: each isNewJavaRef ]
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   303
                ifFalse: 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   304
                    [ each isJavaNameAndType 
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   305
                        ifTrue: [ self assertTrue: each isNewJavaNameAndType ] ] ].
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   306
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   307
    "Created: / 10-05-2011 / 12:18:58 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   308
    "Modified: / 10-05-2011 / 16:59:15 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   309
! !
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   310
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   311
!JavaClassReader2Tests class methodsFor:'documentation'!
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   312
e898eaeff091 Synchronized with CVS repository at:
vranyj1
parents:
diff changeset
   313
version_SVN
2152
1cbdfbcc685c Jan's version
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 749
diff changeset
   314
    ^ '$Id: JavaClassReader2Tests.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
   315
! !