RegressionTests__BehaviorLookupObjectTests.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 1930 68ae0c911d46
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding

"{ Encoding: utf8 }"

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#BehaviorLookupObjectTests
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression'
!

Object subclass:#BadLookupClass
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:BehaviorLookupObjectTests
!

Object subclass:#ClassWithSpecialLookup
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:BehaviorLookupObjectTests
!

Object subclass:#LookupClass
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:BehaviorLookupObjectTests
!

Object subclass:#NilReturningLookupClass
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	privateIn:BehaviorLookupObjectTests
!


!BehaviorLookupObjectTests methodsFor:'helpers'!

returnConstant98765
    ^ 98765
! !

!BehaviorLookupObjectTests methodsFor:'tests'!

testLookupObject_01a
    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new x ] raise:MessageNotUnderstood.

    "/ at some time during the development, it crashed the second time,
    "/ due to a badly updated inlineCache
    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new x ] raise:MessageNotUnderstood.
!

testLookupObject_01b
    |firstException rslt|

    firstException := true.

    "/ catch it, and proceed without a method (leads to another dnu)...
    MessageNotUnderstood handle:[:ex |
        firstException ifTrue:[
            firstException := false.    
            self assert:(ex suspendedContext selector == #doesNotUnderstand:).
            self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
            self assert:(ex suspendedContext sender sender sender selector == #x).

            "/ here, we return a method...                              
            ex proceedWith:nil.
        ].
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender sender sender sender selector == #x).
        ex proceedWith:12345.
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new x
    ].

    self assert:(rslt = 12345).

    "Modified: / 11-05-2018 / 16:11:41 / stefan"
!

testLookupObject_01c
    |rslt|

    "/ catch it, and proceed with a method...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #x).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new x
    ].

    self assert:(rslt = 98765).

    "Modified: / 11-05-2018 / 16:14:52 / stefan"
!

testLookupObject_02
    "/ check lookupObject with 2.. arguments
    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new x:1234 ] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2 a3:3] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7] raise:MessageNotUnderstood.

    ClassWithSpecialLookup setLookupObject:BadLookupClass.
    self should:[ ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8] raise:MessageNotUnderstood.
!

testLookupObject_02c
    |rslt|

    "/ catch it, and proceed with a method...

    "/ 1 arg...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #x:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new x:1234
    ].
    self assert:(rslt = 98765).

    "/ 2 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2
    ].
    self assert:(rslt = 98765).

    "/ 3 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3
    ].
    self assert:(rslt = 98765).

    "/ 4 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4
    ].
    self assert:(rslt = 98765).

    "/ 5 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5
    ].
    self assert:(rslt = 98765).

    "/ 6 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6
    ].
    self assert:(rslt = 98765).

    "/ 7 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7
    ].
    self assert:(rslt = 98765).

    "/ 8 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8
    ].
    self assert:(rslt = 98765).

    "/ 9 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9
    ].
    self assert:(rslt = 98765).

    "/ 10 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:j:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10
    ].
    self assert:(rslt = 98765).

    "/ 11 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:j:k:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11
    ].
    self assert:(rslt = 98765).

    "/ 12 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12
    ].
    self assert:(rslt = 98765).

    "/ 13 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:m:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12 m:13
    ].
    self assert:(rslt = 98765).

    "/ 14 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:m:n:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12 m:13 n:14
    ].
    self assert:(rslt = 98765).

    "/ 15 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #lookupMethodForSelector:directedTo:for:withArguments:from:ilc:).
        self assert:(ex suspendedContext sender sender sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:).
        "/ here, we return a method...
        ex proceedWith:(self class compiledMethodAt:#returnConstant98765).
    ] do:[
        ClassWithSpecialLookup setLookupObject:BadLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12 m:13 n:14 o:15
    ].
    self assert:(rslt = 98765).

    "Modified: / 11-05-2018 / 16:22:27 / stefan"
!

testLookupObject_02d
    |rslt|

    "/ lookup returns nil (for dnu); catch it, and proceed with a value...

    "/ 1 arg...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #x:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new x:1234
    ].
    self assert:(rslt = 6666).

    "/ 2 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2
    ].
    self assert:(rslt = 6666).

    "/ 3 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3
    ].
    self assert:(rslt = 6666).

    "/ 4 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4
    ].
    self assert:(rslt = 6666).

    "/ 5 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5
    ].
    self assert:(rslt = 6666).

    "/ 6 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6
    ].
    self assert:(rslt = 6666).

    "/ 7 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7
    ].
    self assert:(rslt = 6666).

    "/ 8 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8
    ].
    self assert:(rslt = 6666).

    "/ 9 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9
    ].
    self assert:(rslt = 6666).

    "/ 10 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:j:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10
    ].
    self assert:(rslt = 6666).

    "/ 11 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:j:k:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11
    ].
    self assert:(rslt = 6666).

    "/ 12 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12
    ].
    self assert:(rslt = 6666).

    "/ 13 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:m:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12 m:13
    ].
    self assert:(rslt = 6666).

    "/ 14 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:m:n:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12 m:13 n:14
    ].
    self assert:(rslt = 6666).

    "/ 15 args...
    MessageNotUnderstood handle:[:ex |
        self assert:(ex suspendedContext selector == #doesNotUnderstand:).
        self assert:(ex suspendedContext sender selector == #a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:).
        "/ here, we return a value...
        ex proceedWith:6666.
    ] do:[
        ClassWithSpecialLookup setLookupObject:NilReturningLookupClass.
        ObjectMemory flushInlineCaches.
        rslt := ClassWithSpecialLookup new a:1 b:2 c:3 d:4 e:5 f:6 g:7 h:8 i:9 j:10 k:11 l:12 m:13 n:14 o:15
    ].
    self assert:(rslt = 6666).
!

testLookupObject_03
    "/ check good lookupObject with 0.. arguments
    ClassWithSpecialLookup setLookupObject:LookupClass.
    self assert:( ClassWithSpecialLookup new x ) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self assert:( ClassWithSpecialLookup new x:1234 ) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9 a10:10) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9 a10:10 a11:11) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9 a10:10 a11:11 a12:12) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9 a10:10 a11:11 a12:12 a13:13) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9 a10:10 a11:11 a12:12 a13:13 a14:14) = 12345.

    ClassWithSpecialLookup setLookupObject:LookupClass.
    self should:( ClassWithSpecialLookup new a1:1 a2:2 a3:3 a4:4 a5:5 a6:6 a7:7 a8:8 a9:9 a10:10 a11:11 a12:12 a13:13 a14:14 a15:15) = 12345.
! !

!BehaviorLookupObjectTests::LookupClass class methodsFor:'lookup'!

lookupMethodForSelector:aSelector directedTo:searchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
    ^ self compiledMethodAt:#returnConstant12345
!

lookupMethodForSelector:aSelector directedTo:searchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilc
    ^ self compiledMethodAt:#returnConstant12345

    "Created: / 04-09-2013 / 19:25:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BehaviorLookupObjectTests::LookupClass methodsFor:'trap methods'!

returnConstant12345
    ^ 12345
! !

!BehaviorLookupObjectTests::NilReturningLookupClass class methodsFor:'lookup'!

lookupMethodForSelector:aSelector directedTo:searchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext
    ^ nil
!

lookupMethodForSelector:aSelector directedTo:searchClass for:aReceiver withArguments:argArrayOrNil from:sendingContext ilc: ilc
    ^ nil

    "Created: / 04-09-2013 / 19:26:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!BehaviorLookupObjectTests class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !