[latex3-commits] [git/LaTeX3-latex3-latex3] master: Make \fp_compare:nTF robust against tuples (fixes #438); add tests (76e33d6)
Bruno Le Floch
bruno at le-floch.fr
Sun Feb 25 21:41:50 CET 2018
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/76e33d6d1cd7e716d1b484fb898846e0d24295dc
>---------------------------------------------------------------
commit 76e33d6d1cd7e716d1b484fb898846e0d24295dc
Author: Bruno Le Floch <bruno at le-floch.fr>
Date: Sun Feb 25 15:41:50 2018 -0500
Make \fp_compare:nTF robust against tuples (fixes #438); add tests
This remaining problem only showed up if the argument of \fp_compare:nTF
evaluates to a tuple, which does not happen for the supported syntax
operand_1 relation_1 operand_2 etc.
>---------------------------------------------------------------
76e33d6d1cd7e716d1b484fb898846e0d24295dc
l3kernel/l3fp-logic.dtx | 10 +++++++---
l3kernel/testfiles/m3fp-logic001.lvt | 1 +
l3kernel/testfiles/m3fp-logic001.tlg | 1 +
l3kernel/testfiles/m3rand001.lvt | 5 ++++-
l3kernel/testfiles/m3rand001.tlg | 30 ++++++++++++++++++++++++++++++
l3kernel/testfiles/m3rand001.xetex.tlg | 30 ++++++++++++++++++++++++++++++
6 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/l3kernel/l3fp-logic.dtx b/l3kernel/l3fp-logic.dtx
index 6158451..4339385 100644
--- a/l3kernel/l3fp-logic.dtx
+++ b/l3kernel/l3fp-logic.dtx
@@ -96,16 +96,20 @@
% \begin{macro}[pTF, EXP]{\fp_compare:n}
% \begin{macro}[EXP]{\@@_compare_return:w}
% Within floating point expressions, comparison operators are treated
-% as operations, so we evaluate |#1|, then compare with $0$.
+% as operations, so we evaluate |#1|, then compare with $\pm 0$.
+% Tuples are \texttt{true}.
% \begin{macrocode}
\prg_new_conditional:Npnn \fp_compare:n #1 { p , T , F , TF }
{
\exp_after:wN \@@_compare_return:w
\exp:w \exp_end_continue_f:w \@@_parse:n {#1}
}
-\cs_new:Npn \@@_compare_return:w \s_@@ \@@_chk:w #1#2;
+\cs_new:Npn \@@_compare_return:w #1#2#3;
{
- \if_meaning:w 0 #1
+ \if_charcode:w 0
+ \@@_if_type_fp:NTwFw
+ #1 { \use_i_delimit_by_q_stop:nw #3 \q_stop }
+ \s_@@ 1 \q_stop
\prg_return_false:
\else:
\prg_return_true:
diff --git a/l3kernel/testfiles/m3fp-logic001.lvt b/l3kernel/testfiles/m3fp-logic001.lvt
index c63b99f..d16a109 100644
--- a/l3kernel/testfiles/m3fp-logic001.lvt
+++ b/l3kernel/testfiles/m3fp-logic001.lvt
@@ -135,6 +135,7 @@
\test:nn {(1,-0)} {(1,+0)}
\test:nn {(1,nan)} {(1,nan)}
\test:nn {(2,3)} {(4,5)}
+ \fp_compare:nTF { (1, 2) } { \TRUE } { \ERROR }
}
\TESTEXP { Expansion~and~expressions }
diff --git a/l3kernel/testfiles/m3fp-logic001.tlg b/l3kernel/testfiles/m3fp-logic001.tlg
index ef0be0e..b446937 100644
--- a/l3kernel/testfiles/m3fp-logic001.tlg
+++ b/l3kernel/testfiles/m3fp-logic001.tlg
@@ -311,6 +311,7 @@ TEST 3: Comparing tuples
< FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE
! TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
!< TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
+TRUE
============================================================
============================================================
TEST 4: Expansion and expressions
diff --git a/l3kernel/testfiles/m3rand001.lvt b/l3kernel/testfiles/m3rand001.lvt
index 850d4a2..65b588a 100644
--- a/l3kernel/testfiles/m3rand001.lvt
+++ b/l3kernel/testfiles/m3rand001.lvt
@@ -1,5 +1,5 @@
%
-% Copyright (C) 2016,2017 LaTeX3 Project
+% Copyright (C) 2016-2018 LaTeX3 Project
%
\documentclass{minimal}
@@ -59,6 +59,9 @@
\fp_to_tl:n { randint(nan,0) } \NEWLINE
\fp_to_tl:n { randint(inf,0) } \NEWLINE
\int_rand:nn { 1 } { 0 } \NEWLINE
+ \fp_to_tl:n { rand((1,)) } \NEWLINE
+ \fp_to_tl:n { randint((1,2)) } \NEWLINE
+ \fp_to_tl:n { randint((),()) } \NEWLINE
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/l3kernel/testfiles/m3rand001.tlg b/l3kernel/testfiles/m3rand001.tlg
index c3a3af6..b037084 100644
--- a/l3kernel/testfiles/m3rand001.tlg
+++ b/l3kernel/testfiles/m3rand001.tlg
@@ -177,6 +177,33 @@ of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ rand() expects between 0 and 0 arguments.
+l. ... }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ Arguments in randint((1, 2),) are invalid.
+l. ... }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ Arguments in randint((), ()) are invalid.
+l. ... }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
nan
nan
nan
@@ -192,6 +219,9 @@ nan
nan
nan
1
+nan
+nan
+nan
============================================================
============================================================
TEST 4: Random integer in a range
diff --git a/l3kernel/testfiles/m3rand001.xetex.tlg b/l3kernel/testfiles/m3rand001.xetex.tlg
index 80787ed..bb83fcb 100644
--- a/l3kernel/testfiles/m3rand001.xetex.tlg
+++ b/l3kernel/testfiles/m3rand001.xetex.tlg
@@ -212,6 +212,33 @@ of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ Random numbers unavailable
+l. ... }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ Random numbers unavailable
+l. ... }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
+! Undefined control sequence.
+<argument> \LaTeX3 error:
+ Random numbers unavailable
+l. ... }
+The control sequence at the end of the top line
+of your error message was never \def'ed. If you have
+misspelled it (e.g., `\hobx'), type `I' and the correct
+spelling (e.g., `I\hbox'). Otherwise just continue,
+and I'll forget about whatever was undefined.
nan
nan
nan
@@ -227,6 +254,9 @@ nan
nan
nan
1
+nan
+nan
+nan
============================================================
============================================================
TEST 4: Random integer in a range
More information about the latex3-commits
mailing list