/*

CLASS {Testing|_calculations}, UNTESTED, BITWISE:

IMPORT: {Compiler}, {Generator}, {Type}, {Configuration}, {String_functions} ;

	    
CONST STR: KEY|_REGISTRY = "AL-IV" .

FUN Need_any_tests(
{Compiler} C|ompiler_this) ==> BOOL 
	:
	CASE "$ALLTESTS" IN C.Defined_name[] ?
         //DEBUG: "$ALLTESTEST setected --> Need_any_tests = TRUE"#NL ;
	     RESULT = TRUE ==> ;
	CASE "$NOTESTS" IN C.Defined_name[] ? RESULT = FALSE ==> ;
	FOR c IN C.All_classes[] :
		CASE Class_needs_testing(c) ?
             //DEBUG: "Class [" c.Names[0] "] needs testing!"#NL ;
		     RESULT = TRUE ==> ;
	; .
	
FUN Int|_from_string(
STR S|tring_containing_integer) ==> INT
	:
	FOR i IN [0 TO S.Len-1] :
	    CASE S.[i] ?
	    ["-"]: BOOL neg|ative_result = TRUE
	    ["_"]: NONE
	    ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]:
	    	RESULT = RESULT * 10 + S.[i].Ord - "0".Ord ;
	;
	CASE neg ? RESULT = -RESULT ; .
	
FUN Class_needs_testing(
{Type} C|lass_to_check) ==> BOOL
	:
	CASE C.Test[].Count == 0 ? ==> ;
	CASE ?
	["$ALLTESTS" IN C.Compiler.Defined_name[]] ? RESULT = TRUE ==> 
	["$NOTESTS" IN C.Compiler.Defined_name[]] ? RESULT = FALSE ==> ;
    //DEBUG: RESULT = FALSE ==> ;
	INT h|ash_of_source = C.Hash_calc // hash_calc(C.Parse.Source[])
	INT size|_of_source = C.File_size // size_file(C.Path)
	
	{Configuration} conf|iguration_temp = New_read_config(
		KEY, 'USER', "Testing\" TARGET_LANG(C.Compiler))
		
	CASE !conf.Present(C.Whole_name) ? RESULT = TRUE ==> ;
	STR s|tring_stored_values[] 
	Split(s[], conf.Str(C.Whole_name), " ")
	CASE s[0].Int != h || s[1].Int != size ?
         //DEBUG: "1 class " C.Names[0] " [0]=" s[0].Int " <> h=" h 
         //       " || [1]=" s[1].Int " <> size=" size  #NL ;
	     RESULT = TRUE ==> ;
	----------------------------- 'check imported classes'
	FOR im IN C.Import_[] :
	    BOOL p|resent_in_configuration = conf.Present(im.Whole_name) 
	    CASE !p && im.Test[].Count == 0 ?
	         CONTINUE im ;
	    CASE !p ?
             //DEBUG: "2 class " C.Names[0] " import " im.Names[0] " not present "
             //#NL ;
	         RESULT = TRUE ==> ;
	    h = im.Hash_calc // hash_calc(im.Parse.Source[])
	    size = im.File_size // size_file(im.Path)
	    Split(s[], conf.Str(im.Whole_name), " ")
	    CASE s[0].Int != h || s[1].Int != size ?
             //DEBUG: "3 class " C.Names[0] " import " im.Names[0]
             //" [0]=" s[0].Int " <> h=" h " || [1]=" [1].Int " <> size=" size 
             //#NL ;
	         RESULT = TRUE ==> ;
	; .
	
	
----------------------- 'store testing results'

FUN Testing_done(
{Type} C|lass_tested, REAL P|ercents_covered)
	:
	{Configuration} conf|iguration_temp = New_write_config(
		KEY, 'USER', "Testing\" TARGET_LANG(C.Compiler))
		
	STR v|alue_to_store = C.Hash_calc.Str // hash_calc(C.Parse.Source[]).Str
	v = v " " C.File_size.Str
	v = v " " P.Str
	conf.Set_s(C.Whole_name, v) .
		    
FUN Testing_failed({Type} C|lass_not_tested) :
	{Configuration} conf|iguration_temp = New_write_config(
		KEY, 'USER', "Testing\" TARGET_LANG(C.Compiler))
		
	conf.Delete_value(C.Whole_name) .
		
END

*/
