Release calc version 2.12.0

This commit is contained in:
Landon Curt Noll
2006-05-21 01:11:18 -07:00
parent 7165fa17c7
commit 58d94b08d8
342 changed files with 8845 additions and 6327 deletions

View File

@@ -18,8 +18,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.16 $
# @(#) $Id: Makefile,v 29.16 2005/12/12 06:42:30 chongo Exp $
# @(#) $Revision: 29.18 $
# @(#) $Id: Makefile,v 29.18 2006/05/20 19:32:40 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/Makefile,v $
#
# Under source code control: 1991/07/21 05:00:54
@@ -176,7 +176,8 @@ CALC_FILES= README bigprime.cal deg.cal ellip.cal lucas.cal lucas_chk.cal \
test3500.cal seedrandom.cal test4000.cal test4100.cal test4600.cal \
beer.cal hello.cal test5100.cal test5200.cal randombitrun.cal \
randomrun.cal repeat.cal xx_print.cal natnumset.cal qtime.cal \
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal
test8400.cal test8500.cal test8600.cal chi.cal intfile.cal screen.cal \
dotest.cal set8700.cal set8700.line
# These files are found (but not built) in the distribution
#

View File

@@ -12,7 +12,7 @@ Normally a resource file will simply define some functions. By default,
most resource files will print out a short message when they are read.
For example:
> read lucas
; read lucas
lucas(h,n) defined
gen_u0(h,n,v1) defined
gen_v1(h,n) defined
@@ -22,9 +22,9 @@ will cause calc to load and execute the 'lucas.cal' resource file.
Executing the resource file will cause several functions to be defined.
Executing the lucas function:
> lucas(149,60)
; lucas(149,60)
1
> lucas(146,61)
; lucas(146,61)
0
shows that 149*2^60-1 is prime whereas 146*2^61-1 is not.
@@ -180,6 +180,38 @@ deg.cal
Calculate in degrees, minutes, and seconds.
dotest.cal
dotest(dotest_file [,dotest_code [,dotest_maxcond]])
dotest_file
Search along CALCPATH for dotest_file, which contains lines that
should evaluate to 1. Comment lines and empty lines are ignored.
Comment lines should use ## instead of the multi like /* ... */
because lines are evaluated one line at a time.
dotest_code
Assign the code number that is to be printed at the start of
each non-error line and after **** in each error line.
The default code number is 999.
dotest_maxcond
The maximum number of error conditions that may be detected.
An error condition is not a sign of a problem, in some cases
a line deliberately forces an error condition. A value of -1,
the default, implies a maximum of 2147483647.
Global variables and functions must be declared ahead of time because
the dotest scope of evaluation is a line at a time. For example:
read dotest.cal
read set8700.cal
dotest("set8700.line");
ellip.cal
efactor(iN, ia, B, force)
@@ -505,6 +537,58 @@ regress.cal
Errors are reported with '****' messages, or worse. :-)
screen.cal
up
CUU /* same as up */
down = CUD
CUD /* same as down */
forward
CUF /* same as forward */
back = CUB
CUB /* same as back */
save
SCP /* same as save */
restore
RCP /* same as restore */
cls
home
eraseline
off
bold
faint
italic
blink
rapidblink
reverse
concealed
/* Lowercase indicates foreground, uppercase background */
black
red
green
yellow
blue
magenta
cyan
white
Black
Red
Green
Yellow
Blue
Magenta
Cyan
White
Define ANSI control sequences providing (i.e., cursor movement, changing
foreground or background color, etc.) for VT100 terminals and terminal
window emulators (i.e., xterm, Apple OS/X Terminal, etc.) that support them.
For example:
read screen
print green:"This is green. ":red:"This is red.":black
seedrandom.cal
seedrandom(seed1, seed2, bitsize [,trials])
@@ -523,6 +607,24 @@ seedrandom.cal
Blum primes for the modulus.
set8700.cal
set8700_getA1() defined
set8700_getA2() defined
set8700_getvar() defined
set8700_f(set8700_x) defined
set8700_g(set8700_x) defined
Declare globals and define functions needed by dotest() (see
dotest.cal) to evaluate set8700.line a line at a time.
set8700.line
A line-by-line evaluation file for dotest() (see dotest.cal).
The set8700.cal file (and dotest.cal) should be read first.
solve.cal
solve(low, high, epsilon)
@@ -833,8 +935,8 @@ xx_print.cal
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.10 $
## @(#) $Id: README,v 29.10 2005/12/12 06:39:18 chongo Exp $
## @(#) $Revision: 29.12 $
## @(#) $Id: README,v 29.12 2006/05/21 04:41:09 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
##
## Under source code control: 1990/02/15 01:50:32

193
cal/dotest.cal Normal file
View File

@@ -0,0 +1,193 @@
/*
* dotest - test truth statements found in line tests of dotest_testline file
*
* This file was created by Ernest Bowen <ebowen at une dot edu dot au>
* and modified by Landon Curt Noll.
*
* This dotest_code has been placed in the public domain. Please do not
* copyright this dotest_code.
*
* ERNEST BOWEN AND LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
* NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: dotest.cal,v 29.2 2006/05/21 00:55:27 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/dotest.cal,v $
*
* This file is not covered under version 2.1 of the GNU LGPL.
*
* Under source dotest_code control: 2006/03/08 05:54:09
* File existed as early as: 2006
*/
/*
* dotest - perform tests from dotest_testline file
*
* given:
* dotest_file filename containing single test lines
* dotest_code regress.cal test number to use (def: 0)
* dotest_maxcond max error conditions allowed (def: <0 ==> 2^31-1)
*
* returns:
* number of line test failures
*
* NOTE: All variables used by the dotest() function start with "dotest_".
* The dotest_file and dotest_read should not use any variable
* that starts with "dotest_".
*/
define dotest(dotest_file, dotest_code = 0, dotest_maxcond = -1)
{
local dotest_f_file; /* open file containing test lines */
local dotest_testline; /* test line */
local dotest_testeval; /* eval value from dotest_testline test line */
local dotest_tmperrcnt; /* temp error count after line test */
local dotest_errcnt; /* total number of errors */
local dotest_failcnt; /* number of line tests failed */
local dotest_testnum; /* number of test lines evaluated */
local dotest_linenum; /* test line number */
local dotest_old_errmax; /* value of errmax() prior to calling */
local dotest_old_errcount; /* value of errcount() prior to calling */
/*
* preserve calling stats
*/
dotest_old_errmax = errmax();
dotest_old_errcount = errcount(0);
/*
* initialize test accounting
*/
dotest_errcnt = errcount();
dotest_failcnt = 0;
dotest_testnum = 0;
dotest_linenum = 0;
/*
* setup error accounting for dotest
*/
if (dotest_maxcond >= 0 && dotest_maxcond < 2147483647) {
errmax(dotest_maxcond + dotest_old_errcount + 1),;
} else {
errmax(2147483647),;
}
/*
* open the test line file
*/
printf("%d-: opening line file: %d", dotest_code, dotest_file);
dotest_f_file = fpathopen(dotest_file, "r");
if (!isfile(dotest_f_file)) {
printf("**** Unable to file or open file \"%s\"\n",
dotest_file);
quit;
}
printf('%d: testing "%s"\n', dotest_code, dotest_file);
/*
* perform dotest_testline test on each line of the file
*/
for (;;) {
/* get the next test line */
dotest_testline = fgets(dotest_f_file);
++dotest_linenum;
if (iserror(dotest_testline)) {
quit "**** Error while reading file";
} else if (isnull(dotest_testline)) {
/* EOF - end of test file */
break;
}
/* skip empty lines */
if (dotest_testline == "\n") {
continue;
}
/* evaluate the test line */
dotest_testeval = eval(dotest_testline);
/* ignore white space or comment lines */
if (isnull(dotest_testeval)) {
continue;
}
/* look for test line parse errors */
if (iserror(dotest_testeval)) {
printf("**** evaluation error: ");
++dotest_failcnt;
/* look for test line dotest_failcnt */
} else if (dotest_testeval != 1) {
printf("**** did not return 1: ");
++dotest_failcnt;
}
/* show the test line we just performed */
printf("%d-%d: %s", dotest_code, dotest_linenum, dotest_testline);
/* error accounting */
dotest_tmperrcnt = errcount() - dotest_errcnt;
if (dotest_tmperrcnt > 0) {
/* report any other errors */
if (dotest_tmperrcnt > 1) {
printf("%d-%d: NOTE: %d error conditions(s): %s\n",
dotest_code, dotest_linenum, dotest_tmperrcnt);
}
/* report the calc error string */
printf("%d-%d: NOTE: last error string: %s\n",
dotest_code, dotest_linenum, strerror());
/* new error count level */
dotest_errcnt = errcount();
if (dotest_maxcond >= 0 &&
dotest_old_errcount-dotest_errcnt > dotest_maxcond) {
printf("%d-%d: total error conditions: %d > %d\n",
dotest_code, dotest_linenum,
dotest_maxcond, dotest_old_errcount-dotest_errcnt);
}
}
}
/*
* test the close of the line file
*/
printf("%d-: detected %d error condition(s), many of which may be OK\n",
dotest_code, dotest_old_errcount-dotest_errcnt);
printf("%d-: closing line file: %d\n", dotest_code, dotest_file);
fclose(dotest_f_file);
/*
* test line file accounting
*/
if (dotest_failcnt > 0) {
printf("**** %d-: %d test failure(s) in %d line(s)\n",
dotest_code, dotest_failcnt, dotest_linenum);
} else {
printf("%d-: no failure(s) in %d line(s)\n",
dotest_code, dotest_linenum);
}
/*
* preppare to return to the caller environment
*
* We increase the caller's error count by the number
* of line tests that failed, not the number of internal
* errors that were noted.
*/
errmax(dotest_old_errmax),;
errcount(dotest_old_errcount + dotest_failcnt),;
/*
* All Done!!! -- Jessica Noll, Age 2
*/
return dotest_failcnt;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: ellip.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: ellip.cal,v 29.3 2006/03/07 22:16:25 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/ellip.cal,v $
*
* Under source code control: 1990/02/15 01:50:33
@@ -141,7 +141,7 @@ define point_mul(p1, p2)
if (p2 == 1)
return p1;
if (p1 == p2)
return point_square(&p1);
return point_square(`p1);
obj point r;
m = (minv(p2.x - p1.x, N) * (p2.y - p1.y)) % N;
if (m == 0) {
@@ -185,9 +185,9 @@ define point_pow(p, pow)
r = p;
t = p;
for (bit = 2; ((bit <= pow) && (f == 0)); bit <<= 1) {
t = point_square(&t);
t = point_square(`t);
if (bit & pow)
r = point_mul(&t, &r);
r = point_mul(`t, `r);
}
return r;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: natnumset.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: natnumset.cal,v 29.3 2006/05/01 19:19:46 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/natnumset.cal,v $
*
* Under source code control: 1997/09/07 23:53:51
@@ -471,7 +471,7 @@ define set_plus(a) = set_sum(a);
define interval(a, b)
{
local i, j, s;
static tail = str("\0\1\3\7\17\37\77\177\377");
static tail = "\0\1\3\7\17\37\77\177\377";
if (!isint(a) || !isint(b))
quit "Non-integer argument for interval";

View File

@@ -1,7 +1,7 @@
/*
* regress - calc regression and correctness test suite
*
* Copyright (C) 1999-2004 David I. Bell and Landon Curt Noll
* Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
*
* Calc is open software; you can redistribute it and/or modify it under
* the terms of the version 2.1 of the GNU Lesser General Public License
@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.20 $
* @(#) $Id: regress.cal,v 29.20 2004/10/22 23:51:26 chongo Exp $
* @(#) $Revision: 29.25 $
* @(#) $Id: regress.cal,v 29.25 2006/05/21 00:58:31 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -1310,9 +1310,14 @@ define test_functions()
* verify sleep
*/
vrfy(sleep(1/5) == null(), '1153: sleep(1/5) == null()');
vrfy(sleep(1) == null(), '1154: sleep(1) == null()');
vrfy(sleep(1/100) == null(), '1154: sleep(1/100) == null()');
print '1155: Ending test_functions';
/*
* verify calcpath
*/
vrfy(isstr(calcpath()), '1155: isstr(calcpath())');
print '1156: Ending test_functions';
}
print '017: parsed test_functions()';
@@ -2595,6 +2600,22 @@ define test_2600()
strcat(str(tnum++), ': ln(exp(6)^15) == 90'));
vrfy(ln(exp(5)^18) == 90,
strcat(str(tnum++), ': ln(exp(5)^18) == 90'));
vrfy(log(1e6) == 6,
strcat(str(tnum++), ': log(1e6)) == 6'));
vrfy(log(1) == 0,
strcat(str(tnum++), ': log(1)) == 0'));
vrfy(log(100) == 2,
strcat(str(tnum++), ': log(100)) == 2'));
vrfy(log(1e66) == 66,
strcat(str(tnum++), ': log(1e66)) == 66'));
vrfy(log(1e127) == 127,
strcat(str(tnum++), ': log(1e127)) == 127'));
vrfy(round(log(17^47),10) == 57.8310993048,
strcat(str(tnum++),
': round(log(17^47),10) == 57.8310993048'));
vrfy(round(log(127),10) == 2.103803721,
strcat(str(tnum++),
': round(log(127),10) == 2.103803721'));
epsilon(i),;
print tnum++: ': epsilon(i),;';
@@ -3383,7 +3404,7 @@ print '070: parsed test_redc()';
*/
define test_fileops()
{
local a, b, c, f, m, n, x, y, z;
local a, b, c, f, m, n, p, r, x, y, z;
local L = "Landon";
local C = "Curt";
local N = "Noll";
@@ -3485,13 +3506,21 @@ define test_fileops()
vrfy(y == "Noll", '4258: y == "Noll"');
vrfy(isnull(fclose(f)), '4259: isnull(fclose(f))');
/*
* fpathopen tests
*/
vrfy(!iserror(p=fpathopen("junk4200","r",".")),
'4260: !iserror(p=fparhopen("junk4200","r","."))');
vrfy(!iserror(r=fpathopen("regress.cal","r")),
'4261: !iserror(r=fparhopen("regress.cal","r","."))');
/*
* cleanup
*/
x = rm("junk4200");
print '4260: x = rm("junk4200")';
print '4262: x = rm("junk4200")';
print '4261: Ending test_fileops';
print '4263: Ending test_fileops';
}
print '071: parsed test_fileops()';
@@ -5115,7 +5144,7 @@ define test_assign(base, work)
Y5800 = base+4;
print base+4: ': Y5800 = base+4';
obj xy5800 A={1,2}, obj xy5800 B={3,4};
print base+5: ': obj xy5800 A={1,2}, obj xy5000 B={3,4}';
print base+5: ': obj xy5800 A={1,2}, obj xy5800 B={3,4}';
/*
* test assignment
@@ -5238,7 +5267,7 @@ define test_is()
prime = 3217;
print '5922: prime = 3217';
square = prime^2;
print '5923: square = prine^2';
print '5923: square = prime^2';
string = "a string";
print '5924: string = "a string"';
com = 3+4i;
@@ -6237,7 +6266,7 @@ define test_blk()
/* A second named block */
B1 = blk("+++6700", 15, 10) = {1,2,3,4,5};
print '6746: B1 = blk("+++6700", , 10);';
print '6746: B1 = blk("+++6700", 15 , 10) = {1,2,3,4,5};';
vrfy(size(B1) == 15, '6747: size(B1) == 15');
vrfy(sizeof(B1) == 20, '6748: sizeof(B1) == 20');
vrfy(test(B1) == 1, '6749: test(B1) == 1');
@@ -7339,7 +7368,7 @@ define test_somenew()
vrfy(size(char(0)) == 1, '8203: size(char(0)) == 1');
vrfy(strlen(char(0)) == 0, '8204: strlen(char(0)) == 0');
vrfy(char(0) != "", '8205: char(0) != ""');
vrfy(strcmp(char(0),"") == 0, '8206: strcmp(char(0),"") == 0');
vrfy(str(char(0)) == "", '8206: str(char(0)) == ""');
vrfy(str("abc") == "abc", '8207: str("abc") == "abc"');
@@ -7696,20 +7725,34 @@ print '8406: Ending test_quit';
* test_divmod - psuedo-random tests on the // and % with various rounding modes
*/
print;
print '8500: Starting test_divmod'
print '8500: Starting test of divmod'
read -once "test8500";
/* 85xx: Ending test_divmod is printed by test8500.cal */
/* 85xx: Ending test of divmod is printed by test8500.cal */
/*
* test_maxargs - test up to 1024 args being passed to a builtin function
*/
print;
print '8600: Starting test_1024args'
print '8600: Starting test of up to 1024 args'
read -once "test8600";
/* 86xx: Ending test_1024args is printed by test8600.cal */
/* 86xx: Ending test of up to 1024 args is printed by test8600.cal */
/*
* dotest scripts
*
* We use the dotest driver to evaluate test-97xx data files.
*/
print '8700: Starting dotest runs'
print '8701: read -once "dotest"';
read -once "dotest";
print '8702: read -once "set8700"';
read -once "set8700";
vrfy(dotest("set8700.line", 8703) == 0,
'8703: dotest("set8700.line", 8703) == 0');
/* 87xx: Ending dotest runs is printed by set8700.test */
/*
* read various calc resource files
*

61
cal/screen.cal Normal file
View File

@@ -0,0 +1,61 @@
/*
* screen - ANSI control sequences
*
* This file was created by Ernest Bowen <ebowen at une dot edu dot au>.
*
* This code has been placed in the public domain. Please do not
* copyright this code.
*
* ERNEST BOWEN DISCLAIMS ALL WARRANTIES WITH REGARD TO
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER-
* CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT
* NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: screen.cal,v 29.2 2006/05/01 19:21:18 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/screen.cal,v $
*
* This file is not covered under version 2.1 of the GNU LGPL.
*
* Under source code control: 2006/03/08 05:54:09
* File existed as early as: 2006
*/
up = CUU ="\e[A";
down = CUD = "\e[B}";
forward = CUF = "\e[C";
back = CUB = "\e[D";
save = SCP = "\e[s";
restore = RCP = "\e[u";
cls = "\e[2J";
home = "\e[F";
eraseline = "\e[K";
off = "\e[0m";
bold = "\e[1m";
faint = "\e[2m";
italic = "\e[3m";
blink = "\e[5m";
rapidblink = "\e[6m";
reverse = "\e[7m";
concealed = "\e[8m";
/* Lowercase indicates foreground, uppercase background" */
black = "\e[30m";
red = "\e[31m";
green = "\e[32m";
yellow = "\e[33m";
blue = "\e[34m";
magenta = "\e[35m";
cyan = "\e[36m";
white = "\e[37m";
Black = "\e[40m";
Red = "\e[41m";
Green = "\e[42m";
Yellow = "\e[43m";
Blue = "\e[44m";
Magenta = "\e[45m";
Cyan = "\e[46m";
White = "\e[47m";

72
cal/set8700.cal Normal file
View File

@@ -0,0 +1,72 @@
/*
* set8700 - environment for dotest line tests for the 8700 set of regress.cal
*
* Copyright (C) 2006 Ernest Bowen and Landon Curt Noll
*
* Calc is open software; you can redistribute it and/or modify it under
* the terms of the version 2.1 of the GNU Lesser General Public License
* as published by the Free Software Foundation.
*
* Calc is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
* Public License for more details.
*
* A copy of version 2.1 of the GNU Lesser General Public License is
* distributed with calc under the filename COPYING-LGPL. You should have
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.1 $
* @(#) $Id: set8700.cal,v 29.1 2006/05/20 19:35:33 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.cal,v $
*
* Under source code control: 2006/05/20 14:10:11
* File existed as early as: 2006
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* setup global variables for dotest() to use with set8700.set
*/
global set8700_A;
global set8700_B;
global set8700_M;
global set8700_M1;
global set8700_M2;
global set8700_L;
global set8700_L1;
global set8700_L2;
global set8700_O;
global set8700_P;
global set8700_P1;
global set8700_P2;
global set8700_Q;
global set8700_R;
global set8700_S;
global set8700_X;
global set8700_Y;
global set8700_x;
global set8700_y;
define set8700_getA1() = set8700_A;
define set8700_getA2() { return set8700_A; }
define set8700_getvar() {local a = 42; protect(a,256); return a;}
define set8700_f(set8700_x) = set8700_x^2;
define set8700_g(set8700_x)
{
if (isodd(set8700_x)) protect(set8700_x, 256);
return set8700_x;
}
obj set8700_point {
set8700_x, set8700_y, set8700_z
}

405
cal/set8700.line Normal file
View File

@@ -0,0 +1,405 @@
##
## set8700 - dotest line tests for the 8700 set of regress.cal
##
## Copyright (C) 2006 Ernest Bowen and Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: set8700.line,v 29.1 2006/05/20 19:35:33 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
##
## Under source code control: 2006/05/20 14:10:11
## File existed as early as: 2006
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
strcpy("", "") == ""
strcpy("", "xyz") == ""
strcpy("a", "xyz") == "x"
strcpy("ab", "xyz") == "xy"
strcpy("abc", "xyz") == "xyz"
strcpy("abcd", "xyz") == "xyz\0" ## Result will print as "xyz"
strcpy("abcde", "xyz") == "xyz\0e"
strcpy("abcdef", "xyz") == "xyz\0ef"
strcpy("abcdef", "x\0z") == "x\0z\0ef" ## Note z is copied
strcpy("abc", "") == "\0bc"
strncpy("abcdef", "xyz", 0) == "abcdef" ## No characters copied
strncpy("abcdef", "xyz", 1) == "xbcdef" ## One character copied, no '\0'
strncpy("abcdef", "xyz", 2) == "xycdef"
strncpy("abcdef", "xyz", 3) == "xyzdef"
strncpy("abcdef", "xyz", 4) == "xyz\0ef"
strncpy("abcdef", "xyz", 5) == "xyz\0\0f" ## Two nulls as in C
strncpy("abcdef", "xyz", 6) == "xyz\0\0\0"
strncpy("abcdef", "xyz", 7) == "xyz\0\0\0" ## Size of first string unchanged
strncpy("a\0cdef", "\0yz", 4) == "\0yz\0ef"
strncpy("ab", "xyz", 3) == "xy"
strcmp("", "") == 0
strcmp("", "a") == -1
strcmp("\n", "\n") == 0
strcmp("\0", "") == 1 ## '\0' treated like other characters
strcmp("ab", "") == 1
strcmp("ab", "a") == 1
strcmp("ab", "ab") == 0
strcmp("ab", "abc") == -1
strcmp("abc", "abb") == 1
strcmp("abc", "abc") == 0
strcmp("abc", "abd") == -1
strcmp("abc\0", "abc") == 1
strncmp("abc", "xyz", 0) == 0
strncmp("abc", "xyz", 1) == -1
strncmp("abc", "", 1) == 1
strncmp("abc", "a", 1) == 0
strncmp("", "", 2) == 0
strncmp("a", "a", 2) == 0
strncmp("a", "b", 2) == -1
strncmp("ab", "ab", 2) == 0
strncmp("ab", "ac", 2) == -1
strncmp("\0ac", "\0b", 2) == -1
strncmp("ab", "abc", 2) == 0
strncmp("abc", "abd", 2) == 0
strncmp("a", "a\0", 2) == -1
strncmp("a", "a", 3) == 0
strncmp("abc", "abd", 3) == -1
strncmp("\0\0\n", "\0\0\t", 3) == 1
str("abc") == "abc"
str("ab\0") == "ab"
str("a\0c") == "a"
str("\0bc") == ""
size("") == 0
size("a") == 1
size("\0") == 1
size("a\0") == 2
size("a\0b") == 3
strlen("\0") == 0
strlen("a\0") == 1
strlen("a\0b") == 1
0 * "abc" == ""
1 * "abc" == "abc"
2 * "abc" == "abcabc"
3 * "abc" == "abcabcabc"
1 * "" == ""
-1 * "abc" == "cba"
-2 * "abc" == "cbacba"
"abc" + "xyz" == "abcxyz"
"abc" - "xyz" == "abczyx"
substr("abcd",0,0) == ""
substr("abcd",0,1) == "a"
substr("abcd",0,2) == "ab"
substr("abcd",1,0) == ""
substr("abcd",1,1) == "a"
substr("abcd",1,2) == "ab"
substr("abcd",2,0) == ""
substr("abcd",2,1) == "b"
substr("abcd",2,2) == "bc";
substr("abcd",2,3) == "bcd";
substr("abcd",2,4) == "bcd";
substr("abcd",2,5) == "bcd"; ## substr stops at end of string
substr("abcd",4,0) == ""
substr("abcd",4,1) == "d"
substr("abcd",4,2) == "d"
substr("abcd",4,3) == "d"
substr("abcd",5,0) == ""
substr("abcd",5,1) == ""
substr("a\0c\0",2,2) == "\0c" ## '\0' treated like other characters
substr("a\0c\0",2,3) == "\0c\0"
#"" == 0 ## # operator counts number of bits
#"\0" == 0
# "a" == 3
# "ab" == 6 ## white space ignored
# "abc" == 10
# 27 == 4
# 0b1010111011 == 7
7 # 9 == 2 ## 7 # 9 = abs(7 - 9)
3/4 # 2/3 == 1/12
a = 5, a #= 2, a == 3
a #= 4, a == 1
## Binary # operator not defined for strings
global set8700_A; protect(set8700_A) == 0
## Testing with one lvalue
isnull(protect(set8700_A,65))
protect(set8700_A) == 65
isnull(protect(set8700_A, -1))
protect(set8700_A) == 64
protect(set8700_A,-2), protect(set8700_A) == 64
protect(set8700_A,5), protect(set8700_A) == 69
protect(set8700_A,-4), protect(set8700_A) == 65
protect(set8700_A,0), protect(set8700_A) == 0
protect(set8700_A,1234), protect(set8700_A) == 1234
protect(set8700_A,-1234), protect(set8700_A) == 0
protect(set8700_A,65535), protect(set8700_A) == 65535
protect(set8700_A,-65535), protect(set8700_A) == 0
## Simple assignments
set8700_A = 42, protect(set8700_A,1024), set8700_B = set8700_A, protect(set8700_B) == 1024
set8700_A = 6 * 7, protect(set8700_A) == 1024
set8700_A == set8700_B
## Testing matrix protectioon
set8700_A = mat [3] = {1, 2, list(3,4)}; 1
protect(set8700_A, 65, 1), protect(set8700_A) == 1089
protect(set8700_A[0]) == 65
protect(set8700_A[2]) == 65
protect(set8700_A[2][1]) == 0
protect(set8700_A, 65, 2), protect(set8700_A[2][1]) == 65
protect(set8700_A,-1024), protect(set8700_A) == 65
protect(set8700_A, -1, 1), protect(set8700_A) == 64
protect(set8700_A[1]) == 64
protect(set8700_A[2]) == 64
protect(set8700_A[2][0]) == 65
protect(set8700_A,0), protect(set8700_A) == 0
protect(set8700_A[1]) == 64
protect(set8700_A, 0, 2), protect(set8700_A) == 0
protect(set8700_A[1]) == 0
protect(set8700_A[2][1]) == 0
protect(set8700_A,1024, 2), protect(set8700_A) == 1024
protect(set8700_A[2]) == 1024
protect(set8700_A[2][0], 512), protect(set8700_A[2][0]) == 1536
## Testing simple assignment of matrix
set8700_B = set8700_A, protect(set8700_B) == 1024 ## protect(set8700_A) copied
protect(set8700_B[2]) == 1024 ## protect(set8700_A[2]) copied
protect(set8700_B[2][0]) == 1536 ## protect(set8700_A[2][0]) copied
## copying matrix to list
set8700_B = list(5,6,7), protect(set8700_B) == 1024
protect(set8700_B[0]) == 0
protect(set8700_B[2]) == 0
protect(set8700_A,0), protect(set8700_A) == 0
copy(set8700_A,set8700_B), set8700_B[0] == 1 && set8700_B[1] == 2
set8700_B[2] == list(3,4)
protect(set8700_B) == 1024 ## protect(set8700_A) not copied
protect(set8700_B[0]) == 1024 ## protect(set8700_A[0]) copied
protect(set8700_B[2][0]) == 1536 ## protect(set8700_A[2][0]) copied
## copying matrix to matrix
set8700_B = mat[3], protect(set8700_B) == 1024
protect(set8700_B[2]) == 0
copy(set8700_A,set8700_B), set8700_B[0] == 1 && set8700_B[1] == 2
set8700_B[2] == list(3,4)
protect(set8700_B) == 1024 ## protect(set8700_A) not copied
protect(set8700_B[0]) == 1024 ## protect(set8700_A[0]) copied
protect(set8700_B[2][0]) == 1536 ## protect(set8700_A[2][0]) copied
## Testing list protection
set8700_A = list(1, 2, list(3,4)), 1
protect(set8700_A,1024, 2), protect(set8700_A) == 1024
protect(set8700_A[2]) == 1024
protect(set8700_A[2][0], 512), protect(set8700_A[2][0]) == 1536
## Simple assignment of list
set8700_B = set8700_A, protect(set8700_B) == 1024 ## protect(set8700_A) copied
protect(set8700_B[2]) == 1024 ## protect(set8700_A[2]) copied
protect(set8700_B[2][0]) == 1536 ## protect(set8700_A[2][0]) copied
## Copying list to list
set8700_B = list(5,6,7), protect(set8700_B) == 1024
protect(set8700_B[2]) == 0
copy(set8700_A,set8700_B), set8700_B[0] == 1 && set8700_B[1] == 2
set8700_B[2] == list(3,4)
protect(set8700_B) == 1024 ## protect(set8700_A) not copied
protect(set8700_B[0]) == 1024 ## protect(set8700_A[0]) copied
protect(set8700_B[2][0]) == 1536 ## protect(set8700_A[2][0]) copied
## Copying list to matrix
set8700_B = mat[3], protect(set8700_B) == 1024
protect(set8700_B[2]) == 0
copy(set8700_A,set8700_B), set8700_B[0] == 1 && set8700_B[1] == 2
set8700_B[2] == list(3,4)
protect(set8700_B) == 1024
protect(set8700_B[0]) == 1024 ## protect(set8700_A[0]) copied
protect(set8700_B[2][0]) == 1536 ## protect(set8700_A[2][0]) copied
## Protecting one element of a list
set8700_A = list(1,4,3,2), protect(set8700_A[1]) == 0
protect(set8700_A[1], 1024), protect(set8700_A[1]) == 1024
## Testing sort
set8700_A = sort(set8700_A), set8700_A == list(1,2,3,4)
protect(set8700_A[1]) == 0
protect(set8700_A[3]) == 1024 ## status of 4
## Testings reverse
set8700_A = reverse(set8700_A), set8700_A == list(4,3,2,1)
protect(set8700_A[0]) == 1024 ## status of 4
## Testing swap
swap(set8700_A[0], set8700_A[1]), set8700_A == list(3,4,2,1)
protect(set8700_A[0]) == 0 ## status moved
protect(set8700_A[1]) == 1024 ## 4 retains protection
## Testing list with protected list argument
protect(set8700_A, 0), protect(set8700_A) == 0
protect(set8700_A, 512), protect(set8700_A) == 512
protect(set8700_A[1]) == 1024
set8700_L = list(1,set8700_A,3), protect(set8700_L) == 0
protect(set8700_L[0]) == 0
protect(set8700_L[1]) == 512 ## protect(set8700_A) copied
protect(set8700_L[1][1]) == 1024 ## protect(set8700_A[1]) copied
## Testing list with "intialization"
set8700_L = list(1,2,3), protect(set8700_L) == 0
protect(set8700_L[0]) | protect(set8700_L[1]) | protect(set8700_L[2]) == 0 ## All zero
set8700_L = {1,set8700_A}, set8700_L[1] == set8700_A
protect(set8700_L[1]) == 512 ## protect(set8700_A) copied
protect(set8700_L[1][1]) == 1024 ## protect(set8700_A[1]) copied
set8700_L[1] = 2, protect(set8700_L[1]) == 512 ## Not changed
## Testing matrix with "initialization"
set8700_M = mat[3] = {1,set8700_A}, protect(set8700_M) == 0
protect(set8700_M[0]) == 0
protect(set8700_M[1]) == 512 ## protect(set8700_A) copied
protect(set8700_M[2]) == 0
protect(set8700_M[1][1]) == 1024 ## protect(set8700_A[1]) copied
## Testing push, pop, append, remove
set8700_A = list(1,2), protect(set8700_A,0,1), protect(set8700_A[0]) == 0
protect(set8700_A[0], 256), protect(set8700_A[0]) == 256
protect(set8700_A[1]) == 0
append(set8700_A, pop(set8700_A)), protect(set8700_A[0]) == 0
protect(set8700_A[1]) == 256
push(set8700_A, remove(set8700_A)), protect(set8700_A[0]) == 256
protect(set8700_A[1]) == 0
## Testing operation-assignments
set8700_A = 5, protect(set8700_A,1024), protect(set8700_A) == 1024
protect(set8700_A, 1024), set8700_A = 7, protect(set8700_A) == 1024
protect(set8700_A,1024), set8700_A += 2, protect(set8700_A) == 1024
protect(set8700_A,1024), set8700_A *= 2, protect(set8700_A) == 1024
protect(set8700_A,1024), set8700_A |= 2, protect(set8700_A) == 1024
protect(set8700_A,1024), set8700_A &= 2, protect(set8700_A) == 1024
protect(set8700_A,1024), set8700_A ^= 2, protect(set8700_A) == 1024
protect(set8700_B,0), set8700_B = set8700_getA1(), protect(set8700_B) == 1024
protect(set8700_B,0), set8700_B = set8700_getA2(), protect(set8700_B) == 1024
set8700_B = set8700_getvar(), protect(set8700_B) == 1024 + 256
global set8700_x, set8700_y; set8700_x = 7, protect(set8700_x) == 0
protect(7,2) == error(10234)
protect(set8700_x,2.5) == error(10235)
protect(set8700_x,"abc") == error(10235)
protect(set8700_x, 1e6) == error(10235)
protect(set8700_x,1), (set8700_x = 2) == error(10366)
(set8700_x = 3 + 4) == error(10366)
protect(set8700_x,2), protect(set8700_x) == 3
protect(set8700_x,-1), protect(set8700_x) == 2
(set8700_x = 2) == error(10368)
(set8700_x = 3 + 4) == 7
protect(set8700_x,2), ++set8700_x == error(10379)
set8700_x == 7
--set8700_x == error(10382)
set8700_x == 7
set8700_x++ == error(10385)
set8700_x == 7
set8700_x-- == error(10388)
global set8700_A, set8700_B; 1
protect(set8700_A,0), protect(set8700_A,16), 1
set8700_A = "abcdef", protect(set8700_A) == 16 ## No copy to set8700_A
protect(set8700_B,0), set8700_B = "xyz", protect(set8700_B) == 0
copy(set8700_B, set8700_A) == error(10226)
set8700_A == "abcdef" ## set8700_A not changed
protect(set8700_A,0), copy(set8700_B,set8700_A), set8700_A == "xyzdef"
protect(set8700_B,128), protect(set8700_B) == 128 ## No copy from set8700_B
copy(set8700_B,set8700_A,,,3) == error(10225)
set8700_A == "xyzdef"
protect(set8700_B,0), copy(set8700_B,set8700_A,,,3), set8700_A == "xyzxyz"
set8700_A = "abcdef", protect(set8700_A, 16), swap(set8700_A[0], set8700_A[5]) == error(10371)
set8700_A == "abcdef"
protect(set8700_A,0), isnull(swap(set8700_A[0], set8700_A[5]))
set8700_A == "fbcdea"
protect(set8700_A,2), ++set8700_A[0] == error(10377)
--set8700_A[1] == error(10380)
set8700_A[2]++ == error(10383)
set8700_A[3]-- == error(10386)
set8700_A == "fbcdea"
protect(set8700_A,0), ++set8700_A[0] == 'g'
--set8700_A[1] == 'a'
set8700_A[2]++ == ord('c')
set8700_A[3]-- == ord('d')
set8700_A == "gadcea"
protect(set8700_x,0), protect(set8700_y,0), protect(set8700_x,256), protect(set8700_y,512),1
quomod(11,4,set8700_x,set8700_y), set8700_x == 2 && set8700_y == 3
protect(set8700_x) == 256
protect(set8700_y) == 512
set8700_A = mat[3]; protect(set8700_A[0], 1024); protect(set8700_A[0]) == 1024
set8700_x = 7, protect(set8700_x,0), protect(set8700_x, 512), 1
set8700_A = {set8700_x,,set8700_x}, protect(set8700_A[0]) == 1536
protect(set8700_A[1]) == 0
protect(set8700_A[2]) == 512
protect(set8700_A,16), protect(set8700_A) == 16 ## No copy to
set8700_A == (mat[3] = {7,0,7})
set8700_A = {1,2,3}, errno() == 10390;
set8700_A == (mat[3] = {7,0,7})
protect(set8700_A,0), set8700_A = {1,2,3}, set8700_A == (mat[3] = {1,2,3})
protect(set8700_A[1],1), protect(set8700_A[1]) == 1
set8700_A = {4,5,6}, errno() == 10394
set8700_A == (mat[3] = {4,2,6})
modify(7, "set8700_f") == error(10405)
set8700_A = list(2,3,5), modify(set8700_A, 7) == error(10406)
protect(set8700_A,2), modify(set8700_A, "set8700_f") == error(10407)
protect(set8700_A,0), modify(set8700_A, "h") == error(10408)
set8700_B = 42, protect(set8700_B,0), modify(set8700_B, "set8700_f") == error(10409)
set8700_A == list(2,3,5) ## set8700_A not affected by failures
protect(set8700_A,0,1), modify(set8700_A, "set8700_f") == null()
set8700_A == list(4,9,25)
modify(set8700_A,"set8700_g") == null()
protect(set8700_A[0]) == 0
protect(set8700_A[1]) == 256 && protect(set8700_A[2]) == 256
set8700_A = 0, protect(set8700_A,0), set8700_A = pop(2), set8700_A == error(10181)
set8700_A = pop(list(1,2,3)), set8700_A == error(10181)
set8700_B = set8700_A = pop(2), set8700_B == error(10181)
set8700_A = 32, protect(set8700_A,8), (set8700_A = pop(2)) == error(10370)
set8700_A == 32
set8700_B = set8700_A = pop(2), set8700_B == error(10370)
## Testing copying of protected elements and initialization
set8700_M1 = mat[3], protect(set8700_M1,0), protect(set8700_M1[1],1), protect(set8700_M1[1]) == 1
set8700_M2 = mat[3], protect(set8700_M2,0), protect(set8700_M2[2],4), protect(set8700_M2[2]) == 4
set8700_L = list(set8700_M1, set8700_M2), protect(set8700_L[0][1]) == 1 && protect(set8700_L[1][2]) == 4
set8700_L = {{1,2,3},{'a','b','c'}}, set8700_L[0] == (mat[3] = {1,0,3})
set8700_L[1] == (mat[3] = {'a','b',0})
set8700_M = mat[2], protect(set8700_M,0), set8700_M = {1,2,3,4}, set8700_M == (mat[2] = {1,2})
set8700_x = 5, set8700_M = {set8700_x++, set8700_x++, set8700_x++, set8700_x++, set8700_x++}, set8700_M == (mat[2] = {5,6})
set8700_x == 10 ## All initialization terms evaluated
set8700_S = " ", set8700_S = {'a','b','c','d'}, set8700_S == "abc"
set8700_P = obj set8700_point = {1,2,3,4}, set8700_P.set8700_x == 1 && set8700_P.set8700_y == 2 && set8700_P.set8700_z == 3
protect(set8700_P,16), set8700_Q = set8700_P, set8700_Q = {5,6,7}, set8700_Q == set8700_P
set8700_P == (obj set8700_point = {1,2,3})
set8700_L = list(mat[1] = {set8700_P}), protect(set8700_L[0][0]) == 16
set8700_L = {{{4,5,6}}}, set8700_L[0][0] == set8700_P
protect(set8700_L,0,2), set8700_L = {{{4,5,6}}}, set8700_L[0][0] == (obj set8700_point = {4,5,6})