RegressionTests__CompilerTests2.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 12 Feb 2013 17:26:24 +0100
changeset 784 b59c0cad82d6
child 823 452346d978c6
permissions -rw-r--r--
initial checkin

"{ Package: 'exept:regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#CompilerTests2
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'System-Compiler'
!


!CompilerTests2 methodsFor:'setup'!

tearDown

    (Smalltalk at: #'exept_regression_testData_CompilerTests2') notNil ifTrue:[
        (Smalltalk at: #'exept_regression_testData_CompilerTests2') classes do:[:e|
            e notNil ifTrue:[
                Smalltalk removeClass: e
            ].
        ]
    ].

    "Created: / 26-10-2012 / 11:32:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 12-02-2013 / 16:12:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CompilerTests2 methodsFor:'tests'!

test_01
    "JV@2012-10-26: 

     When a package is loaded from source using 

        Smalltalk loadPackage:'...'

     expression __EVALUATED FROM WORKSPACE__ AND a method from loaded class 
     uses a class from the same package that is not yet loaded (i.e., it will 
     be loaded later), 

     then the compiler as of 2012-10-26 generates access to a workspace variable 
     instead of access to a global

     This tests checks for this bug
    "

    | ws |

    "/First, make sure that package is not yet loaded...
    self 
        assert: (Smalltalk at: #'exept_regression_testData_CompilerTests2') isNil
        description: 'Mock package already loaded'.

    ws := WorkspaceApplication new.
    ws selectedWorkspace contents: '(Smalltalk loadPackage: #''exept:regression/testData/CompilerTests2'')'.
    ws selectedWorkspace selectAll.
    ws selectedWorkspace doIt.

    self assert: (Smalltalk at: #'RegressionTests::CompilerTests2Mock1') new foo class 
                    == (Smalltalk at: #'RegressionTests::CompilerTests2Mock2')

    "Created: / 26-10-2012 / 11:59:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 12-02-2013 / 16:24:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

test_02
    "JV@2012-10-26: 

     When a package is loaded from source using 

        Smalltalk loadPackage:'...'

     expression and a method from loaded class in namespace uses a class from the 
     same package and same namespace, that is not yet loaded (i.e., it will be loaded 
     later), 

     then the compiler as of 2012-10-26 generates access to class in no namespace.

     This test checks for this bug
    "

    "/First, make sure that package is not yet loaded...
    self 
        assert: (Smalltalk at: #'exept_regression_estData_CompilerTests2') isNil
        description: 'Mock package already loaded'.

    self 
        assert: (Smalltalk loadPackage: #'exept:regression/testData/CompilerTests2')
        description: 'Cannot load mock package!!'.


    self assert: (Smalltalk at: #'RegressionTests::CompilerTests2Mock1') new foo class 
                    == (Smalltalk at: #'RegressionTests::CompilerTests2Mock2')

    "Created: / 26-10-2012 / 12:26:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified (comment): / 12-02-2013 / 16:24:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!CompilerTests2 class methodsFor:'documentation'!

version
    ^ '$Header$'
!

version_CVS
    ^ '$Header$'
!

version_SVN
    ^ '§Id:: RegressionTests__CompilerTests2.st 506 2012-10-26 12:03:11Z vranyj1                                                    §'
! !