tools/JavaCompilerTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 04 Feb 2019 00:24:10 +0000
changeset 3886 292b73957757
parent 3412 df11bb428463
permissions -rw-r--r--
Fix initialization of system propertirs ...and use `amd64` consistenly instead of `x86_64`.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2986
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
 Copyright (c) 2010-2011 Jan Vrany, Jan Kurs & Marcel Hlopko,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
                         SWING Research Group, Czech Technical University 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
                         in Prague
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
 Permission is hereby granted, free of charge, to any person
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
 obtaining a copy of this software and associated documentation
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
 files (the 'Software'), to deal in the Software without
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
 restriction, including without limitation the rights to use,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
 copy, modify, merge, publish, distribute, sublicense, and/or sell
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
 copies of the Software, and to permit persons to whom the
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
 Software is furnished to do so, subject to the following
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
 conditions:
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    14
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    15
 The above copyright notice and this permission notice shall be
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    16
 included in all copies or substantial portions of the Software.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    17
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    18
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    21
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    22
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    24
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    25
 OTHER DEALINGS IN THE SOFTWARE.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
"{ Package: 'stx:libjava/tools' }"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
3330
b14c58b2876c Oops, moved stray reloading-related methods from stx:libjava/experiments to stx:libjava.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3173
diff changeset
    29
"{ NameSpace: Smalltalk }"
b14c58b2876c Oops, moved stray reloading-related methods from stx:libjava/experiments to stx:libjava.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3173
diff changeset
    30
2986
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
TestCase subclass:#JavaCompilerTests
3173
26dd7e06c4bb Removed classFileBytes from JavaClass.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2986
diff changeset
    32
	instanceVariableNames:'classloader'
2986
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
	classVariableNames:''
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
	poolDictionaries:''
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
	category:'Languages-Java-Tests-Compiling'
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
!JavaCompilerTests class methodsFor:'documentation'!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
copyright
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
 Copyright (c) 2010-2011 Jan Vrany, Jan Kurs & Marcel Hlopko,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
                         SWING Research Group, Czech Technical University 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
                         in Prague
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
 Permission is hereby granted, free of charge, to any person
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
 obtaining a copy of this software and associated documentation
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
 files (the 'Software'), to deal in the Software without
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
 restriction, including without limitation the rights to use,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
 copy, modify, merge, publish, distribute, sublicense, and/or sell
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
 copies of the Software, and to permit persons to whom the
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
 Software is furnished to do so, subject to the following
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
 conditions:
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
 The above copyright notice and this permission notice shall be
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
 included in all copies or substantial portions of the Software.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
 OTHER DEALINGS IN THE SOFTWARE.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    66
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    67
"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    68
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    69
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
history
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
    "Created: #resources / 21-12-2012 / 18:24:51 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
!JavaCompilerTests class methodsFor:'accessing'!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
resources
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    ^ Array with: JavaInitializedResource
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
    "Created: / 02-01-2013 / 15:16:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
!JavaCompilerTests methodsFor:'helpers'!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
registerFooBarSuperclass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
package stx.libjava;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
class FooBar {    
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
    compiledClasses := JavaCompiler compile: sourceCode.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
    compiledClasses isNil ifTrue: [
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
        self 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
            error: 'these tests need PackageVisibleClass and aparently it could not be compiled'
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
    ].
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
    JavaVM registry registerClasses: compiledClasses.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
    "Created: / 09-12-2012 / 09:28:10 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
    "Modified: / 09-12-2012 / 20:35:03 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
    "Modified: / 02-01-2013 / 17:02:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
registerPackageVisibleClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
class PackageVisibleClass {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   113
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   114
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   115
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
    compiledClasses := JavaCompiler compile: sourceCode.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
    compiledClasses isNil ifTrue: [
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   119
        self 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
            error: 'these tests need PackageVisibleClass and aparently it could not be compiled'
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   121
    ].
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
    JavaVM registry registerClasses: compiledClasses.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   123
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
    "Created: / 08-12-2012 / 20:31:13 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
    "Modified: / 02-01-2013 / 17:02:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   127
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   128
!JavaCompilerTests methodsFor:'tests'!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
testCompilingFromComplexStringWithComplexAssertions
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
    | sourceCode  compiledClass |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
    self registerPackageVisibleClass.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
import org.junit.Test;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
import static java.lang.String.*;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
        return new PackageVisibleClass().foo();
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   142
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
    compiledClass := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
    self assert: compiledClass notNil message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
    self assert: compiledClass isJavaClass message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   147
    self assert: compiledClass javaName = 'stx.libjava.tests.Wohoo' message: 'class name is not correct'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   148
    self assert: compiledClass javaPackage = 'stx.libjava.tests' message: 'java package is not correct'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
    self assert: (compiledClass lookupMethodFor: #'foo()I') notNil message: 'compiled class should have the foo method'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   150
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   151
    "Created: / 16-12-2012 / 15:38:56 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
    "Modified: / 02-01-2013 / 16:33:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
testCompilingFromString
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
public class Foo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   162
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   163
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   164
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   171
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   172
    "Created: / 06-12-2012 / 22:59:42 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
    "Modified: / 02-01-2013 / 17:04:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
testCompilingFromStringWithImports
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
import org.junit.Test;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   185
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   186
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   193
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   194
    "Created: / 08-12-2012 / 20:29:05 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
    "Modified: / 02-01-2013 / 17:05:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
testCompilingFromStringWithPackage
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   207
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
    "Created: / 06-12-2012 / 23:30:54 / Marcel Hlopko <hlopkmar@fel.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
    "Modified: / 02-01-2013 / 17:05:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
testCompilingFromStringWithPackageDependencies
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
    self registerPackageVisibleClass.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   225
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
        return new PackageVisibleClass().foo();
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   228
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   229
}
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   233
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   236
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   237
    "Created: / 08-12-2012 / 20:30:05 / Marcel Hlopko <marcel.hlopko@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
    "Modified: / 02-01-2013 / 17:05:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
testCompilingSyntacticallyIncorrectCode_01
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   242
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
    public class Foo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
        return 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
    "ECJ can compile even this..."
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
    self assert: compiledClasses notEmptyOrNil.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   252
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
    "Created: / 15-04-2013 / 20:56:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   255
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   256
!JavaCompilerTests methodsFor:'tests - incomplete / invalid code'!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
test_invalid_01
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259
    | source inst |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   260
    source := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   261
    public class Foo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   262
        public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   263
            return "XXXX";
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   264
        }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   265
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   266
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   267
    JavaCompiler compile: source register: true notifying: nil.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   268
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   269
    inst := JAVA Foo new.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   270
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   271
    self should: [ inst foo ] raise: JavaUnresolvedCompilationError
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   272
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   273
    "Created: / 19-04-2013 / 09:55:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   274
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   275
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   276
!JavaCompilerTests class methodsFor:'documentation'!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   278
version_CVS
3412
df11bb428463 Merged with mercurial revision 4f3cc813be4 (8 changesets total)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3360
diff changeset
   279
    ^ '$Header: /cvs/stx/stx/libjava/tools/JavaCompilerTests.st,v 1.2 2015-03-20 13:29:52 vrany Exp $'
2986
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   281
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   282
version_HG
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   283
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   284
    ^ '$Changeset: <not expanded> $'
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   285
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   286
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   287
version_SVN
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   288
    ^ 'Id::                                                                                                                        '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   289
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   290