Skip to content

Commit

Permalink
Add classes to uni/lib that implement fixed point arithmetic.
Browse files Browse the repository at this point in the history
If operator overloading is configured the classes will support it. Otherwise, the
alternative methods (add, sub etc.) can be used in place of the infix operators.
Test code is in tests/unicon. There are two sets of tests, one with overloading and
one without (one is a superset of the other).
Unidoc documentation is embedded in the source code.
  • Loading branch information
Don-Ward committed Feb 26, 2024
1 parent 090d47a commit 8883112
Show file tree
Hide file tree
Showing 9 changed files with 1,249 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ E=/bin/echo
# define UC if it is not defined already
UC?=../bin/unicon

TESTS=general posix thread pattern mt
TESTS=general posix thread pattern mt unicon

# The default is to run all tests, using icont.

Expand Down
20 changes: 20 additions & 0 deletions tests/unicon/FxPtTest.icn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#################################################################################
#
# This file is released under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE
# (LGPL) version 2. The licence may be found in the root directory of the Unicon
# source directory in the file COPYING.
#
# Fixed Point Arithmetic class tests (without operator overloading)
# --------------------------------------------------------------------------------

procedure main(args)
if not(&features == "large integers") then
stop("large integers not supported")

runTests(args)
end

# Turn off operator overloading
$undef _OVLD
$include "FxPtTests.icn"

21 changes: 21 additions & 0 deletions tests/unicon/FxPtTest_OVLD.icn
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#################################################################################
#
# This file is released under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE
# (LGPL) version 2. The licence may be found in the root directory of the Unicon
# source directory in the file COPYING.
#
# Fixed Point Arithmetic class tests (with operator overloading)
# --------------------------------------------------------------------------------

procedure main(args)
if not(&features == "large integers") then
stop("large integers not supported")

if not (&features == "operator overloading") then
stop("operator overloading not supported")

runTests(args)
end

$include "FxPtTests.icn"

550 changes: 550 additions & 0 deletions tests/unicon/FxPtTests.icn

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions tests/unicon/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

include ../Makedefs

TARGETS=$(patsubst %.icn,%,$(wildcard *.icn))

SKIP= tester FxPtTests\
audio dbi list_test nlm q rec test testnlm clin_err hello mintest ovld q2 sel to

Test: DoTest

include ../Makefile.test

FxPtTest: FxPtTest.icn tester.u

FxPtTest_OVLD: FxPtTest_OVLD.icn tester.u

tester.u: tester.icn
$(UC) -s -u -c $^



4 changes: 4 additions & 0 deletions tests/unicon/stand/FxPtTest.std
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--------------------------------------------------
Fixed Point Tests Start
Fixed Point Tests Passed = 454 Failed = 0
--------------------------------------------------
4 changes: 4 additions & 0 deletions tests/unicon/stand/FxPtTest_OVLD.std
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--------------------------------------------------
Fixed Point Tests Start
Fixed Point Tests Passed = 586 Failed = 0
--------------------------------------------------
Loading

0 comments on commit 8883112

Please sign in to comment.