[latex3-commits] [git/LaTeX3-latex3-latex3] master: Implement \intarray_gset_rand:Nnn to get an array of random numbers (490e843)

Bruno Le Floch bruno at le-floch.fr
Sun May 6 16:13:51 CEST 2018


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/490e84388d942e4020727c528c0f8214c527755f

>---------------------------------------------------------------

commit 490e84388d942e4020727c528c0f8214c527755f
Author: Bruno Le Floch <bruno at le-floch.fr>
Date:   Sat May 5 21:36:43 2018 -0400

    Implement \intarray_gset_rand:Nnn to get an array of random numbers


>---------------------------------------------------------------

490e84388d942e4020727c528c0f8214c527755f
 l3kernel/l3candidates.dtx               |   16 +++++
 l3kernel/l3intarray.dtx                 |  103 +++++++++++++++++++++++++++++--
 l3kernel/l3msg.dtx                      |    3 +-
 l3kernel/testfiles/m3expl001.luatex.tlg |   10 +++
 l3kernel/testfiles/m3expl001.ptex.tlg   |   10 +++
 l3kernel/testfiles/m3expl001.tlg        |   10 +++
 l3kernel/testfiles/m3expl001.uptex.tlg  |   10 +++
 l3kernel/testfiles/m3expl001.xetex.tlg  |    3 +
 l3kernel/testfiles/m3expl003.luatex.tlg |   10 +++
 l3kernel/testfiles/m3expl003.ptex.tlg   |   10 +++
 l3kernel/testfiles/m3expl003.tlg        |   10 +++
 l3kernel/testfiles/m3expl003.uptex.tlg  |   10 +++
 l3kernel/testfiles/m3expl003.xetex.tlg  |    3 +
 l3kernel/testfiles/m3rand001.lvt        |   13 +++-
 l3kernel/testfiles/m3rand001.tlg        |    9 ++-
 l3kernel/testfiles/m3rand001.xetex.tlg  |   62 ++++++++++++++++++-
 16 files changed, 284 insertions(+), 8 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 4734cd3..d0ade1e 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -445,6 +445,22 @@
 %   available in \XeTeX{}.
 % \end{function}
 %
+% \begin{function}[added = 2018-05-05]{\intarray_gset_rand:Nnn, \intarray_gset_rand:Nn}
+%   \begin{syntax}
+%     \cs{intarray_gset_rand:Nnn} \meta{intarray~var} \Arg{minimum} \Arg{maximum}
+%     \cs{intarray_gset_rand:Nn} \meta{intarray~var} \Arg{maximum}
+%   \end{syntax}
+%   Evaluates the integer expressions \meta{minimum} and \meta{maximum}
+%   then sets each entry (independently) of the \meta{integer array
+%   variable} to a pseudo-random number between the two (with bounds
+%   included).  If the absolute value of either bound is bigger than
+%   $2^{30}-1$, an error occurs.  Entries are generated in the same way
+%   as repeated calls to \cs{int_rand:nn} or \cs{int_rand:n}
+%   respectively, in particular for the second function the
+%   \meta{minimum} is $1$.  This is not yet available in \XeTeX{}.
+%   Assignments are always global.
+% \end{function}
+%
 % \subsection{Working with contents of integer arrays}
 %
 % \begin{function}[added = 2018-05-04, rEXP]{\intarray_const_from_clist:Nn}
diff --git a/l3kernel/l3intarray.dtx b/l3kernel/l3intarray.dtx
index 23fefb1..b54d706 100644
--- a/l3kernel/l3intarray.dtx
+++ b/l3kernel/l3intarray.dtx
@@ -222,6 +222,15 @@
 %
 % \subsection{Array items}
 %
+% \begin{macro}[EXP]{\@@_signed_max_dim:n}
+%   Used when an item to be stored is larger than \cs{c_max_dim} in
+%   absolute value; it is replaced by $\pm\cs{c_max_dim}$.
+%    \begin{macrocode}
+\cs_new:Npn \@@_signed_max_dim:n #1
+  { \int_value:w \int_compare:nNnT {#1} < 0 { - } \c_max_dim }
+%    \end{macrocode}
+% \end{macro}
+%
 % \begin{macro}[EXP]{\@@_bounds:NNnTF, \@@_bounds_error:NNn}
 %   The functions \cs{intarray_gset:Nnn} and \cs{intarray_item:Nn} share
 %   bounds checking.  The |T| branch is used if |#3| is within bounds of
@@ -295,10 +304,8 @@
 \cs_new_protected:Npn \@@_gset_overflow:NNnn #1#2#3#4
   {
     \__kernel_msg_error:nnxxxx { kernel } { overflow }
-      { \token_to_str:N #2 } {#3} {#4}
-      { \int_value:w \int_compare:nNnT {#4} < 0 { - } \c_max_dim }
-    \__kernel_intarray_gset:Nnn #2 {#3}
-      { \int_value:w \int_compare:nNnT {#4} < 0 { - } \c_max_dim }
+      { \token_to_str:N #2 } {#3} {#4} {  \@@_signed_max_dim:n {#4} }
+    #1 #2 {#3} { \@@_signed_max_dim:n {#4} }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -436,6 +443,94 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \subsection{Random arrays}
+%
+% \begin{macro}
+%   {
+%     \intarray_gset_rand:Nn,
+%     \intarray_gset_rand:Nnn,
+%     \@@_gset_rand:Nnn,
+%     \@@_gset_rand:Nff,
+%     \@@_gset_rand_auxi:Nnnn,
+%     \@@_gset_rand_auxii:Nnnn,
+%     \@@_gset_rand_auxiii:Nnnn,
+%     \@@_gset_all_same:Nn,
+%   }
+%   We only perform the bounds checks once.  This is done by two
+%   \cs{@@_gset_overflow_test:nw}, with an appropriate empty argument to
+%   avoid a spurious \enquote{at position \texttt{\#1}} part in the
+%   error message.  Then calculate the number of choices: this is at
+%   most $(2^{30}-1)-(-(2^{30}-1))+1=2^{31}-1$, which just barely does
+%   not overflow.  For small ranges use \cs{__kernel_randint:nn},
+%   otherwise use the (very much slower) floating point |randint|.
+%   Finally, if there are no random numbers do not define any of the
+%   auxiliaries.
+%    \begin{macrocode}
+\cs_new_protected:Npn \intarray_gset_rand:Nn #1
+  { \intarray_gset_rand:Nnn #1 { 1 } }
+\sys_if_rand_exist:TF
+  {
+    \cs_new_protected:Npn \intarray_gset_rand:Nnn #1#2#3
+      {
+        \@@_gset_rand:Nff #1
+          { \int_eval:n {#2} } { \int_eval:n {#3} }
+      }
+    \cs_new_protected:Npn \@@_gset_rand:Nnn #1#2#3
+      {
+        \int_compare:nNnTF {#2} > {#3}
+          {
+            \__kernel_msg_expandable_error:nnnn
+              { kernel } { randint-backward-range } {#2} {#3}
+            \@@_gset_rand:Nnn #1 {#3} {#2}
+          }
+          {
+            \@@_gset_overflow_test:nw {#2}
+            \@@_gset_rand_auxi:Nnnn #1 { } {#2} {#3}
+          }
+      }
+    \cs_generate_variant:Nn \@@_gset_rand:Nnn { Nff }
+    \cs_new_protected:Npn \@@_gset_rand_auxi:Nnnn #1#2#3#4
+      {
+        \@@_gset_overflow_test:nw {#4}
+        \@@_gset_rand_auxii:Nnnn #1 { } {#4} {#3}
+      }
+    \cs_new_protected:Npn \@@_gset_rand_auxii:Nnnn #1#2#3#4
+      {
+        \exp_args:NNf \@@_gset_rand_auxiii:Nnnn #1
+          { \int_eval:n { #3 - #4 + 1 } } {#4} {#3}
+      }
+    \cs_new_protected:Npn \@@_gset_rand_auxiii:Nnnn #1#2#3#4
+      {
+        \exp_args:NNf \@@_gset_all_same:Nn #1
+          {
+            \int_compare:nNnTF {#2} > \c__kernel_randint_max_int
+              { \exp_stop_f: \fp_to_int:n { randint(#3,#4) } }
+              {
+                \exp_stop_f:
+                \int_eval:n { \__kernel_randint:nn {#3} {#2} }
+              }
+          }
+      }
+    \cs_new_protected:Npn \@@_gset_all_same:Nn #1#2
+      {
+        \int_zero:N \l_@@_loop_int
+        \prg_replicate:nn { \intarray_count:N #1 }
+          {
+            \int_incr:N \l_@@_loop_int
+            \__kernel_intarray_gset:Nnn #1 \l_@@_loop_int {#2}
+          }
+      }
+  }
+  {
+    \cs_new_protected:Npn \intarray_gset_rand:Nnn #1#2#3
+      {
+        \__kernel_msg_error:nnn { kernel } { fp-no-random }
+          { \intarray_gset_rand:Nnn #1 {#2} {#3} }
+      }
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 %    \begin{macrocode}
 %</initex|package>
 %    \end{macrocode}
diff --git a/l3kernel/l3msg.dtx b/l3kernel/l3msg.dtx
index 6eacc18..8c93401 100644
--- a/l3kernel/l3msg.dtx
+++ b/l3kernel/l3msg.dtx
@@ -1711,7 +1711,8 @@
 \__kernel_msg_new:nnnn { kernel } { overflow }
   { Integers~larger~than~2^{30}-1~cannot~be~stored~in~arrays. }
   {
-    An~attempt~was~made~to~store~#3~at~position~#2~in~the~array~'#1'.~
+    An~attempt~was~made~to~store~#3~
+    \tl_if_empty:nF {#2} { at~position~#2~ } in~the~array~'#1'.~
     The~largest~allowed~value~#4~will~be~used~instead.
   }
 \__kernel_msg_new:nnnn { kernel } { out-of-bounds }
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index 6ff4b8b..52e6cc6 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -3323,6 +3323,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3345,6 +3346,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index 5fe6b6e..3bb58be 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -3577,6 +3577,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3599,6 +3600,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index c067bdb..06cf5f3 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -3577,6 +3577,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3599,6 +3600,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 18954cf..a81e100 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -3577,6 +3577,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3599,6 +3600,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index e38b05b..69f7e2e 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -3322,6 +3322,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3344,6 +3345,8 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index 6ff4b8b..52e6cc6 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -3323,6 +3323,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3345,6 +3346,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index 5fe6b6e..3bb58be 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -3577,6 +3577,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3599,6 +3600,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index c067bdb..06cf5f3 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -3577,6 +3577,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3599,6 +3600,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 18954cf..a81e100 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -3577,6 +3577,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3599,6 +3600,15 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
+Defining \__intarray_gset_rand:Nnn on line ...
+Defining \exp_args:NNff on line ...
+Defining \__intarray_gset_rand:Nff on line ...
+Defining \__intarray_gset_rand_auxi:Nnnn on line ...
+Defining \__intarray_gset_rand_auxii:Nnnn on line ...
+Defining \__intarray_gset_rand_auxiii:Nnnn on line ...
+Defining \__intarray_gset_all_same:Nn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index e38b05b..69f7e2e 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -3322,6 +3322,7 @@ Defining message LaTeX/kernel/negative-array-size on line ...
 Defining \__intarray_new:N on line ...
 Defining \intarray_new:Nn on line ...
 Defining \intarray_count:N on line ...
+Defining \__intarray_signed_max_dim:n on line ...
 Defining \__intarray_bounds:NNnTF on line ...
 Defining \__intarray_bounds_error:NNn on line ...
 Defining \__kernel_intarray_gset:Nnn on line ...
@@ -3344,6 +3345,8 @@ Defining \intarray_show:c on line ...
 Defining \intarray_log:N on line ...
 Defining \intarray_log:c on line ...
 Defining \__intarray_show:NN on line ...
+Defining \intarray_gset_rand:Nn on line ...
+Defining \intarray_gset_rand:Nnn on line ...
 Defining \__fp_int_eval:w on line ...
 Defining \__fp_int_eval_end: on line ...
 Defining \__fp_int_to_roman:w on line ...
diff --git a/l3kernel/testfiles/m3rand001.lvt b/l3kernel/testfiles/m3rand001.lvt
index 8008722..4024a72 100644
--- a/l3kernel/testfiles/m3rand001.lvt
+++ b/l3kernel/testfiles/m3rand001.lvt
@@ -164,11 +164,22 @@
 \intarray_const_from_clist:Nn \c_empty_intarray { }
 \intarray_const_from_clist:Nn \c_test_intarray { 3 , 3 , 3 , 1 }
 \TIMO
-\TESTEXP { Random~prop~key/value }
+\TESTEXP { Random~intarray~item }
   {
     \intarray_rand_item:N \c_empty_intarray \NEWLINE
     \test_ii:n { \intarray_rand_item:N \c_test_intarray }
   }
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\intarray_new:Nn \g_testb_intarray { 15 }
+\TEST { Random~intarray~contents }
+  {
+    \sys_gset_rand_seed:n { 0 }
+    \intarray_gset_rand:Nnn \g_testb_intarray { -2 } { 5 }
+    \TYPE { \intarray_to_clist:N \g_testb_intarray }
+    \intarray_gset_rand:Nnn \g_testb_intarray { -\c_max_dim } { \c_max_dim }
+    \TYPE { \intarray_to_clist:N \g_testb_intarray }
+  }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \END
diff --git a/l3kernel/testfiles/m3rand001.tlg b/l3kernel/testfiles/m3rand001.tlg
index 8d01500..1fe6112 100644
--- a/l3kernel/testfiles/m3rand001.tlg
+++ b/l3kernel/testfiles/m3rand001.tlg
@@ -293,7 +293,7 @@ and I'll forget about whatever was undefined.
 |2|10|7|9|6|11|10|6|6|2|4|1|3|1|2|
 ============================================================
 ============================================================
-TEST 11: Random prop key/value
+TEST 11: Random intarray item
 ============================================================
 ! Undefined control sequence.
 <argument> \LaTeX3 error: 
@@ -316,3 +316,10 @@ and I'll forget about whatever was undefined.
 0
 |3|1|3|1|3|3|3|1|3|1|3|3|1|3|1|
 ============================================================
+Defining \g_testb_intarray on line ...
+============================================================
+TEST 12: Random intarray contents
+============================================================
+-1,0,2,-2,2,-1,2,-2,3,-1,3,2,0,4,5
+820649670,-76691285,-492843675,964914867,-36140785,421358030,-646354023,1060444501,-447645417,267975480,-671975694,-407769766,-332046542,-666077711,1040688595
+============================================================
diff --git a/l3kernel/testfiles/m3rand001.xetex.tlg b/l3kernel/testfiles/m3rand001.xetex.tlg
index 12de33f..180b1ad 100644
--- a/l3kernel/testfiles/m3rand001.xetex.tlg
+++ b/l3kernel/testfiles/m3rand001.xetex.tlg
@@ -477,7 +477,7 @@ and I'll forget about whatever was undefined.
 (1) (1) (1) 
 ============================================================
 ============================================================
-TEST 11: Random prop key/value
+TEST 11: Random intarray item
 ============================================================
 ! Undefined control sequence.
 <argument> \LaTeX3 error: 
@@ -509,3 +509,63 @@ and I'll forget about whatever was undefined.
 0
 (3) 
 ============================================================
+Defining \g_testb_intarray on line ...
+============================================================
+TEST 12: Random intarray contents
+============================================================
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/fp-no-random"
+! 
+! Random numbers unavailable for \sys_gset_rand_seed:n {0}
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! Type <return> to continue.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| LaTeX does not know anything more about this error, sorry.
+| 
+| Try typing <return> to proceed.
+| If that doesn't work, type X <return> to quit.
+|...............................................
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/fp-no-random"
+! 
+! Random numbers unavailable for \intarray_gset_rand:Nnn \g_testb_intarray
+! {-2}{5}
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! Type <return> to continue.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| LaTeX does not know anything more about this error, sorry.
+| 
+| Try typing <return> to proceed.
+| If that doesn't work, type X <return> to quit.
+|...............................................
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!
+! LaTeX error: "kernel/fp-no-random"
+! 
+! Random numbers unavailable for \intarray_gset_rand:Nnn \g_testb_intarray
+! {-\c_max_dim }{\c_max_dim }
+! 
+! See the LaTeX3 documentation for further information.
+! 
+! Type <return> to continue.
+!...............................................  
+l. ...  }
+|'''''''''''''''''''''''''''''''''''''''''''''''
+| LaTeX does not know anything more about this error, sorry.
+| 
+| Try typing <return> to proceed.
+| If that doesn't work, type X <return> to quit.
+|...............................................
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+============================================================





More information about the latex3-commits mailing list