I wrote this property
prop_lookupsymbol = forAll $ \name table scope -> case lookupsymbol name table scope of
Just (s,_) -> property $ is_ancestor s scope
Nothing -> forAll $ \s->is_ancestor s ==> (lookupsymbol name table s) == Nothing
and ran it with smallCheck 3 prop_lookupsymbol
, the results are :
Completed 9000 tests without failure.
But 9000 did not meet ==> condition.
I know it refers to ==>
call in the property but what does it mean by did not meet
? Should I worry about this ? and if yes then how do I get the tests that didn't meet the condition ?
Edit
I had a mistake where is_ancestor
was lacking a second parameter, so the property is this now :
prop_lookupsymbol = forAll $ \name table scope -> case lookupsymbol name table scope of
Just (s,_) -> property $ is_ancestor s scope
Nothing -> forAll $ \s->is_ancestor s scope ==> (lookupsymbol name table s) == Nothing
But from 9000 there are 8340 which didn't meet the condition.
Here is explanation of the types and functions above :
SymbolTable
is a type synonym for HashMap (Scope,String) Symbol
(HashMap.Strict
from unordered-containers package), this is simply for building a compiler :).
Symbol has variety of constructors(variable,function,type,etc) and Scope
defines in what scope the symbol is defined, we have file,class,function,method(function in class),interface.
Scope has name(file name, class name , etc) and upper scope, for a class it also has the parent scope(parent as in inheritance) and a list of interfaces scopes(which the class implements), the interface scope has a parent scope along with its upper scope.
The function is_ancestor s1 s2
returns whether s1 is an upperscope of s2 (or upper-upperscope or upper-upper-upper...) or is a parent scope(or parent-parent or parent-parent-...) or one of the interfaces(or the parent's interfaces or etc), I should mention that is_ancestor s s
is always true.
Finally lookupsymbol name table scope
tries to find a symbol whose name is name
and scope is s
where is_ancestor s scope
is true, its return type is Maybe (Scope,Symbol)
meaning that it returns the found symbol along with the scope the symbol is defined in(and Nothing when nothing is found).
My property states this : for any name table scope, if lookupsymbol returns Just (s,_)
then s
must be is_ancestor
of scope
, but if it returns nothing then it will return nothing for any scope that is_ancestor
of scope
.