tools/JavaCompilerTests.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 24 Jul 2014 21:18:20 +0100
changeset 3173 26dd7e06c4bb
parent 2986 6b521f99c43b
child 3330 b14c58b2876c
permissions -rw-r--r--
Removed classFileBytes from JavaClass. They are no longer needed once we have ReflectiveType machinery.
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
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
TestCase subclass:#JavaCompilerTests
3173
26dd7e06c4bb Removed classFileBytes from JavaClass.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2986
diff changeset
    30
	instanceVariableNames:'classloader'
2986
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    31
	classVariableNames:''
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
	poolDictionaries:''
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
	category:'Languages-Java-Tests-Compiling'
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
!JavaCompilerTests class methodsFor:'documentation'!
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
copyright
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 (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
    41
                         SWING Research Group, Czech Technical University 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
                         in Prague
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
 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
    45
 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
    46
 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
    47
 restriction, including without limitation the rights to use,
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
 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
    49
 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
    50
 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
    51
 conditions:
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
 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
    54
 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
    55
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
 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
    57
 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
    58
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
 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
    60
 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
    61
 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
    62
 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
    63
 OTHER DEALINGS IN THE SOFTWARE.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    64
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    65
"
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
history
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
    "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
    71
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    72
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
!JavaCompilerTests class methodsFor:'accessing'!
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
resources
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
    ^ Array with: JavaInitializedResource
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    "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
    79
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
!JavaCompilerTests methodsFor:'helpers'!
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
registerFooBarSuperclass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
package stx.libjava;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
class FooBar {    
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
}
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
    compiledClasses := JavaCompiler compile: sourceCode.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    compiledClasses isNil ifTrue: [
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
        self 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    94
            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
    95
    ].
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
    JavaVM registry registerClasses: compiledClasses.
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
    "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
    99
    "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
   100
    "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
   101
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   102
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   103
registerPackageVisibleClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   104
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   105
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   106
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   107
class PackageVisibleClass {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   108
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   109
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   110
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   111
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   112
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
    compiledClasses := JavaCompiler compile: sourceCode.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   116
    compiledClasses isNil ifTrue: [
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   117
        self 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   118
            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
   119
    ].
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   120
    JavaVM registry registerClasses: compiledClasses.
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
    "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
   123
    "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
   124
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
!JavaCompilerTests methodsFor:'tests'!
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
testCompilingFromComplexStringWithComplexAssertions
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   129
    | sourceCode  compiledClass |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   130
    self registerPackageVisibleClass.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   133
import org.junit.Test;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   134
import static java.lang.String.*;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   135
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   136
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   137
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
        return new PackageVisibleClass().foo();
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   140
}
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
    compiledClass := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   143
    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
   144
    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
   145
    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
   146
    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
   147
    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
   148
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   149
    "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
   150
    "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
   151
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   152
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   153
testCompilingFromString
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   154
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   155
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   156
public class Foo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   157
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   158
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   159
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   160
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   161
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
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   165
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   166
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   167
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   168
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   169
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   170
    "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
   171
    "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
   172
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   173
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   174
testCompilingFromStringWithImports
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   175
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   176
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   177
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   178
import org.junit.Test;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   179
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   180
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   181
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   182
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   183
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   184
}
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
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   187
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   188
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   189
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   190
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   191
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   192
    "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
   193
    "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
   194
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   195
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   196
testCompilingFromStringWithPackage
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   197
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   198
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   199
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   200
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   201
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   202
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   203
        return 42;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   204
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
}
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
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   213
    "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
   214
    "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
   215
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   216
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
testCompilingFromStringWithPackageDependencies
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   219
    self registerPackageVisibleClass.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   220
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
package stx.libjava.tests;
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   222
public class Wohoo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   223
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   224
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   225
        return new PackageVisibleClass().foo();
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   226
    }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   227
}
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
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   230
    self assert: compiledClasses notNil
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   231
        message: 'compiler should return compiled class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   232
    self assert: compiledClasses isJavaClass
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   233
        message: 'compiler should return java class'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   234
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   235
    "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
   236
    "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
   237
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   238
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   239
testCompilingSyntacticallyIncorrectCode_01
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   240
    | sourceCode  compiledClasses |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
    sourceCode := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   242
    public class Foo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
    public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   245
        return 
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   246
'.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
    compiledClasses := (JavaCompiler compile: sourceCode) anElement.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   248
    "ECJ can compile even this..."
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
    self assert: compiledClasses notEmptyOrNil.
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   251
    "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
   252
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   253
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   254
!JavaCompilerTests methodsFor:'tests - incomplete / invalid code'!
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
test_invalid_01
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   257
    | source inst |
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   258
    source := '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   259
    public class Foo {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   260
        public int foo() {
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   261
            return "XXXX";
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   262
        }
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   263
    }
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
    JavaCompiler compile: source register: true notifying: nil.
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
    inst := JAVA Foo new.
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
    self should: [ inst foo ] raise: JavaUnresolvedCompilationError
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
    "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
   272
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   273
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   274
!JavaCompilerTests class methodsFor:'documentation'!
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
version_CVS
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   277
    ^ '$Header: /cvs/stx/stx/libjava/experiments/JavaCompilerTests.st,v 1.3 2013-09-06 00:44:04 vrany Exp $'
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   278
!
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
version_HG
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
    ^ '$Changeset: <not expanded> $'
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
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   285
version_SVN
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   286
    ^ 'Id::                                                                                                                        '
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   287
! !
6b521f99c43b Moved JavaCompilerTests to stx:libtool.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   288