CodeGeneratorTests.st
author Claus Gittinger <cg@exept.de>
Fri, 01 Jul 2011 15:37:31 +0200
changeset 10012 b9d3ade2b5bc
child 10046 5ab125878ab0
permissions -rw-r--r--
initial checkin

"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
"{ Package: 'stx:libtool' }"

TestCase subclass:#CodeGeneratorTests
	instanceVariableNames:'cg'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Browsers'
!

!CodeGeneratorTests class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!CodeGeneratorTests methodsFor:'initialization & release'!

setUp

    cg := CodeGenerator new

    "Created: / 07-07-2009 / 09:26:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

tearDown

    | mocks |
    mocks := Set new.
    self class selectorsDo:
        [:selector| 
        (selector startsWith: 'mock')
            ifTrue:[mocks add: selector]].
    mocks do:
        [:selector|
        self class removeSelector: selector].

    "Modified: / 07-07-2009 / 09:34:22 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CodeGeneratorTests methodsFor:'mocks - do not remove'!

mmock_03

    ^3

    "Created: / 07-07-2009 / 19:21:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

mmock_03: x

    ^x

    "Created: / 07-07-2009 / 19:55:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CodeGeneratorTests methodsFor:'tests'!

test_01

    cg
        class: self class;
        replace: '`@e' with: '1';
        source: 'mock_01 ^ `@e';
        compile.

    self assert: (self respondsTo: #mock_01).
    self assert: (self mock_01 = 1).

    "Created: / 07-07-2009 / 09:29:56 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

test_02

    cg
        class: self class;
        replace: '`@selector' with: #mock_02;
        source: '`@selector ^ 2';
        compile.

    self assert: (self respondsTo: #mock_02).
    self assert: (self mock_02 = 2).

    "Created: / 07-07-2009 / 19:07:13 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

test_02b

    cg
        class: self class;
        replace: '`@selector:' with: #mock_02:;
        source: '`@selector: arg ^ arg';
        compile.

    self assert: (self respondsTo: #mock_02:).
    self assert: (self mock_02: 20) = 20.

    "Created: / 07-07-2009 / 19:54:03 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

test_03

    cg
        class: self class;
        replace: '`@selector' with: 'mmock_03';
        source: 'mock_03 ^ self `@selector';
        compile.

    self assert: (self respondsTo: #mock_03).
    self assert: (self mock_03 = 3).

    "Created: / 07-07-2009 / 19:22:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

test_03b

    cg
        class: self class;
        replace: '`@selector:' with: #mmock_03:;
        source: 'mock_03b ^ self `@selector: 30';
        compile.

    self assert: (self respondsTo: #mock_03b).
    self assert: (self mock_03b = 30).

    "Created: / 07-07-2009 / 19:54:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!CodeGeneratorTests class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libtool/CodeGeneratorTests.st,v 1.1 2011-07-01 13:37:31 cg Exp $'
!

version_SVN
    ^ '§Id: CodeGeneratorTests.st 7728 2011-05-05 23:02:13Z vranyj1 §'
! !