aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin D. Howard <gavin@gavinhoward.com>2023-03-27 14:32:36 -0600
committerGavin D. Howard <gavin@gavinhoward.com>2023-03-27 14:32:36 -0600
commit49c5d2e54f494db0df095690abce6572213efc17 (patch)
tree3f7a9efcde00642c470b175f36b741955977fddd
parentc148eec90e044b6d9cd1c7323f522f7fdb963037 (diff)
downloadbc-49c5d2e54f494db0df095690abce6572213efc17.tar.gz
Add a test for irand() limits in bc
This test found a bug which will be fixed in the next commit. Signed-off-by: Gavin D. Howard <gavin@gavinhoward.com>
-rw-r--r--manuals/development.md6
-rw-r--r--tests/bc/all.txt1
-rw-r--r--tests/bc/rand_limits.txt26
-rw-r--r--tests/bc/rand_limits_results.txt111
4 files changed, 143 insertions, 1 deletions
diff --git a/manuals/development.md b/manuals/development.md
index 333538df..aea41e2d 100644
--- a/manuals/development.md
+++ b/manuals/development.md
@@ -1,6 +1,6 @@
# Development
-Updated: 13 Mar 2023
+Updated: 27 Mar 2023
This document is meant for the day when I (Gavin D. Howard) get [hit by a
bus][1]. In other words, it's meant to make the [bus factor][1] a non-issue.
@@ -2260,6 +2260,10 @@ rand
: Tests the pseudo-random number generator and its special stack handling.
+rand_limits
+
+: Tests the limits of the pseudo-random number generator `irand()`.
+
recursive_arrays
: Tested the slab vector undo ability in used in `bc_parse_name()` when it
diff --git a/tests/bc/all.txt b/tests/bc/all.txt
index 3d0ea05b..c710534a 100644
--- a/tests/bc/all.txt
+++ b/tests/bc/all.txt
@@ -47,6 +47,7 @@ misc7
misc8
void
rand
+rand_limits
recursive_arrays
divmod
modexp
diff --git a/tests/bc/rand_limits.txt b/tests/bc/rand_limits.txt
new file mode 100644
index 00000000..462313bf
--- /dev/null
+++ b/tests/bc/rand_limits.txt
@@ -0,0 +1,26 @@
+seed = 12183415694832323910165063565742029266.78201143488173352403523006\
+ 17939450703787369504276248076613097826033345478457018711188931947\
+ 5643844725709641352295875549316406250
+
+for (i = 1; i <= 37; ++i)
+{
+ irand(10^i)
+}
+
+seed = 12183415694832323910165063565742029266.82951754507405817776622978\
+ 09630984098584076072986006731059784797092101840727292180396879039\
+ 9608224106486886739730834960937500000
+
+for (i = 1; i <= 37; ++i)
+{
+ irand(10^i)
+}
+
+seed = 149423560533592712773538909996244073918.29527526125449592086425200650563\
+410377957291848306408247710650762029718616172500631291732153815843275879\
+160501062870025634765625
+
+for (i = 1; i <= 37; ++i)
+{
+ irand(10^i)
+}
diff --git a/tests/bc/rand_limits_results.txt b/tests/bc/rand_limits_results.txt
new file mode 100644
index 00000000..d02693bc
--- /dev/null
+++ b/tests/bc/rand_limits_results.txt
@@ -0,0 +1,111 @@
+5
+15
+701
+8215
+98794
+602366
+2027255
+74687524
+830825144
+6081336208
+24314055735
+838559932276
+6866719060925
+36806875401211
+406827598340727
+5356006452532004
+38220052834497507
+337361587138720056
+1181974760686154481
+16008532535003488966
+951908092544652236970
+90730737551380302703
+46492092840194767743061
+188697840939074129889664
+3963332393372745718515074
+78044317381361304314479194
+257814131633376797403093774
+5383100889234097635148206308
+39812361752905775691804497289
+222434065196674291290714932718
+4942298796724199168854529657788
+30804146383811856719866376789543
+817977187096950760817419359822004
+922359768927341898905002631901715
+84002847212517205019842390182209654
+423700247670879534125867432896848815
+982360002329187383971171836321012954
+9
+73
+468
+1781
+79556
+166610
+9336284
+96403025
+23318279
+1074901232
+30659049590
+125915951725
+3123436435684
+52610031172756
+445020218860038
+87520306151384
+47213087211849485
+154045322058555704
+9488624282418036451
+12849313140308039019
+828063328914872193931
+2956454855398834052902
+87417046449320418408586
+165187095179884370295407
+3602892678245454556711806
+88079064510429999588220544
+376741359503002189591164726
+56633499559885161310029862
+11172900796387700171428233596
+473873806840427957175182603343
+824290276873152640168308384248
+36092351141101218267245025967581
+39973475177812910298579659860850
+7364670182480566996610562443888661
+51592684301602944329896812066058114
+951444349069518195584787848316744461
+3234933598293500107173129970384252570
+6
+47
+709
+350
+45155
+117711
+6147313
+26359748
+56878412
+930721373
+47052494689
+84216331603
+1874946867051
+30417072907659
+157776263741438
+3325742508233965
+39500653878059614
+278676289794009775
+3342139004245631096
+63313724143310202591
+647891168358497623537
+5925769871143510986759
+3051401096746445704645
+761857520743586046415633
+9077595326394996332524977
+2159936754163773508122732
+426809670586105698135317225
+3294516277260755029991322796
+14749983115477586453985047494
+692100641365100970093726483540
+9502478720578852594268790479747
+9062487417784678956874793130476
+352159971921852073191742323073689
+2270803770328639487517517910897872
+35166631277333300065883628523569361
+596441689792333324819903835359197616
+6933582360405829608479430394981956723