Hi,


It's been a ... Long couple of months.
I wanted to find the time to contribute the few tests I have, but was not able to find time to do so.
I join them to this email (lamely) as .st. They are available on my github fork, in the SlangTranslation branch aswell: git@github.com:hogoww/OpenSmalltalk-VM.

I had to move on from them quite quickly so some stuff is very basic, but this is still a start.
I tagged with self assert: false the tests results I thought were weird, with a comment of what I expected.

I was not able to look at what you pointed me to, sorry Eliot.

Hope this will help, have a nice day !


Pierre


On 18/12/2019 09:25, Eliot Miranda wrote:
 

Hi Pierre,

On Tue, Dec 17, 2019 at 10:36 PM pierre misse <pierre_misse25@msn.com> wrote:
 


On 18/12/2019 03:52, Eliot Miranda wrote:
 

Hi Pierre,

On Tue, Dec 17, 2019 at 9:50 AM pierre misse <pierre_misse25@msn.com> wrote:
 

Hi,

I saw my previous mistake, and corrected this.
This is a sample test, for a very simple inference.

testReturnFloatConstantNode
    | ccg tMethod |
    ccg := CCodeGenerator new.
    ccg addClass: SlangTypeInferenceTestsClass.
    ccg inferTypesForImplicitlyTypedVariablesAndMethods.
    tMethod := ccg methodNamed: #returnAFloatConstantNode.
   
    self assert: tMethod isNotNil.
    self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #double.
    self assert: tMethod returnType equals: #double


 And perhaps have SlangTypeInferenceTestsClass inherit from StackInterpreter or InterpreterPrimitives.  That will give you much more context.

I was currently inheriting from interpreterPlugin, but I can indeed switch.


I think you have it right.   interpreterPlugin should be fine.

My tests currently were as simple as it gets:

constantNode
Returm constant
return Explicit argument
return Explicit Temporary
return temp assigned by constant.

So it wasn't necessary.

Only surprising result is the return temp assigned by constant, which loses the type. This seems to be easily improvable in the future if you'd like.

returnTempFloatConstantNode
    | t |
    t := 1.0.
    ^ t

Its its return type isn't inferred to be #double then that's a bug.

testReturnTempFloatConstantNode
    | ccg tMethod |
    ccg := CCodeGenerator new.
    ccg addClass: SlangTypeInferenceTestsClass.
    ccg inferTypesForImplicitlyTypedVariablesAndMethods.
    tMethod := ccg methodNamed: #returnTempFloatConstantNode.
   
    self assert: tMethod isNotNil.
    self assert: (ccg typeFor: tMethod statements first in: tMethod) equals: #double.
    self assert: (ccg typeFor: tMethod statements first variable in: tMethod) equals: #sqInt.
    self assert: tMethod returnType equals: #sqInt.


 Well, t is untyped and it is assigned a double.  So I would expect that the inferencer infer the ty[e #double for f.  Then it should infer the type #double for  returnTempFloatConstantNode since it answers t.    
 

    self error "wait what"



 I need to work on ones with ambiguity.


 The instability I saw was in getErrorObjectFromPrimFailCode; its two locals clone & errObj are sometimes typed as squint and sometimes as usqInt.  Some times numPointerSlotsOf ends up with a return type of usqInt, some times as sqInt.  I've recently had success in another project substituting OrderedDictionary et al for Dictionary.  So I'm sure that solutions can be found easily.
 

Thanks for the pointer !


Pierre


Thanks for looking!!  It will be great to have tests for this, if only for good documentation.  I never had the time, and always look at the diffs of the generated code.  But that doesn't mean I don't want these tests.  Thank you for your energy!
 
_,,,^..^,,,_
best, Eliot