diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2023-08-14 20:56:54 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2023-08-14 20:56:54 -0700 |
commit | 725112ef78d8c6e655db4a99fc69e54d0ed1eb5a (patch) | |
tree | 89b456d55b28fb07a41483aa838555ee3035c1a5 /tests/016/ud-arith.tl | |
parent | f94ae27b4021b61eabe50d3b088b8d8917bfdfe8 (diff) | |
download | txr-725112ef78d8c6e655db4a99fc69e54d0ed1eb5a.tar.gz txr-725112ef78d8c6e655db4a99fc69e54d0ed1eb5a.tar.bz2 txr-725112ef78d8c6e655db4a99fc69e54d0ed1eb5a.zip |
math: tofloat and toint in user-defined arithmetic.
* arith.c (tofloat_s, toint_s): New symbol variables.
(tofloat, toint): If the argument is a COBJ, handle
it via do_unary_method.
(arith_init): Initialize new symbol variables.
The functions tofloat, toint, tofloatz and tointz.
are now registered here, rather than eval_init.
* eval.c (eval_init): Remove registrations of tofloat,
toint, tofloatz and tointz.
* tests/016/ud-arith.tl: New tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'tests/016/ud-arith.tl')
-rw-r--r-- | tests/016/ud-arith.tl | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/016/ud-arith.tl b/tests/016/ud-arith.tl index 35a0cb5f..8a8e50df 100644 --- a/tests/016/ud-arith.tl +++ b/tests/016/ud-arith.tl @@ -109,7 +109,9 @@ (:method r-remainder (me arg) ^(remainder ,arg ,me.v)) (:method r-scalb (me arg) ^(scalb ,arg ,me.v)) (:method r-scalbln (me arg) ^(scalbln ,arg ,me.v)) - (:method r-yn (me arg) ^(yn ,arg ,me.v))) + (:method r-yn (me arg) ^(yn ,arg ,me.v)) + (:method tofloat (me) ^(tofloat ,me.v)) + (:method toint (me) ^(toint ,me.v))) (defvarl n (new numbase v 1)) @@ -226,5 +228,7 @@ (test (scalb 0 n) (scalb 0 1)) (test (scalbln 0 n) (scalbln 0 1)) (test (yn 0 n) (yn 0 1)) +(test (tofloat n) (tofloat 1)) +(test (toint n) (toint 1)) (test (arithp n) t) |