Skip to content

Commit

Permalink
test(random): 🧪 add test for random number generation using modulo fr…
Browse files Browse the repository at this point in the history
…om zenroom data
  • Loading branch information
matteo-cristino committed Sep 28, 2023
1 parent c992d6c commit ec439de
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions test/zencode/random.bats
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,43 @@ EOF
cat <<EOF | zexe random_numbers.zen
Given nothing
When I create the array of '64' random numbers
Then print the 'array' as 'number'
Then print the 'array'
EOF
save_output 'array_random_nums.json'
assert_output '{"array":["3904086534545870648103397272374395472111763637484398936882003778415383430137","47814547401978225074551943904213649697478725078403230989228572241412545286587","20250292702156892133228542763254776040948430545701811534484410438642657305351","3638509672679313421396650447123673605069920774626448395168696993467069318322","2257780796768374787384994139875791998977257685729631114695862408498366831791","34685600361283436970232636854390932625142992040784233598000147899704055948718","10836023900635767872849288836365682792291331213435757293942181116469495190770","45011551088056380163568472514045809546537145114392674909708072719772102193807","46834277656873437830989136759743725261823997554247712334741442241521784131458","19036649058844508016250847061982566773624732066731826071450607888506722398538","22951110803797068394872512129896637701638766160588981651261275974969042109800","38464113506542938462921640434104944919670734817666327034073705300328623826311","34688353596503237898697677134242939420276624704608227019800769972238095095092","39729669272673417275689124615539379484034326218570016146219865014945900529329","50386863133821566618949117133531626446249651207178181018096553339617540676186","4780749269461261828871211789348275500996690946681185155546712938465126135346","18625526331360936019891568430062707563085530631611318185938988215690027877772","6120828558719666822714698669619663984354716516772738251985422474038270923369","4754799870786809414550151146387972441361612124041385542550994641638067561310","3171048970402684674413997541996124020856566655552110827874578708591455580379","51839476788245815571019465528585408091391537496445679174358906928439621332898","49284895238044257539799251133024481952259183570395456782029611881640483260383","23793423071278733633975613844392904697589546040471390619478009258514495753377","12422601348263381008231805759761607802196455732153489587240745599475008465898","22025317375021745893533108816830620564850851146338913756760602970780170447727","32938268479228414697959867476954271486636528822952733725679818389998338140012","29122730585157660447505036107005430131848296434991105307897538200349004020484","15679091822420326627917828339776501086424756250619494419606571743992091907006","26378147895327534839771887148112341667711296451314660930990647260520879926566","22827981109584334153926577828538463623899824964835764666076727632693253890647","23319507322545331847173789279574117245409613851450642985873714683555415232275","29346904966098864963634618326423305849751527931569182177493929683953719024359","21411742023623049412601510764676108076988626794280897615155808688138489685812","36577597262380444556516870118129258891630448815821755443719320621514026472138","44076977240693213132216562034824767453272260097121135865761042454142766693717","2263343693355390240564630226500250294548693679824816065318786148427492746145","20465961282908351218639922530194285588387291008350476792494764017072882447479","48802031388515212992418161289805877731235394249071739233340005908405467121044","30682084911053286009707594607270797715530616683689689082906588822724597436455","31270489297794985320083658178580359719066196882478666706065109210021963171693","10298083977621698456471161960404972488476291864246351843241506156315695106309","32250743118427067951355498196839349347720980200028024781374778973202019019014","15988624155440178542438823841594034017554989814129772746240673705056384599419","13493469786672307392372588897524916495700632246543154421334849913488575195520","47486011227022681378584899665338298663667604186593542307024113313108307816953","49376615311346451945914820928989976389181819548451011795425600103856435971686","6116628591184336937379216627750993277880893289105659675240169282338592191674","37694717363739166698808565633546662107826889656655916383749326014140981244017","2000209371551877596398019046309328915395457390948030554810503257358099091639","24426428267761535922463780172791998513206545821246526260030917328450197609420","21992427308692255955026386502908685913037854633409765424331905719565747265952","25182834017338467474619606393760722034275126237079457715918106332004197260250","45012910216816339370463821006545634538712257272918851546428476138491751233401","10023682381689832334957609660006976334383924197901586123477868350581815257237","23185364249367823063650142759083113342465753011192858545809957726517833002553","48557009515744913129811813319139745073331451275608433169897262261901175229828","8055397671964479959808863717350312018602873228201148773369379127077558641078","20527352340820328251225687766552542421403744600135761793525096159436408993753","1744099541349786043869278533733524209480756435241322161942399881616626700287","50813973875547414996260064851094985858929226171042919491763849444470271528749","14565585858096230174066403355487485721955230613815150373683110993650789331632","46757545749844544528061212801492420471771462899112979971344494085263544458086","25764927861691432394653552842636944222904294927399668094600578841908196742954","34713681150265725040619279827727469867214666937890540690204957740395771700475"]}'
}

@test "Array random nums modulo" {
cat <<EOF | zexe random_numbers_modulo.zen
Given nothing
cat <<EOF | save_asset random_numbers_modulo.data
{
"numbers_of_random": 10,
"modulo_int": "1234567890",
"modulo_float": 100
}
EOF

cat <<EOF | zexe random_numbers_modulo.zen random_numbers_modulo.data
Given I have a 'float' named 'numbers_of_random'
and I have a 'integer' named 'modulo_int'
and I have a 'float' named 'modulo_float'
# modulo in statement
When I create the array of '64' random numbers modulo '100'
and I create the aggregation of array 'array'
Then print the 'array' as 'number'
and print the 'aggregation' as 'number'
and I rename 'array' to 'modulo_in_statement'
# modulo as integer
When I create the array of 'numbers_of_random' random numbers modulo 'modulo_int'
and I rename 'array' to 'modulo_as_int'
# modulo as float
When I create the array of 'numbers_of_random' random numbers modulo 'modulo_float'
and I rename 'array' to 'modulo_as_float'
and I create the aggregation of array 'modulo_in_statement'
Then print the 'modulo_in_statement'
and print the 'modulo_as_int'
and print the 'modulo_as_float'
and print the 'aggregation'
EOF
save_output "array_random_nums_modulo.json"
assert_output '{"aggregation":"3174","array":["37","87","51","22","91","18","70","7","58","38","0","11","92","29","86","46","72","69","10","79","98","83","77","98","27","12","84","6","66","47","75","59","12","38","17","45","79","44","55","93","9","14","19","20","53","86","74","17","39","20","52","50","1","37","53","28","78","53","87","49","32","86","54","75"]}'
assert_output '{"aggregation":"3174","modulo_as_float":[5,54,34,51,29,15,45,83,85,34],"modulo_as_int":["956626096","1153915691","295091336","359211920","623653102","781512004","89024066","243000631","1160399432","779959027"],"modulo_in_statement":["37","87","51","22","91","18","70","7","58","38","0","11","92","29","86","46","72","69","10","79","98","83","77","98","27","12","84","6","66","47","75","59","12","38","17","45","79","44","55","93","9","14","19","20","53","86","74","17","39","20","52","50","1","37","53","28","78","53","87","49","32","86","54","75"]}'
}

@test "Pick random in array with one element" {
Expand Down

0 comments on commit ec439de

Please sign in to comment.