[latex3-commits] [latex3/latex3] main: Add and adapt tests (873295df2)
github at latex-project.org
github at latex-project.org
Sun Oct 29 11:39:17 CET 2023
Repository : https://github.com/latex3/latex3
On branch : main
Link : https://github.com/latex3/latex3/commit/873295df206666e7ae8c6a02165e4d442058e8c0
>---------------------------------------------------------------
commit 873295df206666e7ae8c6a02165e4d442058e8c0
Author: Yukai Chou <muzimuzhi at gmail.com>
Date: Sat Oct 28 08:23:57 2023 +0800
Add and adapt tests
>---------------------------------------------------------------
873295df206666e7ae8c6a02165e4d442058e8c0
l3kernel/testfiles/m3fp-symbolic001.luatex.tlg | 8 ++-
l3kernel/testfiles/m3fp-symbolic001.lvt | 7 +--
l3kernel/testfiles/m3fp-symbolic001.tlg | 8 ++-
l3kernel/testfiles/m3fp-symbolic002.luatex.tlg | 70 ++++++++++++++++++++++++--
l3kernel/testfiles/m3fp-symbolic002.lvt | 36 +++++++++++--
l3kernel/testfiles/m3fp-symbolic002.tlg | 70 ++++++++++++++++++++++++--
6 files changed, 178 insertions(+), 21 deletions(-)
diff --git a/l3kernel/testfiles/m3fp-symbolic001.luatex.tlg b/l3kernel/testfiles/m3fp-symbolic001.luatex.tlg
index bf075431f..b4b5b419e 100644
--- a/l3kernel/testfiles/m3fp-symbolic001.luatex.tlg
+++ b/l3kernel/testfiles/m3fp-symbolic001.luatex.tlg
@@ -7,8 +7,12 @@ TEST 1: Assign a symbolic expression
Defining \__fp_parse_word_A:N on line ...
Defining \__fp_parse_word_B:N on line ...
Defining \__fp_parse_word_C:N on line ...
-((A)+(csc(B)))+((C)*(sin(B)))
-((A)+(csc(B)))+((C)*(sin(B)))
+> \l_tmpa_fp=((A)+(csc(B)))+((C)*(sin(B))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=((A)+(csc(B)))+((C)*(sin(B))).
+<recently read> }
+l. ... }
((A)+(2))+((C)*(0.4999999999999999))
((A)+(2))+(0.5999999999999999)
3.6
diff --git a/l3kernel/testfiles/m3fp-symbolic001.lvt b/l3kernel/testfiles/m3fp-symbolic001.lvt
index f4c5f04d8..6e5308e32 100644
--- a/l3kernel/testfiles/m3fp-symbolic001.lvt
+++ b/l3kernel/testfiles/m3fp-symbolic001.lvt
@@ -22,9 +22,9 @@
\fp_new_variable:n { B }
\fp_new_variable:n { C }
\fp_set:Nn \l_tmpa_fp { A + csc(B) + C * sin(B) }
- \TYPE { \fp_to_tl:N \l_tmpa_fp }
+ \fp_show:N \l_tmpa_fp
\fp_set_variable:nn { B } { pi/6 }
- \TYPE { \fp_to_tl:N \l_tmpa_fp }
+ \fp_show:N \l_tmpa_fp
\TYPE { \fp_to_tl:n { \l_tmpa_fp } }
\fp_set_variable:nn { C } { 1.2 }
\TYPE { \fp_to_tl:n { \l_tmpa_fp } }
@@ -33,6 +33,7 @@
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
\TESTEXP { Conversions }
{
\fp_to_decimal:n { A + B**2 } \NEWLINE
@@ -87,7 +88,7 @@
\TEST { Set~and~clear~both~acts~locally }
{
\OMIT
- \cs_set:Npn \test_temp:
+ \cs_set_protected:Npn \test_temp:
{ \TYPE { \fp_to_tl:n { P*P + 1 } } }
\TIMO
\fp_new_variable:n { P }
diff --git a/l3kernel/testfiles/m3fp-symbolic001.tlg b/l3kernel/testfiles/m3fp-symbolic001.tlg
index 4c3022ef1..edada5f35 100644
--- a/l3kernel/testfiles/m3fp-symbolic001.tlg
+++ b/l3kernel/testfiles/m3fp-symbolic001.tlg
@@ -7,8 +7,12 @@ TEST 1: Assign a symbolic expression
Defining \__fp_parse_word_A:N on line ...
Defining \__fp_parse_word_B:N on line ...
Defining \__fp_parse_word_C:N on line ...
-((A)+(csc(B)))+((C)*(sin(B)))
-((A)+(csc(B)))+((C)*(sin(B)))
+> \l_tmpa_fp=((A)+(csc(B)))+((C)*(sin(B))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=((A)+(csc(B)))+((C)*(sin(B))).
+<recently read> }
+l. ... }
((A)+(2))+((C)*(0.4999999999999999))
((A)+(2))+(0.5999999999999999)
3.6
diff --git a/l3kernel/testfiles/m3fp-symbolic002.luatex.tlg b/l3kernel/testfiles/m3fp-symbolic002.luatex.tlg
index 81dc3c0ff..37d79d8bb 100644
--- a/l3kernel/testfiles/m3fp-symbolic002.luatex.tlg
+++ b/l3kernel/testfiles/m3fp-symbolic002.luatex.tlg
@@ -7,12 +7,18 @@ TEST 1: Functions in symbolic expression
Defining \__fp_parse_word_A:N on line ...
Defining \__fp_parse_word_B:N on line ...
Defining \__fp_parse_word_C:N on line ...
-((A(3))+(B(3.141592653589793, 3)))+((C(0, 0, 0.2))*(B(3.141592653589793, 6)))
+> \l_tmpa_fp=((A(3))+(B(3.141592653589793, 3)))+((C(0, 0,
+0.2))*(B(3.141592653589793, 6))).
+<recently read> }
+l. ... }
Defining \__fp_parse_word__i:N on line ...
Defining \__fp_parse_word_i:N on line ...
Defining \__fp_parse_word__ii:N on line ...
Defining \__fp_parse_word_j:N on line ...
-((A(3))+(B(3.141592653589793, 3)))+((C(0, 0, 0.2))*(B(3.141592653589793, 6)))
+> \l_tmpa_fp=((A(3))+(B(3.141592653589793, 3)))+((C(0, 0,
+0.2))*(B(3.141592653589793, 6))).
+<recently read> }
+l. ... }
((A(3))+(1.047197551196598))+((C(0, 0, 0.2))*(0.5235987755982988))
Defining \__fp_parse_word__i:N on line ...
Defining \__fp_parse_word_i:N on line ...
@@ -125,7 +131,61 @@ Defining \__fp_parse_word_inf:N on line ...
(((1)/(inf(pi(tmpa(1)))))+(aux(-1)))+(chk(1))
============================================================
============================================================
-TEST 5: Function parameters are created locally
+TEST 5: Show a variable holding symbolic expression
+============================================================
+Defining \__fp_parse_word_x:N on line ...
+Defining \__fp_parse_word_F:N on line ...
+> \l_tmpa_fp=x.
+<recently read> }
+l. ... }
+> \l_tmpa_fp =x.
+<recently read> }
+l. ... }
+> \l_tmpa_fp=F(1).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =F(1).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=F(x, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =F(x, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=F(1, (x)+(1), (tan(F(-1)))/(5)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =F(1, (x)+(1), (tan(F(-1)))/(5)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=(3)+((sin(x))*(F((x)^(x)))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =(3)+((sin(x))*(F((x)^(x)))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=(1, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =(1, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=(0, (x)+(-(x)), ((F(x))+(1))+((-1)+(!(F(x))))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =(0, (x)+(-(x)), ((F(x))+(1))+((-1)+(!(F(x))))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=((2)*(x), ((7)/(F(0.0174532925199433)))-(x), 4).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =((2)*(x), ((7)/(F(0.0174532925199433)))-(x), 4).
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 6: Function parameters are created locally
============================================================
Defining \__fp_parse_word_FUNCA:N on line ...
Defining \__fp_parse_word__i:N on line ...
@@ -144,7 +204,7 @@ Defining \__fp_parse_word_a:N on line ...
42
============================================================
============================================================
-TEST 6: Function parameters are cleared locally
+TEST 7: Function parameters are cleared locally
============================================================
Defining \__fp_parse_word_E:N on line ...
Defining \__fp_parse_word_PS:N on line ...
@@ -154,7 +214,7 @@ Defining \__fp_parse_word__i:N on line ...
l. ... }
============================================================
============================================================
-TEST 7: Set and clear both act locally
+TEST 8: Set and clear both act locally
============================================================
Defining \__fp_parse_word_FUNCP:N on line ...
((FUNCP(3, 4))*(10))-(7)
diff --git a/l3kernel/testfiles/m3fp-symbolic002.lvt b/l3kernel/testfiles/m3fp-symbolic002.lvt
index 75658325a..ea8a44058 100644
--- a/l3kernel/testfiles/m3fp-symbolic002.lvt
+++ b/l3kernel/testfiles/m3fp-symbolic002.lvt
@@ -23,9 +23,9 @@
\fp_new_function:n { C }
% wired fp-expr :)
\fp_set:Nn \l_tmpa_fp { A(3) + B(pi, 3) + C(0,0,.2) * B(pi, 6) }
- \TYPE { \fp_to_tl:N \l_tmpa_fp } % symbolic
+ \fp_show:N \l_tmpa_fp % symbolic
\fp_set_function:nnn { B } { i, j } { i/j }
- \TYPE { \fp_to_tl:N \l_tmpa_fp } % symbolic
+ \fp_show:N \l_tmpa_fp % symbolic
\TYPE { \fp_to_tl:n { \l_tmpa_fp } } % symbolic, B(pi, 3) evaluated
\fp_set_function:nnn { C } { i, j, k } { k * -10 }
\TYPE { \fp_to_tl:n { \l_tmpa_fp } } % symbolic, B & C evaluated
@@ -34,6 +34,7 @@
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
\TESTEXP { Conversions }
{
\fp_to_decimal:n { A(1) + B(1,2)**2 } \NEWLINE
@@ -87,10 +88,37 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\TEST { Show~a~variable~holding~symbolic~expression }
+ {
+ \OMIT
+ \cs_set_protected:Npn \test_temp:n #1
+ {
+ \fp_set:Nn \l_tmpa_fp {#1}
+ \fp_show:N \l_tmpa_fp
+ \fp_show:n \l_tmpa_fp
+ }
+ \TIMO
+ \fp_new_variable:n { x }
+ \fp_new_function:n { F }
+ \test_temp:n { x }
+ \test_temp:n { F(1) }
+ \test_temp:n { F(x, F(x)) }
+ \test_temp:n { F(1, x + 1, tan(F(-1)) / 5) }
+ \test_temp:n { 3 + sin(x) * F(x**x) }
+ % tuples
+ \test_temp:n { 1 , F(x) }
+ \test_temp:n { (1 , x , F(x) + 1) + (-1 , -x , -1 + !F(x)) }
+ % after using \fp_new_function:n { pi } in a previous test,
+ % pi is not a constant anymore
+ \test_temp:n { 2 * x , 7 / F(deg) - x , 4 }
+ }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
\TEST { Function~parameters~are~created~locally }
{
\OMIT
- \cs_set:Npn \test_temp:
+ \cs_set_protected:Npn \test_temp:
{ \TYPE { \fp_to_tl:n { a + FUNCA(1) } } }
\TIMO
\fp_new_function:n { FUNCA }
@@ -118,7 +146,7 @@
\TEST { Set~and~clear~both~act~locally }
{
\OMIT
- \cs_set:Npn \test_temp:
+ \cs_set_protected:Npn \test_temp:
{ \TYPE { \fp_to_tl:n { FUNCP(3, 4) * 10 - 7 } } }
\TIMO
\fp_new_function:n { FUNCP }
diff --git a/l3kernel/testfiles/m3fp-symbolic002.tlg b/l3kernel/testfiles/m3fp-symbolic002.tlg
index 45117fab2..79c250d9a 100644
--- a/l3kernel/testfiles/m3fp-symbolic002.tlg
+++ b/l3kernel/testfiles/m3fp-symbolic002.tlg
@@ -7,12 +7,18 @@ TEST 1: Functions in symbolic expression
Defining \__fp_parse_word_A:N on line ...
Defining \__fp_parse_word_B:N on line ...
Defining \__fp_parse_word_C:N on line ...
-((A(3))+(B(3.141592653589793, 3)))+((C(0, 0, 0.2))*(B(3.141592653589793, 6)))
+> \l_tmpa_fp=((A(3))+(B(3.141592653589793, 3)))+((C(0, 0,
+0.2))*(B(3.141592653589793, 6))).
+<recently read> }
+l. ... }
Defining \__fp_parse_word__i:N on line ...
Defining \__fp_parse_word_i:N on line ...
Defining \__fp_parse_word__ii:N on line ...
Defining \__fp_parse_word_j:N on line ...
-((A(3))+(B(3.141592653589793, 3)))+((C(0, 0, 0.2))*(B(3.141592653589793, 6)))
+> \l_tmpa_fp=((A(3))+(B(3.141592653589793, 3)))+((C(0, 0,
+0.2))*(B(3.141592653589793, 6))).
+<recently read> }
+l. ... }
((A(3))+(1.047197551196598))+((C(0, 0, 0.2))*(0.5235987755982988))
Defining \__fp_parse_word__i:N on line ...
Defining \__fp_parse_word_i:N on line ...
@@ -125,7 +131,61 @@ Defining \__fp_parse_word_inf:N on line ...
(((1)/(inf(pi(tmpa(1)))))+(aux(-1)))+(chk(1))
============================================================
============================================================
-TEST 5: Function parameters are created locally
+TEST 5: Show a variable holding symbolic expression
+============================================================
+Defining \__fp_parse_word_x:N on line ...
+Defining \__fp_parse_word_F:N on line ...
+> \l_tmpa_fp=x.
+<recently read> }
+l. ... }
+> \l_tmpa_fp =x.
+<recently read> }
+l. ... }
+> \l_tmpa_fp=F(1).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =F(1).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=F(x, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =F(x, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=F(1, (x)+(1), (tan(F(-1)))/(5)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =F(1, (x)+(1), (tan(F(-1)))/(5)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=(3)+((sin(x))*(F((x)^(x)))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =(3)+((sin(x))*(F((x)^(x)))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=(1, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =(1, F(x)).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=(0, (x)+(-(x)), ((F(x))+(1))+((-1)+(!(F(x))))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =(0, (x)+(-(x)), ((F(x))+(1))+((-1)+(!(F(x))))).
+<recently read> }
+l. ... }
+> \l_tmpa_fp=((2)*(x), ((7)/(F(0.0174532925199433)))-(x), 4).
+<recently read> }
+l. ... }
+> \l_tmpa_fp =((2)*(x), ((7)/(F(0.0174532925199433)))-(x), 4).
+<recently read> }
+l. ... }
+============================================================
+============================================================
+TEST 6: Function parameters are created locally
============================================================
Defining \__fp_parse_word_FUNCA:N on line ...
Defining \__fp_parse_word__i:N on line ...
@@ -144,7 +204,7 @@ Defining \__fp_parse_word_a:N on line ...
42
============================================================
============================================================
-TEST 6: Function parameters are cleared locally
+TEST 7: Function parameters are cleared locally
============================================================
Defining \__fp_parse_word_E:N on line ...
Defining \__fp_parse_word_PS:N on line ...
@@ -154,7 +214,7 @@ Defining \__fp_parse_word__i:N on line ...
l. ... }
============================================================
============================================================
-TEST 7: Set and clear both act locally
+TEST 8: Set and clear both act locally
============================================================
Defining \__fp_parse_word_FUNCP:N on line ...
((FUNCP(3, 4))*(10))-(7)
More information about the latex3-commits
mailing list.