Original in Russian: http://programmingmindstream.blogspot.ru/2015/08/blog-post_70.html
The previous series was here – Code generation. Extracting the specific model and specific templates to external dictionaries.
Let’s take our mind off the code generation and discuss the tests.
The idea was raised here - ToDo. Tests for script words.
Now I have developed this idea.
I’ll try to tell you how it was done.
Let us have the functions dictionary:
string.ms.dict
The tests for it:
String.ms.script
The results of the tests:
More or less we’ve tested the functions.
Various code areas have been covered.
Not so bad, but let’s move on.
We can put tests “inside” the functions and launch them from outside automatically.
Later I will try to tell how to do it.
The previous series was here – Code generation. Extracting the specific model and specific templates to external dictionaries.
Let’s take our mind off the code generation and discuss the tests.
The idea was raised here - ToDo. Tests for script words.
Now I have developed this idea.
I’ll try to tell you how it was done.
Let us have the functions dictionary:
string.ms.dict
USES Documentation.ms.dict params.ms.dict core.ms.dict map.ms.dict ; : (string) ^ IN aValue aValue DO ToPrintable ; // (string) STRING FUNCTION string:CatWihAny STRING IN aString IN aValue aString aValue ToPrintable Cat =: Result ; // string:CatWihAny STRING FUNCTION any:Cat ARRAY IN anArray anArray .map> ToPrintable strings:Cat =: Result ; // any:Cat STRING FUNCTION (+)? STRING in aPrefix STRING right aSuffix %SUMMARY 'If aSuffix is not empty, it returns the sum of aPrefix and aSuffix, otherwise or returns a blank string ' ; Result := '' STRING VAR l_Suffix aSuffix =: l_Suffix if ( l_Suffix =/= '' ) then ( aPrefix l_Suffix Cat =: Result ) ; // (+)? STRING FUNCTION ?(+) STRING in aPrefix STRING right aSuffix %SUMMARY 'If aPrefix is not empty, it returns the sum of aPrefix and aSuffix, otherwise or returns a blank string ' ; Result := '' if ( aPrefix =/= '' ) then ( aPrefix aSuffix Cat =: Result ) ; // ?(+) STRING FUNCTION strings:CatSep> STRING right aSep ARRAY right aValues aValues aSep strings:CatSep =: Result ; // strings:CatSep> WordAlias CatSep> strings:CatSep>
The tests for it:
String.ms.script
USES string.ms.dict ; '' (+)? 'B' Print 'A' (+)? 'B' Print 'A' (+)? '' Print '------------------' Print '' ?(+) 'B' Print 'A' ?(+) 'B' Print 'A' ?(+) '' Print '------------------' Print strings:CatSep> ' ' [ 'A' 'B' ] Print strings:CatSep> ' ' [ 'A ' 'B' ] Print strings:CatSep> ' ' [ 'A ' ' B' ] Print strings:CatSep> ' ' [ 'A' ' B' ] Print strings:CatSep> ' ' [ '' 'B' ] Print strings:CatSep> ' ' [ 'A' '' ] Print '------------------' Print [ 'A' 123 'B' ] any:Cat Print '------------------' Print
The results of the tests:
B AB ------------------ AB A ------------------ A B A B A B A B B A ------------------ A123B ------------------
More or less we’ve tested the functions.
Various code areas have been covered.
Not so bad, but let’s move on.
We can put tests “inside” the functions and launch them from outside automatically.
Later I will try to tell how to do it.
Комментариев нет:
Отправить комментарий