src/JavaRuntimeConstantPoolTests.st
author vranyj1
Wed, 23 Nov 2011 15:26:06 +0000
branchjk_new_structure
changeset 1152 040cba55a7d2
parent 877 f5a5b93e1c78
child 1155 d6f6d5fc0343
permissions -rw-r--r--
Copyright fixes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     1
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     2
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
     3
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
     4
 New code and modification done at SWING Research Group [1]:
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
     5
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     6
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     7
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     8
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
     9
 Parts of the code written by Claus Gittinger are under following
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    10
 license:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    11
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    12
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    13
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    14
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    15
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    16
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    17
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    18
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    19
 [1] Code written at SWING Research Group contain a signature
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    20
     of one of the above copright owners. For exact set of such code
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    21
     see the differences between this version and version stx:lib
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    22
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    23
"
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    24
"{ Package: 'stx:libjava' }"
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    25
773
ff7dbe5581a3 cleaned tests class hierarchy, small fixes
hlopkmar
parents: 771
diff changeset
    26
AbstractJavaTestCase subclass:#JavaRuntimeConstantPoolTests
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    27
	instanceVariableNames:'constantPoolCacheBackup'
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    28
	classVariableNames:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    29
	poolDictionaries:''
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    30
	category:'Languages-Java-Tests-RuntimeConstantPool'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    31
!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    32
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    33
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    34
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    35
copyright
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    36
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    37
 COPYRIGHT (c) 1996-2011 by Claus Gittinger
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    38
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    39
 New code and modification done at SWING Research Group [1]:
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    40
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    41
 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    42
                            SWING Research Group, Czech Technical University in Prague
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    43
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    44
 Parts of the code written by Claus Gittinger are under following
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    45
 license:
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    46
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    47
 This software is furnished under a license and may be used
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    48
 only in accordance with the terms of that license and with the
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    49
 inclusion of the above copyright notice.   This software may not
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    50
 be provided or otherwise made available to, or used by, any
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    51
 other person.  No title to or ownership of the software is
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    52
 hereby transferred.
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    53
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    54
 [1] Code written at SWING Research Group contain a signature
1152
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    55
     of one of the above copright owners. For exact set of such code
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    56
     see the differences between this version and version stx:lib
040cba55a7d2 Copyright fixes
vranyj1
parents: 877
diff changeset
    57
     as of 1.9.2010
877
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    58
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    59
"
f5a5b93e1c78 Cleanup phase 1
vranyj1
parents: 814
diff changeset
    60
! !
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
    61
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    62
!JavaRuntimeConstantPoolTests methodsFor:'helpers'!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    63
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    64
cleanUpCPCache
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    65
    "warning - counting with the fact that cp cache is backed up in setUp and restored in tearDown methods"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    66
    JavaConstantPool allConstantPools: OrderedCollection new.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    67
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    68
    "Created: / 13-05-2011 / 09:42:04 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    69
! !
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    70
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    71
!JavaRuntimeConstantPoolTests methodsFor:'running'!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    72
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    73
setUp
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    74
    super setUp.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    75
    constantPoolCacheBackup := JavaConstantPool allConstantPools.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    76
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    77
    "Created: / 13-05-2011 / 09:33:39 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    78
!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    79
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    80
tearDown
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    81
super tearDown.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    82
    JavaConstantPool allConstantPools: constantPoolCacheBackup.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    83
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    84
    "Created: / 13-05-2011 / 09:33:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    85
! !
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    86
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
    87
!JavaRuntimeConstantPoolTests methodsFor:'tests'!
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
    88
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    89
testConstantPoolCaching
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    90
    | newConstantPool |
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    91
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    92
    JavaConstantPool allConstantPools: OrderedCollection new.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    93
    newConstantPool := self getPrettyBigConstantPool.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    94
    self 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    95
        assertTrue: (JavaConstantPool allConstantPools includes: newConstantPool).
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    96
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    97
    "Created: / 13-05-2011 / 09:36:02 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    98
!
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
    99
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   100
testInvalidateAll
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   101
    | cp |
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   102
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   103
    cp := self getPrettyBigConstantPool.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   104
    cp do: [:each | each isJavaRef ifTrue: [each resolve]].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   105
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   106
             do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved) ] ].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   107
             cp invalidateAll.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   108
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   109
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   110
                 do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved not) ] ].
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   111
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   112
    "Created: / 08-04-2011 / 17:03:56 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   113
    "Modified: / 13-05-2011 / 09:48:30 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   114
!
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   115
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   116
testInvalidateForClass
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   117
    | cp |
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   118
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   119
    self cleanUpCPCache.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   120
    cp := self getPrettyBigConstantPool.
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 778
diff changeset
   121
778
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   122
    cp do: [:each | each isJavaRef ifTrue: [ each resolve ] ].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   123
    cp 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   124
        do: [:each | each isJavaRef ifTrue: [ self assertTrue: (each isResolved) ] ].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   125
    JavaConstantPool invalidateReferencesToClass: 'Ljava/lang/Runnable;'.
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   126
    1 to: 13
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   127
        do: 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   128
            [:index | 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   129
            (cp at: index) isJavaRef 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   130
                ifTrue: [ self assertTrue: (cp at: index) isResolved ] ].
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   131
    14 to: 20
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   132
        do: 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   133
            [:index | 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   134
            (cp at: index) isJavaRef 
caa3a009f617 refactoring tests and fixing related bugs, added functionality to constantPool
hlopkmar
parents: 777
diff changeset
   135
                ifTrue: [ self assertTrue: (cp at: index) isResolved not ] ].
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   136
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   137
    "Created: / 08-04-2011 / 17:10:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
814
68df82c46fb0 finally forced myself to refactor tests.. fieldRef tests are ok now.. methodRef to come..
hlopkmar
parents: 778
diff changeset
   138
    "Modified: / 23-05-2011 / 15:29:53 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
771
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   139
! !
fb8026dda011 Merged with /trunk
vranyj1
parents: 763
diff changeset
   140
752
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   141
!JavaRuntimeConstantPoolTests class methodsFor:'documentation'!
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   142
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   143
version_SVN
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   144
    ^ '$Id$'
ff7bc6428c9c branch jk_new_structure resurrected
vranyj1
parents:
diff changeset
   145
! !