summaryrefslogtreecommitdiff
path: root/tests/general
diff options
context:
space:
mode:
Diffstat (limited to 'tests/general')
-rw-r--r--tests/general/Makefile48
-rwxr-xr-xtests/general/Test-icon76
-rwxr-xr-xtests/general/Test-opts79
-rw-r--r--tests/general/args.icn96
-rw-r--r--tests/general/args.std447
-rw-r--r--tests/general/arith.icn131
-rw-r--r--tests/general/arith.std149
-rw-r--r--tests/general/augment.icn181
-rw-r--r--tests/general/augment.std127
-rw-r--r--tests/general/btrees.dat3
-rw-r--r--tests/general/btrees.icn43
-rw-r--r--tests/general/btrees.std30
-rw-r--r--tests/general/case.icn34
-rw-r--r--tests/general/case.std24
-rw-r--r--tests/general/center.icn22
-rw-r--r--tests/general/center.std18
-rw-r--r--tests/general/cfuncs.icn33
-rw-r--r--tests/general/cfuncs.std18
-rw-r--r--tests/general/checkc.icn188
-rw-r--r--tests/general/checkc.std129
-rw-r--r--tests/general/checkfpc.icn127
-rw-r--r--tests/general/checkfpc.std283
-rw-r--r--tests/general/checkfpx.icn127
-rw-r--r--tests/general/checkfpx.std283
-rw-r--r--tests/general/checkx.icn182
-rw-r--r--tests/general/checkx.std129
-rw-r--r--tests/general/ck.icn190
-rw-r--r--tests/general/ck.std144
-rw-r--r--tests/general/coerce.icn67
-rw-r--r--tests/general/coerce.std54
-rw-r--r--tests/general/coexpr.icn72
-rw-r--r--tests/general/coexpr.std76
-rw-r--r--tests/general/collate.icn78
-rw-r--r--tests/general/collate.std124
-rw-r--r--tests/general/concord.dat17
-rw-r--r--tests/general/concord.icn31
-rw-r--r--tests/general/concord.std128
-rw-r--r--tests/general/cset.icn85
-rw-r--r--tests/general/cset.std113
-rw-r--r--tests/general/cxprimes.icn20
-rw-r--r--tests/general/cxprimes.std25
-rw-r--r--tests/general/diffwrds.dat12
-rw-r--r--tests/general/diffwrds.icn14
-rw-r--r--tests/general/diffwrds.std26
-rw-r--r--tests/general/endetab.dat258
-rw-r--r--tests/general/endetab.icn145
-rw-r--r--tests/general/endetab.std11
-rw-r--r--tests/general/env.icn14
-rw-r--r--tests/general/errkwds.icn25
-rw-r--r--tests/general/errkwds.std18
-rw-r--r--tests/general/errors.icn203
-rw-r--r--tests/general/errors.std533
-rw-r--r--tests/general/evalx.icn233
-rw-r--r--tests/general/evalx.std304
-rw-r--r--tests/general/every.icn34
-rw-r--r--tests/general/every.std73
-rw-r--r--tests/general/fncs.icn185
-rw-r--r--tests/general/fncs.std455
-rw-r--r--tests/general/fncs1.icn72
-rw-r--r--tests/general/fncs1.std195
-rw-r--r--tests/general/gc1.icn18
-rw-r--r--tests/general/gc1.std4
-rw-r--r--tests/general/gc2.icn222
-rw-r--r--tests/general/gc2.std256
-rw-r--r--tests/general/gener.icn141
-rw-r--r--tests/general/gener.std42
-rw-r--r--tests/general/genqueen.icn100
-rw-r--r--tests/general/genqueen.std56
-rw-r--r--tests/general/hello.icn5
-rw-r--r--tests/general/ilib.icn396
-rw-r--r--tests/general/ilib.std277
-rw-r--r--tests/general/image.icn83
-rw-r--r--tests/general/image.std51
-rw-r--r--tests/general/io.dat13
-rw-r--r--tests/general/io.icn214
-rw-r--r--tests/general/io.std125
-rw-r--r--tests/general/kross.dat3
-rw-r--r--tests/general/kross.icn30
-rw-r--r--tests/general/kross.std159
-rw-r--r--tests/general/kwds.icn91
-rw-r--r--tests/general/kwds.std57
-rw-r--r--tests/general/large.icn37
-rw-r--r--tests/general/large.std299
-rw-r--r--tests/general/left.icn31
-rw-r--r--tests/general/left.std24
-rw-r--r--tests/general/level.icn21
-rw-r--r--tests/general/level.std16
-rw-r--r--tests/general/lexcmp.icn27
-rw-r--r--tests/general/lexcmp.std36
-rw-r--r--tests/general/lgint.icn218
-rw-r--r--tests/general/lgint.std413
-rw-r--r--tests/general/lists.icn89
-rw-r--r--tests/general/lists.std52
-rw-r--r--tests/general/map.icn14
-rw-r--r--tests/general/map.std10
-rw-r--r--tests/general/mathfunc.icn36
-rw-r--r--tests/general/mathfunc.std79
-rw-r--r--tests/general/meander.dat3
-rw-r--r--tests/general/meander.icn33
-rw-r--r--tests/general/meander.std3
-rw-r--r--tests/general/mffsol.dat6
-rw-r--r--tests/general/mffsol.icn114
-rw-r--r--tests/general/mffsol.std69
-rw-r--r--tests/general/mindfa.dat20
-rw-r--r--tests/general/mindfa.icn214
-rw-r--r--tests/general/mindfa.std400
-rw-r--r--tests/general/misc.icn128
-rw-r--r--tests/general/misc.std80
-rw-r--r--tests/general/nargs.icn98
-rw-r--r--tests/general/nargs.std85
-rw-r--r--tests/general/numeric.icn192
-rw-r--r--tests/general/numeric.std111
-rw-r--r--tests/general/options.ok20
-rw-r--r--tests/general/others.dat23
-rw-r--r--tests/general/others.icn98
-rw-r--r--tests/general/others.std183
-rw-r--r--tests/general/over.icn22
-rw-r--r--tests/general/over.std9
-rw-r--r--tests/general/parse.icn21
-rw-r--r--tests/general/parse.std11
-rw-r--r--tests/general/pdco.icn179
-rw-r--r--tests/general/pdco.std85
-rw-r--r--tests/general/prefix.dat8
-rw-r--r--tests/general/prefix.icn41
-rw-r--r--tests/general/prefix.std8
-rw-r--r--tests/general/prepro.dat7
-rw-r--r--tests/general/prepro.icn102
-rw-r--r--tests/general/prepro.std7
-rw-r--r--tests/general/primes.icn12
-rw-r--r--tests/general/primes.std25
-rw-r--r--tests/general/proto.icn156
-rw-r--r--tests/general/proto.std0
-rw-r--r--tests/general/queens.icn98
-rw-r--r--tests/general/queens.std61
-rw-r--r--tests/general/random.icn59
-rw-r--r--tests/general/random.std65
-rw-r--r--tests/general/recent.icn291
-rw-r--r--tests/general/recent.std443
-rw-r--r--tests/general/recogn.dat8
-rw-r--r--tests/general/recogn.icn28
-rw-r--r--tests/general/recogn.std8
-rw-r--r--tests/general/record.icn43
-rw-r--r--tests/general/record.std15
-rw-r--r--tests/general/right.icn31
-rw-r--r--tests/general/right.std24
-rw-r--r--tests/general/roman.dat8
-rw-r--r--tests/general/roman.icn23
-rw-r--r--tests/general/roman.std8
-rw-r--r--tests/general/scan.icn59
-rw-r--r--tests/general/scan.std133
-rw-r--r--tests/general/scan1.icn84
-rw-r--r--tests/general/scan1.std79
-rw-r--r--tests/general/scan2.icn51
-rw-r--r--tests/general/scan2.std45
-rw-r--r--tests/general/sets.icn81
-rw-r--r--tests/general/sets.std43
-rw-r--r--tests/general/sieve.icn20
-rw-r--r--tests/general/sieve.std27
-rw-r--r--tests/general/sorting.icn234
-rw-r--r--tests/general/sorting.std503
-rw-r--r--tests/general/statics.icn26
-rw-r--r--tests/general/statics.std4
-rw-r--r--tests/general/string.icn128
-rw-r--r--tests/general/string.std215
-rw-r--r--tests/general/string1.icn54
-rw-r--r--tests/general/string1.std37
-rw-r--r--tests/general/struct.icn202
-rw-r--r--tests/general/struct.std359
-rw-r--r--tests/general/subjpos.icn82
-rw-r--r--tests/general/subjpos.std62
-rw-r--r--tests/general/substring.icn65
-rw-r--r--tests/general/substring.std368
-rw-r--r--tests/general/table.icn97
-rw-r--r--tests/general/table.std18
-rw-r--r--tests/general/tpp.icn315
-rw-r--r--tests/general/tpp.ok565
-rw-r--r--tests/general/tpp1.icn4
-rw-r--r--tests/general/tpp2.icn4
-rw-r--r--tests/general/tpp3.icn4
-rw-r--r--tests/general/tpp4.icn62
-rw-r--r--tests/general/tpp5.icn12
-rw-r--r--tests/general/tpp9.icn8
-rw-r--r--tests/general/tracer.icn30
-rw-r--r--tests/general/tracer.std85
-rw-r--r--tests/general/transmit.dat4
-rw-r--r--tests/general/transmit.icn29
-rw-r--r--tests/general/transmit.std104
-rw-r--r--tests/general/trim.icn14
-rw-r--r--tests/general/trim.std10
-rw-r--r--tests/general/var.icn69
-rw-r--r--tests/general/var.std114
-rw-r--r--tests/general/wordcnt.dat23
-rw-r--r--tests/general/wordcnt.icn24
-rw-r--r--tests/general/wordcnt.std53
194 files changed, 19181 insertions, 0 deletions
diff --git a/tests/general/Makefile b/tests/general/Makefile
new file mode 100644
index 0000000..56da471
--- /dev/null
+++ b/tests/general/Makefile
@@ -0,0 +1,48 @@
+# Makefile for testing Icon
+
+
+SAMPLES = btrees diffwrds kross meander prefix recogn roman sieve wordcnt
+
+
+
+# default is to run all tests, using icont
+
+Test Test-icont: Test-programs Test-preproc Test-options
+
+
+# test programs
+
+Programs Programs-icont Test-programs:
+ IC=icont sh Test-icon
+
+Samples Samples-icont:
+ IC=icont sh Test-icon $(SAMPLES)
+
+
+Test-iconc:
+ IC=iconc sh Test-icon
+
+Samples-iconc:
+ IC=iconc sh Test-icon $(SAMPLES)
+
+
+# test preprocessor
+
+Test-preproc:
+ ../../bin/icont -E tpp.icn tpp9.icn >tpp.out 2>tpp.err || :
+ cat tpp.err tpp.out >tpp.all
+ cmp tpp.ok tpp.all
+ : preprocessor test passed
+
+
+# test various command options
+
+Test-options:
+ sh Test-opts >options.out
+ cmp options.ok options.out
+ : options test passed
+
+
+Clean:
+ -rm -f *.u? *.c *.h foo.baz tmp1 tmp2 *.out *.err *.all
+ -rm -f xx `find * -type f -perm -100 ! -name 'Test-*' -print`
diff --git a/tests/general/Test-icon b/tests/general/Test-icon
new file mode 100755
index 0000000..07ccb87
--- /dev/null
+++ b/tests/general/Test-icon
@@ -0,0 +1,76 @@
+#!/bin/sh
+#
+# Test-icont -- test the Icon translator and interpreter.
+#
+# usage: Test-icont [file...]
+#
+# If $IC is set to iconc, the compiler will be used instead.
+
+IC=${IC-icont}
+IC=../../bin/$IC
+ICONX=../../bin/iconx
+
+unset IPATH LPATH FPATH
+unset BLKSIZE STRSIZE MSTKSIZE COEXPSIZE QLSIZE
+
+# may be needed with Icon is built with BinaryHeader defined
+export ICONX
+
+# echo system environment
+echo ""
+uname -a
+
+# check that we have what we need
+case $IC in
+ *icont)
+ ls ../../bin/icont ../../bin/iconx >/dev/null || exit 0
+ echo "icont: `$IC -V 2>&1`"
+ echo "iconx: `$ICONX -V 2>&1`"
+ ;;
+ *iconc)
+ ls -l ../../bin/iconc ../../bin/rt.* || exit 0
+ ;;
+esac
+
+# if no test files specified, run them all
+if [ $# = 0 ]; then
+ set - *.std
+fi
+
+# loop through the chosen tests
+echo ""
+FAILED=
+for F in $*; do
+ F=`basename $F .std`
+ F=`basename $F .icn`
+ rm -f $F.out
+ echo "Testing $F"
+ if $IC -s $F.icn; then
+ if test -x $F.exe; then
+ EXE=$F.exe
+ else
+ EXE=$F
+ fi
+ if test -r $F.dat; then
+ ./$EXE <$F.dat >$F.out 2>&1
+ else
+ ./$EXE </dev/null >$F.out 2>&1
+ fi
+ diff $F.std $F.out || FAILED="$FAILED $F"
+ else
+ FAILED="$FAILED $F"
+ fi
+ rm -f $EXE
+done
+
+echo ""
+if [ "x$FAILED" = "x" ]; then
+ echo "All tests passed."
+ echo ""
+ exit 0
+else
+ echo "Tests failed: $FAILED"
+ echo ""
+ exit 1
+fi
+
diff --git a/tests/general/Test-opts b/tests/general/Test-opts
new file mode 100755
index 0000000..ac81ebc
--- /dev/null
+++ b/tests/general/Test-opts
@@ -0,0 +1,79 @@
+#!/bin/sh
+#
+# Test-opts -- test some Icon command options
+#
+# Tests a few Icon command options, and especially tests various ways
+# to accomplish directly executable source files.
+#
+# If this script aborts, rerun by "sh -x Test-opts" to see what's occurring.
+
+# check that Icon has been built
+ls ../../bin/icon >/dev/null || exit 1
+ls ../../bin/icont >/dev/null || exit 1
+
+# prepend Icon binary directory to path
+PATH=../../bin:$PATH
+export PATH
+
+# merge stdin and stderr
+exec 2>&1
+
+# unprotect and remove files that might be left from a previous run
+test -f olleh && chmod +rw olleh
+test -f hello && chmod +rw hello
+test -f hello.u1 && chmod +rw hello.u1
+test -f hello.u2 && chmod +rw hello.u2
+rm -f hello hello.u? olleh
+
+# stop on subsequent errors
+set -e
+
+# simple compile and execute, with no arguments
+icont hello -x
+./hello north
+rm hello
+
+# compile and execute with options
+icont -u -s -o olleh hello.icn -x south
+./olleh east
+rm olleh
+test ! -f hello
+test ! -f hello.u?
+
+# separate compilation
+icont -c -t -s hello
+icont -u -s hello.u -x west
+
+# make sure that these files all exist
+# and that subsequent commands don't touch them
+chmod -rwx hello.u1 hello.u2 hello
+
+# icont direct execution
+icont -X hello.icn Tucson
+
+# icon command
+icon hello.icn Pima
+
+# icon command from standard input
+icon - <hello.icn Arizona
+
+# shell magic execution (icont)
+chmod +rwx hello
+echo '#!../../bin/icont -X' | cat - hello.icn > hello
+./hello world
+
+# shell magic execution (icon)
+echo '#!../../bin/icon' | cat - hello.icn > hello
+./hello galaxy
+
+# shell magic execution (/usr/bin/env icon)
+echo '#!/usr/bin/env icon' | cat - hello.icn > hello
+./hello universe
+
+# in-line program
+icon -P 'procedure main(); write("HOWDY!"); end'
+
+# final file cleanup
+chmod +rw hello.u?
+rm hello.u? hello
+: done
diff --git a/tests/general/args.icn b/tests/general/args.icn
new file mode 100644
index 0000000..b836573
--- /dev/null
+++ b/tests/general/args.icn
@@ -0,0 +1,96 @@
+#SRC: JCON
+#
+# test various numbers of args
+
+procedure main()
+ local plist, alist, e
+
+ plist := [3, -2, "image", proc("~===", 2),
+ p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12]
+
+ every write((!plist)())
+ every write((!plist)(1))
+ every write((!plist)(1, 2))
+ every write((!plist)(1, 2, 3))
+ every write((!plist)(1, 2, 3, 4))
+ every write((!plist)(1, 2, 3, 4, 5))
+ every write((!plist)(1, 2, 3, 4, 5, 6))
+ every write((!plist)(1, 2, 3, 4, 5, 6, 7))
+ every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8))
+ every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9))
+ every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
+ every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
+ every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))
+
+ alist := []
+ while *alist < 14 do {
+ every write((!plist) ! alist)
+ put(alist, *alist + 1)
+ }
+end
+
+
+
+# p0 through p12 do their own output and then fail
+
+procedure p0()
+ note("p0")
+end
+
+procedure p1(a)
+ note("p1", a)
+end
+
+procedure p2(a, b)
+ note("p2", a, b)
+end
+
+procedure p3(a, b, c)
+ note("p3", a, b, c)
+end
+
+procedure p4(a, b, c, d)
+ note("p4", a, b, c, d)
+end
+
+procedure p5(a, b, c, d, e)
+ note("p5", a, b, c, d, e)
+end
+
+procedure p6(a, b, c, d, e, f)
+ note("p6", a, b, c, d, e, f)
+end
+
+procedure p7(a, b, c, d, e, f, g)
+ note("p7", a, b, c, d, e, f, g)
+end
+
+procedure p8(a, b, c, d, e, f, g, h)
+ note("p8", a, b, c, d, e, f, g, h)
+end
+
+procedure p9(a, b, c, d, e, f, g, h, i)
+ note("p9", a, b, c, d, e, f, g, h, i)
+end
+
+procedure p10(a, b, c, d, e, f, g, h, i, j)
+ note("p10", a, b, c, d, e, f, g, h, i, j)
+end
+
+procedure p11(a, b, c, d, e, f, g, h, i, j, k)
+ note("p11", a, b, c, d, e, f, g, h, i, j, k)
+end
+
+procedure p12(a, b, c, d, e, f, g, h, i, j, k, l)
+ note("p12", a, b, c, d, e, f, g, h, i, j, k, l)
+end
+
+
+
+procedure note(a[])
+ local e
+
+ every e := !a do writes(\e | "~", " ")
+ write()
+ return
+end
diff --git a/tests/general/args.std b/tests/general/args.std
new file mode 100644
index 0000000..8580d19
--- /dev/null
+++ b/tests/general/args.std
@@ -0,0 +1,447 @@
+&null
+p0
+p1 ~
+p2 ~ ~
+p3 ~ ~ ~
+p4 ~ ~ ~ ~
+p5 ~ ~ ~ ~ ~
+p6 ~ ~ ~ ~ ~ ~
+p7 ~ ~ ~ ~ ~ ~ ~
+p8 ~ ~ ~ ~ ~ ~ ~ ~
+p9 ~ ~ ~ ~ ~ ~ ~ ~ ~
+p10 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+p11 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+p12 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+1
+
+p0
+p1 1
+p2 1 ~
+p3 1 ~ ~
+p4 1 ~ ~ ~
+p5 1 ~ ~ ~ ~
+p6 1 ~ ~ ~ ~ ~
+p7 1 ~ ~ ~ ~ ~ ~
+p8 1 ~ ~ ~ ~ ~ ~ ~
+p9 1 ~ ~ ~ ~ ~ ~ ~ ~
+p10 1 ~ ~ ~ ~ ~ ~ ~ ~ ~
+p11 1 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+p12 1 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+1
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 ~
+p4 1 2 ~ ~
+p5 1 2 ~ ~ ~
+p6 1 2 ~ ~ ~ ~
+p7 1 2 ~ ~ ~ ~ ~
+p8 1 2 ~ ~ ~ ~ ~ ~
+p9 1 2 ~ ~ ~ ~ ~ ~ ~
+p10 1 2 ~ ~ ~ ~ ~ ~ ~ ~
+p11 1 2 ~ ~ ~ ~ ~ ~ ~ ~ ~
+p12 1 2 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+3
+2
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 ~
+p5 1 2 3 ~ ~
+p6 1 2 3 ~ ~ ~
+p7 1 2 3 ~ ~ ~ ~
+p8 1 2 3 ~ ~ ~ ~ ~
+p9 1 2 3 ~ ~ ~ ~ ~ ~
+p10 1 2 3 ~ ~ ~ ~ ~ ~ ~
+p11 1 2 3 ~ ~ ~ ~ ~ ~ ~ ~
+p12 1 2 3 ~ ~ ~ ~ ~ ~ ~ ~ ~
+3
+3
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 ~
+p6 1 2 3 4 ~ ~
+p7 1 2 3 4 ~ ~ ~
+p8 1 2 3 4 ~ ~ ~ ~
+p9 1 2 3 4 ~ ~ ~ ~ ~
+p10 1 2 3 4 ~ ~ ~ ~ ~ ~
+p11 1 2 3 4 ~ ~ ~ ~ ~ ~ ~
+p12 1 2 3 4 ~ ~ ~ ~ ~ ~ ~ ~
+3
+4
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 ~
+p7 1 2 3 4 5 ~ ~
+p8 1 2 3 4 5 ~ ~ ~
+p9 1 2 3 4 5 ~ ~ ~ ~
+p10 1 2 3 4 5 ~ ~ ~ ~ ~
+p11 1 2 3 4 5 ~ ~ ~ ~ ~ ~
+p12 1 2 3 4 5 ~ ~ ~ ~ ~ ~ ~
+3
+5
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 ~
+p8 1 2 3 4 5 6 ~ ~
+p9 1 2 3 4 5 6 ~ ~ ~
+p10 1 2 3 4 5 6 ~ ~ ~ ~
+p11 1 2 3 4 5 6 ~ ~ ~ ~ ~
+p12 1 2 3 4 5 6 ~ ~ ~ ~ ~ ~
+3
+6
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 ~
+p9 1 2 3 4 5 6 7 ~ ~
+p10 1 2 3 4 5 6 7 ~ ~ ~
+p11 1 2 3 4 5 6 7 ~ ~ ~ ~
+p12 1 2 3 4 5 6 7 ~ ~ ~ ~ ~
+3
+7
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 ~
+p10 1 2 3 4 5 6 7 8 ~ ~
+p11 1 2 3 4 5 6 7 8 ~ ~ ~
+p12 1 2 3 4 5 6 7 8 ~ ~ ~ ~
+3
+8
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 ~
+p11 1 2 3 4 5 6 7 8 9 ~ ~
+p12 1 2 3 4 5 6 7 8 9 ~ ~ ~
+3
+9
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 ~
+p12 1 2 3 4 5 6 7 8 9 10 ~ ~
+3
+10
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 11
+p12 1 2 3 4 5 6 7 8 9 10 11 ~
+3
+11
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 11
+p12 1 2 3 4 5 6 7 8 9 10 11 12
+&null
+p0
+p1 ~
+p2 ~ ~
+p3 ~ ~ ~
+p4 ~ ~ ~ ~
+p5 ~ ~ ~ ~ ~
+p6 ~ ~ ~ ~ ~ ~
+p7 ~ ~ ~ ~ ~ ~ ~
+p8 ~ ~ ~ ~ ~ ~ ~ ~
+p9 ~ ~ ~ ~ ~ ~ ~ ~ ~
+p10 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+p11 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+p12 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+1
+
+p0
+p1 1
+p2 1 ~
+p3 1 ~ ~
+p4 1 ~ ~ ~
+p5 1 ~ ~ ~ ~
+p6 1 ~ ~ ~ ~ ~
+p7 1 ~ ~ ~ ~ ~ ~
+p8 1 ~ ~ ~ ~ ~ ~ ~
+p9 1 ~ ~ ~ ~ ~ ~ ~ ~
+p10 1 ~ ~ ~ ~ ~ ~ ~ ~ ~
+p11 1 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+p12 1 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+1
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 ~
+p4 1 2 ~ ~
+p5 1 2 ~ ~ ~
+p6 1 2 ~ ~ ~ ~
+p7 1 2 ~ ~ ~ ~ ~
+p8 1 2 ~ ~ ~ ~ ~ ~
+p9 1 2 ~ ~ ~ ~ ~ ~ ~
+p10 1 2 ~ ~ ~ ~ ~ ~ ~ ~
+p11 1 2 ~ ~ ~ ~ ~ ~ ~ ~ ~
+p12 1 2 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
+3
+2
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 ~
+p5 1 2 3 ~ ~
+p6 1 2 3 ~ ~ ~
+p7 1 2 3 ~ ~ ~ ~
+p8 1 2 3 ~ ~ ~ ~ ~
+p9 1 2 3 ~ ~ ~ ~ ~ ~
+p10 1 2 3 ~ ~ ~ ~ ~ ~ ~
+p11 1 2 3 ~ ~ ~ ~ ~ ~ ~ ~
+p12 1 2 3 ~ ~ ~ ~ ~ ~ ~ ~ ~
+3
+3
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 ~
+p6 1 2 3 4 ~ ~
+p7 1 2 3 4 ~ ~ ~
+p8 1 2 3 4 ~ ~ ~ ~
+p9 1 2 3 4 ~ ~ ~ ~ ~
+p10 1 2 3 4 ~ ~ ~ ~ ~ ~
+p11 1 2 3 4 ~ ~ ~ ~ ~ ~ ~
+p12 1 2 3 4 ~ ~ ~ ~ ~ ~ ~ ~
+3
+4
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 ~
+p7 1 2 3 4 5 ~ ~
+p8 1 2 3 4 5 ~ ~ ~
+p9 1 2 3 4 5 ~ ~ ~ ~
+p10 1 2 3 4 5 ~ ~ ~ ~ ~
+p11 1 2 3 4 5 ~ ~ ~ ~ ~ ~
+p12 1 2 3 4 5 ~ ~ ~ ~ ~ ~ ~
+3
+5
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 ~
+p8 1 2 3 4 5 6 ~ ~
+p9 1 2 3 4 5 6 ~ ~ ~
+p10 1 2 3 4 5 6 ~ ~ ~ ~
+p11 1 2 3 4 5 6 ~ ~ ~ ~ ~
+p12 1 2 3 4 5 6 ~ ~ ~ ~ ~ ~
+3
+6
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 ~
+p9 1 2 3 4 5 6 7 ~ ~
+p10 1 2 3 4 5 6 7 ~ ~ ~
+p11 1 2 3 4 5 6 7 ~ ~ ~ ~
+p12 1 2 3 4 5 6 7 ~ ~ ~ ~ ~
+3
+7
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 ~
+p10 1 2 3 4 5 6 7 8 ~ ~
+p11 1 2 3 4 5 6 7 8 ~ ~ ~
+p12 1 2 3 4 5 6 7 8 ~ ~ ~ ~
+3
+8
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 ~
+p11 1 2 3 4 5 6 7 8 9 ~ ~
+p12 1 2 3 4 5 6 7 8 9 ~ ~ ~
+3
+9
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 ~
+p12 1 2 3 4 5 6 7 8 9 10 ~ ~
+3
+10
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 11
+p12 1 2 3 4 5 6 7 8 9 10 11 ~
+3
+11
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 11
+p12 1 2 3 4 5 6 7 8 9 10 11 12
+3
+12
+1
+2
+p0
+p1 1
+p2 1 2
+p3 1 2 3
+p4 1 2 3 4
+p5 1 2 3 4 5
+p6 1 2 3 4 5 6
+p7 1 2 3 4 5 6 7
+p8 1 2 3 4 5 6 7 8
+p9 1 2 3 4 5 6 7 8 9
+p10 1 2 3 4 5 6 7 8 9 10
+p11 1 2 3 4 5 6 7 8 9 10 11
+p12 1 2 3 4 5 6 7 8 9 10 11 12
diff --git a/tests/general/arith.icn b/tests/general/arith.icn
new file mode 100644
index 0000000..e44c7ab
--- /dev/null
+++ b/tests/general/arith.icn
@@ -0,0 +1,131 @@
+#SRC: JCON
+
+# test arithmetic operators and numeric coercion
+#
+# note: two lines of shifttest output differ from v9 with large integers
+#
+# note also: on Dec Alpha, Java doesn't sign-extend on right-shifts,
+# causing differences to appear.
+
+procedure main()
+ local i, j
+
+ numtest(0, 0)
+ numtest(0, 1)
+ numtest(0, -1)
+ numtest(1, 0)
+ numtest(1, 1)
+ numtest(1, 2)
+ numtest(7, 3)
+ numtest(3, 8)
+ numtest(6.2, 4)
+ numtest(8, 2.5)
+ numtest(5.4, 1.2)
+ numtest(" 1 ", 2.5)
+ numtest(" 3.4", 1.7)
+ numtest(" 5 ", " 5 ")
+ numtest('40', '7')
+ numtest(3, '21')
+ numtest(0., 0.)
+ numtest(0., 1.)
+ numtest(0., -1.)
+ numtest(1, -2)
+ numtest(1., -2.)
+ numtest(-3, 2)
+ numtest(-3., " 2. ")
+ numtest(-6, -3)
+ numtest(-6., -3.)
+ write()
+
+ every (i := -9 | 0 | 5 | 191) & (j := -23 | 0 | 9 | 61) do
+ bitcombo(i, j)
+ write()
+
+ shifttest()
+ write()
+
+ every pow(-3 to 3, -3 to 3)
+ every pow(.5 | 1 | 1.5, (-3 to 3) / 2.0)
+ every pow(-1.5 | -1.0 | -.5 | 0.0, -3 to 3)
+end
+
+procedure numtest(a, b)
+ static f
+ initial f := "---"
+
+ wr5(+a)
+ wr5(b)
+ wr5(abs(a))
+ wr5(-b)
+ wr5(a + b)
+ wr5(a - b)
+ wr5(a * b)
+ if b ~= 0 then wr5(a / b) else wr5(f)
+ if b ~= 0 then wr5(a % b) else wr5(f)
+ wr5(-b)
+ wr5(a < b | f)
+ wr5(a <= b | f)
+ wr5(a = b | f)
+ wr5(a ~= b | f)
+ wr5(a >= b | f)
+ wr5(a > b | f)
+ write()
+ return
+end
+
+procedure bitcombo(i, j)
+ every wr5(i | j | icom(i) | icom(j) | iand(i,j) | ior(i,j) | ixor(i,j))
+ write()
+ return
+end
+
+procedure wr5(n) # write in 5 chars
+ local s
+ if type(n) == "real" then n := r1(n)
+ s := string(n)
+ if *s < 4 then s := right(s, 4)
+ writes(s, " ")
+ return
+end
+
+procedure r1(v) # round real to 1 digit after decimal
+ if v >= 0 then
+ return integer(v * 10 + 0.5) / 10.0
+ else
+ return integer(v * 10 - 0.5) / 10.0
+end
+
+
+procedure shifttest()
+ local n
+
+ every n := 64 | 63 | (5 to -5 by -1) | -63 | -64 do {
+ wr25(ishift(1, n))
+ wr25(ishift(1703, n))
+ wr25(ishift(-251, n))
+ write()
+ }
+end
+
+procedure wr25(n)
+ writes(right(n, 25))
+end
+
+
+
+procedure pow(m, n)
+ local v
+
+ if m = 0 & n <= 0 then
+ fail
+ v := m ^ n
+ if type(v) == "real" then {
+ if v > 0 then
+ v := integer(v * 1000 + 0.5) / 1000.0
+ else
+ v := integer(v * 1000 - 0.5) / 1000.0
+ }
+ write(right(m, 5), " ^ ", left(n, 5), "=", right(v, 7))
+ return
+end
+
diff --git a/tests/general/arith.std b/tests/general/arith.std
new file mode 100644
index 0000000..7b1fcac
--- /dev/null
+++ b/tests/general/arith.std
@@ -0,0 +1,149 @@
+ 0 0 0 0 0 0 0 --- --- 0 --- 0 0 --- 0 ---
+ 0 1 0 -1 1 -1 0 0 0 -1 1 1 --- 1 --- ---
+ 0 -1 0 1 -1 1 0 0 0 1 --- --- --- -1 -1 -1
+ 1 0 1 0 1 1 0 --- --- 0 --- --- --- 0 0 0
+ 1 1 1 -1 2 0 1 1 0 -1 --- 1 1 --- 1 ---
+ 1 2 1 -2 3 -1 2 0 1 -2 2 2 --- 2 --- ---
+ 7 3 7 -3 10 4 21 2 1 -3 --- --- --- 3 3 3
+ 3 8 3 -8 11 -5 24 0 3 -8 8 8 --- 8 --- ---
+ 6.2 4 6.2 -4 10.2 2.2 24.8 1.6 2.2 -4 --- --- --- 4.0 4.0 4.0
+ 8 2.5 8 -2.5 10.5 5.5 20.0 3.2 0.5 -2.5 --- --- --- 2.5 2.5 2.5
+ 5.4 1.2 5.4 -1.2 6.6 4.2 6.5 4.5 0.6 -1.2 --- --- --- 1.2 1.2 1.2
+ 1 2.5 1 -2.5 3.5 -1.5 2.5 0.4 1.0 -2.5 2.5 2.5 --- 2.5 --- ---
+ 3.4 1.7 3.4 -1.7 5.1 1.7 5.8 2.0 0.0 -1.7 --- --- --- 1.7 1.7 1.7
+ 5 5 5 -5 10 0 25 1 0 -5 --- 5 5 --- 5 ---
+ 4 7 4 -7 11 -3 28 0 4 -7 7 7 --- 7 --- ---
+ 3 12 3 -12 15 -9 36 0 3 -12 12 12 --- 12 --- ---
+ 0.0 0.0 0.0 0.0 0.0 0.0 0.0 --- --- 0.0 --- 0.0 0.0 --- 0.0 ---
+ 0.0 1.0 0.0 -1.0 1.0 -1.0 0.0 0.0 0.0 -1.0 1.0 1.0 --- 1.0 --- ---
+ 0.0 -1.0 0.0 1.0 -1.0 1.0 0.0 0.0 0.0 1.0 --- --- --- -1.0 -1.0 -1.0
+ 1 -2 1 2 -1 3 -2 0 1 2 --- --- --- -2 -2 -2
+ 1.0 -2.0 1.0 2.0 -1.0 3.0 -2.0 -0.5 1.0 2.0 --- --- --- -2.0 -2.0 -2.0
+ -3 2 3 -2 -1 -5 -6 -1 -1 -2 2 2 --- 2 --- ---
+-3.0 2. 3.0 -2.0 -1.0 -5.0 -6.0 -1.5 -1.0 -2.0 2.0 2.0 --- 2.0 --- ---
+ -6 -3 6 3 -9 -3 18 2 0 3 -3 -3 --- -3 --- ---
+-6.0 -3.0 6.0 3.0 -9.0 -3.0 18.0 2.0 0.0 3.0 -3.0 -3.0 --- -3.0 --- ---
+
+ -9 -23 8 22 -31 -1 30
+ -9 0 8 -1 0 -9 -9
+ -9 9 8 -10 1 -1 -2
+ -9 61 8 -62 53 -1 -54
+ 0 -23 -1 22 0 -23 -23
+ 0 0 -1 -1 0 0 0
+ 0 9 -1 -10 0 9 9
+ 0 61 -1 -62 0 61 61
+ 5 -23 -6 22 1 -19 -20
+ 5 0 -6 -1 0 5 5
+ 5 9 -6 -10 1 13 12
+ 5 61 -6 -62 5 61 56
+ 191 -23 -192 22 169 -1 -170
+ 191 0 -192 -1 0 191 191
+ 191 9 -192 -10 9 191 182
+ 191 61 -192 -62 61 191 130
+
+ 18446744073709551616 31414805157527366402048 -4630132762501097455616
+ 9223372036854775808 15707402578763683201024 -2315066381250548727808
+ 32 54496 -8032
+ 16 27248 -4016
+ 8 13624 -2008
+ 4 6812 -1004
+ 2 3406 -502
+ 1 1703 -251
+ 0 851 -126
+ 0 425 -63
+ 0 212 -32
+ 0 106 -16
+ 0 53 -8
+ 0 0 -1
+ 0 0 -1
+
+ -3 ^ -3 = 0
+ -3 ^ -2 = 0
+ -3 ^ -1 = 0
+ -3 ^ 0 = 1
+ -3 ^ 1 = -3
+ -3 ^ 2 = 9
+ -3 ^ 3 = -27
+ -2 ^ -3 = 0
+ -2 ^ -2 = 0
+ -2 ^ -1 = 0
+ -2 ^ 0 = 1
+ -2 ^ 1 = -2
+ -2 ^ 2 = 4
+ -2 ^ 3 = -8
+ -1 ^ -3 = -1
+ -1 ^ -2 = 1
+ -1 ^ -1 = -1
+ -1 ^ 0 = 1
+ -1 ^ 1 = -1
+ -1 ^ 2 = 1
+ -1 ^ 3 = -1
+ 0 ^ 1 = 0
+ 0 ^ 2 = 0
+ 0 ^ 3 = 0
+ 1 ^ -3 = 1
+ 1 ^ -2 = 1
+ 1 ^ -1 = 1
+ 1 ^ 0 = 1
+ 1 ^ 1 = 1
+ 1 ^ 2 = 1
+ 1 ^ 3 = 1
+ 2 ^ -3 = 0
+ 2 ^ -2 = 0
+ 2 ^ -1 = 0
+ 2 ^ 0 = 1
+ 2 ^ 1 = 2
+ 2 ^ 2 = 4
+ 2 ^ 3 = 8
+ 3 ^ -3 = 0
+ 3 ^ -2 = 0
+ 3 ^ -1 = 0
+ 3 ^ 0 = 1
+ 3 ^ 1 = 3
+ 3 ^ 2 = 9
+ 3 ^ 3 = 27
+ 0.5 ^ -1.5 = 2.828
+ 0.5 ^ -1.0 = 2.0
+ 0.5 ^ -0.5 = 1.414
+ 0.5 ^ 0.0 = 1.0
+ 0.5 ^ 0.5 = 0.707
+ 0.5 ^ 1.0 = 0.5
+ 0.5 ^ 1.5 = 0.354
+ 1 ^ -1.5 = 1.0
+ 1 ^ -1.0 = 1.0
+ 1 ^ -0.5 = 1.0
+ 1 ^ 0.0 = 1.0
+ 1 ^ 0.5 = 1.0
+ 1 ^ 1.0 = 1.0
+ 1 ^ 1.5 = 1.0
+ 1.5 ^ -1.5 = 0.544
+ 1.5 ^ -1.0 = 0.667
+ 1.5 ^ -0.5 = 0.816
+ 1.5 ^ 0.0 = 1.0
+ 1.5 ^ 0.5 = 1.225
+ 1.5 ^ 1.0 = 1.5
+ 1.5 ^ 1.5 = 1.837
+ -1.5 ^ -3 = -0.296
+ -1.5 ^ -2 = 0.444
+ -1.5 ^ -1 = -0.667
+ -1.5 ^ 0 = 1.0
+ -1.5 ^ 1 = -1.5
+ -1.5 ^ 2 = 2.25
+ -1.5 ^ 3 = -3.375
+ -1.0 ^ -3 = -1.0
+ -1.0 ^ -2 = 1.0
+ -1.0 ^ -1 = -1.0
+ -1.0 ^ 0 = 1.0
+ -1.0 ^ 1 = -1.0
+ -1.0 ^ 2 = 1.0
+ -1.0 ^ 3 = -1.0
+ -0.5 ^ -3 = -8.0
+ -0.5 ^ -2 = 4.0
+ -0.5 ^ -1 = -2.0
+ -0.5 ^ 0 = 1.0
+ -0.5 ^ 1 = -0.5
+ -0.5 ^ 2 = 0.25
+ -0.5 ^ 3 = -0.125
+ 0.0 ^ 1 = 0.0
+ 0.0 ^ 2 = 0.0
+ 0.0 ^ 3 = 0.0
diff --git a/tests/general/augment.icn b/tests/general/augment.icn
new file mode 100644
index 0000000..b567ba8
--- /dev/null
+++ b/tests/general/augment.icn
@@ -0,0 +1,181 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i =:= 9 ----> ",image(i =:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i =:= 10 ----> ",image(i =:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i =:= 11 ----> ",image(i =:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i >=:= 9 ----> ",image(i >=:= 9) | "none")
+end
+
+procedure p2()
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i >=:= 10 ----> ",image(i >=:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i >=:= 11 ----> ",image(i >=:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i >:= 9 ----> ",image(i >:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+end
+
+procedure p3()
+ write("i >:= 10 ----> ",image(i >:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i >:= 11 ----> ",image(i >:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i <=:= 9 ----> ",image(i <=:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i <=:= 10 ----> ",image(i <=:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+end
+
+procedure p4()
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i <=:= 11 ----> ",image(i <=:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i <:= 9 ----> ",image(i <:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i <:= 10 ----> ",image(i <:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i <:= 11 ----> ",image(i <:= 11) | "none")
+end
+
+procedure p5()
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i ~=:= 9 ----> ",image(i ~=:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i ~=:= 10 ----> ",image(i ~=:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i ~=:= 11 ----> ",image(i ~=:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+end
+
+procedure p6()
+ write("i +:= 9 ----> ",image(i +:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i +:= 10 ----> ",image(i +:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i +:= 11 ----> ",image(i +:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i -:= 9 ----> ",image(i -:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+end
+
+procedure p7()
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i -:= 10 ----> ",image(i -:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i -:= 11 ----> ",image(i -:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i *:= 9 ----> ",image(i *:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i *:= 10 ----> ",image(i *:= 10) | "none")
+end
+
+procedure p8()
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i *:= 11 ----> ",image(i *:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i /:= 9 ----> ",image(i /:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i /:= 10 ----> ",image(i /:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+end
+
+procedure p9()
+ write("i /:= 11 ----> ",image(i /:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i %:= 9 ----> ",image(i %:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i %:= 10 ----> ",image(i %:= 10) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i %:= 11 ----> ",image(i %:= 11) | "none")
+ write("i ----> ",image(i) | "none")
+end
+
+procedure p10()
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("i ^:= 9 ----> ",image(i ^:= 9) | "none")
+ write("i ----> ",image(i) | "none")
+ write("i := 10 ----> ",image(i := 10) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s <<:= \"x\" ----> ",image(s <<:= "x") | "none")
+end
+
+procedure p11()
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s <<:= \"xx\" ----> ",image(s <<:= "xx") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s <<:= \"X\" ----> ",image(s <<:= "X") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s <<:= \"abc\" ----> ",image(s <<:= "abc") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+end
+
+procedure p12()
+ write("s ~==:= \"x\" ----> ",image(s ~==:= "x") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ~==:= \"xx\" ----> ",image(s ~==:= "xx") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ~==:= \"X\" ----> ",image(s ~==:= "X") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ~==:= \"abc\" ----> ",image(s ~==:= "abc") | "none")
+ write("s ----> ",image(s) | "none")
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+ p10()
+ p11()
+ p12()
+end
+
+global i, s, c, one, two, x
diff --git a/tests/general/augment.std b/tests/general/augment.std
new file mode 100644
index 0000000..67dc5ca
--- /dev/null
+++ b/tests/general/augment.std
@@ -0,0 +1,127 @@
+i := 10 ----> 10
+i =:= 9 ----> none
+i ----> 10
+i := 10 ----> 10
+i =:= 10 ----> 10
+i ----> 10
+i := 10 ----> 10
+i =:= 11 ----> none
+i ----> 10
+i := 10 ----> 10
+i >=:= 9 ----> 9
+i ----> 9
+i := 10 ----> 10
+i >=:= 10 ----> 10
+i ----> 10
+i := 10 ----> 10
+i >=:= 11 ----> none
+i ----> 10
+i := 10 ----> 10
+i >:= 9 ----> 9
+i ----> 9
+i := 10 ----> 10
+i >:= 10 ----> none
+i ----> 10
+i := 10 ----> 10
+i >:= 11 ----> none
+i ----> 10
+i := 10 ----> 10
+i <=:= 9 ----> none
+i ----> 10
+i := 10 ----> 10
+i <=:= 10 ----> 10
+i ----> 10
+i := 10 ----> 10
+i <=:= 11 ----> 11
+i ----> 11
+i := 10 ----> 10
+i <:= 9 ----> none
+i ----> 10
+i := 10 ----> 10
+i <:= 10 ----> none
+i ----> 10
+i := 10 ----> 10
+i <:= 11 ----> 11
+i ----> 11
+i := 10 ----> 10
+i ~=:= 9 ----> 9
+i ----> 9
+i := 10 ----> 10
+i ~=:= 10 ----> none
+i ----> 10
+i := 10 ----> 10
+i ~=:= 11 ----> 11
+i ----> 11
+i := 10 ----> 10
+i +:= 9 ----> 19
+i ----> 19
+i := 10 ----> 10
+i +:= 10 ----> 20
+i ----> 20
+i := 10 ----> 10
+i +:= 11 ----> 21
+i ----> 21
+i := 10 ----> 10
+i -:= 9 ----> 1
+i ----> 1
+i := 10 ----> 10
+i -:= 10 ----> 0
+i ----> 0
+i := 10 ----> 10
+i -:= 11 ----> -1
+i ----> -1
+i := 10 ----> 10
+i *:= 9 ----> 90
+i ----> 90
+i := 10 ----> 10
+i *:= 10 ----> 100
+i ----> 100
+i := 10 ----> 10
+i *:= 11 ----> 110
+i ----> 110
+i := 10 ----> 10
+i /:= 9 ----> 1
+i ----> 1
+i := 10 ----> 10
+i /:= 10 ----> 1
+i ----> 1
+i := 10 ----> 10
+i /:= 11 ----> 0
+i ----> 0
+i := 10 ----> 10
+i %:= 9 ----> 1
+i ----> 1
+i := 10 ----> 10
+i %:= 10 ----> 0
+i ----> 0
+i := 10 ----> 10
+i %:= 11 ----> 10
+i ----> 10
+i := 10 ----> 10
+i ^:= 9 ----> 1000000000
+i ----> 1000000000
+i := 10 ----> 10
+s := "x" ----> "x"
+s <<:= "x" ----> none
+s ----> "x"
+s := "x" ----> "x"
+s <<:= "xx" ----> "xx"
+s ----> "xx"
+s := "x" ----> "x"
+s <<:= "X" ----> none
+s ----> "x"
+s := "x" ----> "x"
+s <<:= "abc" ----> none
+s ----> "x"
+s := "x" ----> "x"
+s ~==:= "x" ----> none
+s ----> "x"
+s := "x" ----> "x"
+s ~==:= "xx" ----> "xx"
+s ----> "xx"
+s := "x" ----> "x"
+s ~==:= "X" ----> "X"
+s ----> "X"
+s := "x" ----> "x"
+s ~==:= "abc" ----> "abc"
+s ----> "abc"
diff --git a/tests/general/btrees.dat b/tests/general/btrees.dat
new file mode 100644
index 0000000..ca5da4b
--- /dev/null
+++ b/tests/general/btrees.dat
@@ -0,0 +1,3 @@
+a(b,c)
+1(2(3,4),5)
+a(2,8(a,c(d,e)))
diff --git a/tests/general/btrees.icn b/tests/general/btrees.icn
new file mode 100644
index 0000000..bc786f5
--- /dev/null
+++ b/tests/general/btrees.icn
@@ -0,0 +1,43 @@
+#
+# B I N A R Y T R E E S
+#
+
+# This program accepts string representations of binary trees from
+# standard input. It performs a tree walk and lists the leaves of
+# each tree.
+
+record node(data,ltree,rtree)
+
+procedure main()
+ local line, tree
+ while line := read() do {
+ tree := tform(line)
+ write("tree walk")
+ every write(walk(tree))
+ write("leaves")
+ every write(leaves(tree))
+ }
+end
+
+procedure tform(s)
+ local value,left,right
+ if /s then return
+ s ? if value := tab(upto('(')) then {
+ move(1)
+ left := tab(bal(','))
+ move(1)
+ right := tab(bal(')'))
+ return node(value,tform(left),tform(right))
+ }
+ else return node(s)
+end
+
+procedure walk(t)
+ suspend walk(\t.ltree | \t.rtree)
+ return t.data
+end
+
+procedure leaves(t)
+ if not(\t.ltree | \t.rtree) then return t.data
+ suspend leaves(\t.ltree | \t.rtree)
+end
diff --git a/tests/general/btrees.std b/tests/general/btrees.std
new file mode 100644
index 0000000..0fe46fe
--- /dev/null
+++ b/tests/general/btrees.std
@@ -0,0 +1,30 @@
+tree walk
+b
+c
+a
+leaves
+b
+c
+tree walk
+3
+4
+2
+5
+1
+leaves
+3
+4
+5
+tree walk
+2
+a
+d
+e
+c
+8
+a
+leaves
+2
+a
+d
+e
diff --git a/tests/general/case.icn b/tests/general/case.icn
new file mode 100644
index 0000000..72ac3f9
--- /dev/null
+++ b/tests/general/case.icn
@@ -0,0 +1,34 @@
+#SRC: JCON
+
+record rec(a)
+
+procedure main(args)
+ local L, s, x, r, c
+
+ r := rec(45)
+ c := create 1 | 2
+ L := [&null, 0, 1, 2, 0.0, 1.0, 2.0, "", "0", "1", "2", '', '0', '1', '2',
+ rec, main, foo, rec, rec(), r, c, []]
+ put(L, L)
+
+ every x := !L do {
+ s := case x of {
+ 1: "1"
+ '1': "'1'"
+ 1.0: "1.0"
+ "1": "\"1\""
+ &null: "null"
+ main: "main"
+ rec: "rec"
+ rec(): "rec()" # shouldn't ever match
+ r: "r"
+ c: "c"
+ L: "L"
+ default: "default"
+ }
+ write(right(s, 10), " : " , image(x))
+ }
+end
+
+procedure foo()
+end
diff --git a/tests/general/case.std b/tests/general/case.std
new file mode 100644
index 0000000..ca1b44a
--- /dev/null
+++ b/tests/general/case.std
@@ -0,0 +1,24 @@
+ null : &null
+ default : 0
+ 1 : 1
+ default : 2
+ default : 0.0
+ 1.0 : 1.0
+ default : 2.0
+ default : ""
+ default : "0"
+ "1" : "1"
+ default : "2"
+ default : ''
+ default : '0'
+ '1' : '1'
+ default : '2'
+ rec : record constructor rec
+ main : procedure main
+ default : procedure foo
+ rec : record constructor rec
+ default : record rec_2(1)
+ r : record rec_1(1)
+ c : co-expression_2(0)
+ default : list_2(0)
+ L : list_3(24)
diff --git a/tests/general/center.icn b/tests/general/center.icn
new file mode 100644
index 0000000..cb840d5
--- /dev/null
+++ b/tests/general/center.icn
@@ -0,0 +1,22 @@
+#SRC: JCON
+
+procedure main()
+ write(center("12345",3, ""))
+ write(center("1",3, ""))
+ write(center("123"))
+ write(center("12"))
+ write(center("1234",1))
+ write(center("1234",2))
+ write(center("1234",3))
+ write(center("12345",1))
+ write(center("12345",2))
+ write(center("12345",3))
+ write(center("123",8))
+ write(center("12",8))
+ write(center("123",9))
+ write(center("12",9))
+ write(center("123",8,"<>"))
+ write(center("12",8,"<>"))
+ write(center("123",9,"<>"))
+ write(center("12",9,"<>"))
+end
diff --git a/tests/general/center.std b/tests/general/center.std
new file mode 100644
index 0000000..d6cfe1c
--- /dev/null
+++ b/tests/general/center.std
@@ -0,0 +1,18 @@
+234
+ 1
+2
+2
+3
+23
+234
+3
+34
+234
+ 123
+ 12
+ 123
+ 12
+<>123><>
+<><12><>
+<><123><>
+<><12<><>
diff --git a/tests/general/cfuncs.icn b/tests/general/cfuncs.icn
new file mode 100644
index 0000000..40af8fe
--- /dev/null
+++ b/tests/general/cfuncs.icn
@@ -0,0 +1,33 @@
+# A simple test of a few standard C functions
+# for Unix platforms that implement loadfunc().
+
+$ifdef _DYNAMIC_LOADING
+
+ link cfunc
+
+ procedure main()
+ local i
+
+ every i := 500 to 513 do
+ gen(bitcount, i)
+ gen(vword, 314159)
+ gen(lgconv, 10^30)
+ gen(unpack, "abcd")
+ gen(pack, 1684234849)
+ end
+
+ procedure gen(p, a)
+ write(image(p), "(", image(a), ") = ", p(a) | "[failed]")
+ return
+ end
+
+$else
+
+ # fake the "passing" output when LoadFunc is not available,
+ # so that "make Tests" does not fail.
+
+ procedure main()
+ every write(!open("cfuncs.std"))
+ end
+
+$endif
diff --git a/tests/general/cfuncs.std b/tests/general/cfuncs.std
new file mode 100644
index 0000000..de20183
--- /dev/null
+++ b/tests/general/cfuncs.std
@@ -0,0 +1,18 @@
+procedure bitcount(500) = 6
+function bitcount(501) = 7
+function bitcount(502) = 7
+function bitcount(503) = 8
+function bitcount(504) = 6
+function bitcount(505) = 7
+function bitcount(506) = 7
+function bitcount(507) = 8
+function bitcount(508) = 7
+function bitcount(509) = 8
+function bitcount(510) = 8
+function bitcount(511) = 9
+function bitcount(512) = 1
+function bitcount(513) = 2
+procedure vword(314159) = 314159
+procedure lgconv(integer(~10^30)) = 1000000000000000000000000000000
+procedure unpack("abcd") = 1684234849
+procedure pack(1684234849) = abcd
diff --git a/tests/general/checkc.icn b/tests/general/checkc.icn
new file mode 100644
index 0000000..f6af59a
--- /dev/null
+++ b/tests/general/checkc.icn
@@ -0,0 +1,188 @@
+record array(a,b,c,d,e,f,g)
+
+procedure dummy(u,v,x,y,z)
+ suspend u | v
+ return x
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+end
+
+procedure p1()
+ write("image(2) ----> ",image(image(2)) | "none")
+ write("image('cab') ----> ",image(image('cab')) | "none")
+ write("image(&lcase) ----> ",image(image(&lcase)) | "none")
+ write("image('abcdefghijklmnopqrstuvwxyz') ----> ",image(image('abcdefghijklmnopqrstuvwxyz')) | "none")
+ write("image(&input) ----> ",image(image(&input)) | "none")
+ write("image() ----> ",image(image()) | "none")
+ write("image(&null) ----> ",image(image(&null)) | "none")
+ write("image([1,2,3]) ----> ",image(image([1,2,3])) | "none")
+ write("image([]) ----> ",image(image([])) | "none")
+ write("image([,]) ----> ",image(image([,])) | "none")
+ write("image(table()) ----> ",image(image(table())) | "none")
+ write("image(table(3)) ----> ",image(image(table(3))) | "none")
+ write("image(list(0)) ----> ",image(image(list(0))) | "none")
+ write("image(repl) ----> ",image(image(repl)) | "none")
+ write("image(main) ----> ",image(image(main)) | "none")
+ write("image(repl(&lcase,10)) ----> ",image(image(repl(&lcase,10))) | "none")
+ write("image(array) ----> ",image(image(array)) | "none")
+ write("image(a) ----> ",image(image(a)) | "none")
+ write("image(array) ----> ",image(image(array)) | "none")
+ write("image(image) ----> ",image(image(image)) | "none")
+end
+
+procedure p2()
+ write("integer(2) ----> ",image(integer(2)) | "none")
+ write("integer(\"2\") ----> ",image(integer("2")) | "none")
+ write("integer(\" 2\") ----> ",image(integer(" 2")) | "none")
+ write("integer(\"2 \") ----> ",image(integer("2 ")) | "none")
+ write("integer(\"+2\") ----> ",image(integer("+2")) | "none")
+ write("integer(\"-2\") ----> ",image(integer("-2")) | "none")
+ write("integer(\"- 2\") ----> ",image(integer("- 2")) | "none")
+ write("integer(\" - 2 \") ----> ",image(integer(" - 2 ")) | "none")
+ write("integer(\"\") ----> ",image(integer("")) | "none")
+ write("integer(\"--2\") ----> ",image(integer("--2")) | "none")
+ write("integer(\" \") ----> ",image(integer(" ")) | "none")
+ write("integer(\"-\") ----> ",image(integer("-")) | "none")
+ write("integer(\"+\") ----> ",image(integer("+")) | "none")
+ write("integer(\"7r4\") ----> ",image(integer("7r4")) | "none")
+ write("integer(\"4r7\") ----> ",image(integer("4r7")) | "none")
+ write("integer(\"4r 7\") ----> ",image(integer("4r 7")) | "none")
+ write("integer(\"7r 4\") ----> ",image(integer("7r 4")) | "none")
+ write("integer(\"16rff\") ----> ",image(integer("16rff")) | "none")
+ write("integer(\"36rcat\") ----> ",image(integer("36rcat")) | "none")
+ write("integer(\"36Rcat\") ----> ",image(integer("36Rcat")) | "none")
+ write("integer(\"36rCAT\") ----> ",image(integer("36rCAT")) | "none")
+ write("integer(\"1r1\") ----> ",image(integer("1r1")) | "none")
+ write("integer(\"2r0\") ----> ",image(integer("2r0")) | "none")
+ write("integer(integer) ----> ",image(integer(integer)) | "none")
+ write("integer := abs ----> ",image(integer := abs) | "none")
+end
+
+procedure p3()
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(\"2\") ----> ",image(numeric("2")) | "none")
+ write("numeric(\" 2\") ----> ",image(numeric(" 2")) | "none")
+ write("numeric(\"2 \") ----> ",image(numeric("2 ")) | "none")
+ write("numeric(\"+2\") ----> ",image(numeric("+2")) | "none")
+ write("numeric(\"-2\") ----> ",image(numeric("-2")) | "none")
+ write("numeric(\"- 2\") ----> ",image(numeric("- 2")) | "none")
+ write("numeric(\" - 2 \") ----> ",image(numeric(" - 2 ")) | "none")
+ write("numeric(\"\") ----> ",image(numeric("")) | "none")
+ write("numeric(\"--2\") ----> ",image(numeric("--2")) | "none")
+ write("numeric(\" \") ----> ",image(numeric(" ")) | "none")
+ write("numeric(\"-\") ----> ",image(numeric("-")) | "none")
+ write("numeric(\"+\") ----> ",image(numeric("+")) | "none")
+ write("numeric(\"7r4\") ----> ",image(numeric("7r4")) | "none")
+ write("numeric(\"4r7\") ----> ",image(numeric("4r7")) | "none")
+ write("numeric(\"4r 7\") ----> ",image(numeric("4r 7")) | "none")
+ write("numeric(\"7r 4\") ----> ",image(numeric("7r 4")) | "none")
+ write("numeric(\"16rff\") ----> ",image(numeric("16rff")) | "none")
+ write("numeric(\"36rcat\") ----> ",image(numeric("36rcat")) | "none")
+ write("numeric(\"36Rcat\") ----> ",image(numeric("36Rcat")) | "none")
+ write("numeric(\"36rCAT\") ----> ",image(numeric("36rCAT")) | "none")
+ write("numeric(\"1r1\") ----> ",image(numeric("1r1")) | "none")
+ write("numeric(\"2r0\") ----> ",image(numeric("2r0")) | "none")
+end
+
+procedure p4()
+end
+
+procedure p5()
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(+2) ----> ",image(numeric(+2)) | "none")
+ write("numeric(-2) ----> ",image(numeric(-2)) | "none")
+ write("numeric() ----> ",image(numeric()) | "none")
+ write("numeric(7r4) ----> ",image(numeric(7r4)) | "none")
+ write("numeric(16rff) ----> ",image(numeric(16rff)) | "none")
+ write("numeric(36rcat) ----> ",image(numeric(36rcat)) | "none")
+ write("numeric(36Rcat) ----> ",image(numeric(36Rcat)) | "none")
+ write("numeric(36rCAT) ----> ",image(numeric(36rCAT)) | "none")
+ write("numeric(2r0) ----> ",image(numeric(2r0)) | "none")
+ write("numeric(+-2) ----> ",image(numeric(+-2)) | "none")
+ write("numeric(++2) ----> ",image(numeric(++2)) | "none")
+ write("numeric(--2) ----> ",image(numeric(--2)) | "none")
+end
+
+procedure p6()
+ write("36 ^ -9 ----> ",image(36 ^ -9) | "none")
+ write("-36 ^ -9 ----> ",image(-36 ^ -9) | "none")
+end
+
+procedure p7()
+ write("f := open(\"foo.baz\",\"w\") ----> ",image(f := open("foo.baz","w")) | "none")
+ write("write(f,\"hello world\") ----> ",image(write(f,"hello world")) | "none")
+ write("close(f) ----> ",image(close(f)) | "none")
+end
+
+procedure p8()
+ write("\ncset sizes and images:")
+ L := [
+ '',
+ '<()>',
+ '\b\d\e\f\l\n\r\t\v',
+ &digits,
+ '0123456789',
+ '02468' ++ '13579',
+ ')!@#$%^&*(',
+ 'the icon programming language',
+ &lcase,
+ 'abcdefghijklmnopqrstuvwxyz',
+ &letters -- &ucase,
+ 'aBcDeFgHiJkLmNoPqRsTuVwXyZ',
+ &ucase,
+ 'ZYXWVUTSRQPONMLKJIHGFEDCBA',
+ &letters -- &lcase,
+ 'AbcdEfghIjklmnOpqrstUvwxyz',
+ 'The Quick Brown Fox Jumped Over The Lazy Gray Dog\'s Back',
+ &letters,
+ 'abcdefghijklmnopqrstuvwxyzZYXWVUTSRQPONMLKJIHGFEDCBA',
+ &lcase ++ &ucase,
+ 'abcdefghijk|mn.pqrstuvwxyz2YXWVUT5RQP0NMLKJ1HGFEDCBA',
+ &ascii,
+ &cset -- ~&ascii,
+ &cset,
+ &letters ++ ~&ucase,
+ &null]
+ pull(L)
+ every e := !L do {
+ s := image(e) # do this first to make image() calc the cset size
+ s[76:0] := ""
+ write (right(*e,3), " ", s)
+ }
+ write()
+end
+
+procedure p9()
+ write(image(&ascii) | "failed")
+# write(image(&clock) | "failed")
+ write(image(&cset) | "failed")
+# write(image(&date) | "failed")
+# write(image(&dateline) | "failed")
+ write(image(&e) | "failed")
+ write(image(&fail) | "failed")
+# write(image(&host) | "failed")
+ write(image(&input) | "failed")
+ write(image(&lcase) | "failed")
+ write(image(&null) | "failed")
+ write(image(&output) | "failed")
+ write(image(&phi) | "failed")
+ write(image(&pi) | "failed")
+ write(image(&pos) | "failed")
+ write(image(&random) | "failed")
+ write(image(&subject) | "failed")
+# write(image(&time) | "failed")
+ write(image(&ucase) | "failed")
+# write(image(&version) | "failed")
+ exit(abs(3.0))
+end
diff --git a/tests/general/checkc.std b/tests/general/checkc.std
new file mode 100644
index 0000000..15bd17f
--- /dev/null
+++ b/tests/general/checkc.std
@@ -0,0 +1,129 @@
+image(2) ----> "2"
+image('cab') ----> "'abc'"
+image(&lcase) ----> "&lcase"
+image('abcdefghijklmnopqrstuvwxyz') ----> "&lcase"
+image(&input) ----> "&input"
+image() ----> "&null"
+image(&null) ----> "&null"
+image([1,2,3]) ----> "list_1(3)"
+image([]) ----> "list_2(0)"
+image([,]) ----> "list_3(2)"
+image(table()) ----> "table_1(0)"
+image(table(3)) ----> "table_2(0)"
+image(list(0)) ----> "list_4(0)"
+image(repl) ----> "function repl"
+image(main) ----> "procedure main"
+image(repl(&lcase,10)) ----> "\"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\""
+image(array) ----> "record constructor array"
+image(a) ----> "&null"
+image(array) ----> "record constructor array"
+image(image) ----> "function image"
+integer(2) ----> 2
+integer("2") ----> 2
+integer(" 2") ----> 2
+integer("2 ") ----> 2
+integer("+2") ----> 2
+integer("-2") ----> -2
+integer("- 2") ----> none
+integer(" - 2 ") ----> none
+integer("") ----> none
+integer("--2") ----> none
+integer(" ") ----> none
+integer("-") ----> none
+integer("+") ----> none
+integer("7r4") ----> 4
+integer("4r7") ----> none
+integer("4r 7") ----> none
+integer("7r 4") ----> none
+integer("16rff") ----> 255
+integer("36rcat") ----> 15941
+integer("36Rcat") ----> 15941
+integer("36rCAT") ----> 15941
+integer("1r1") ----> none
+integer("2r0") ----> 0
+integer(integer) ----> none
+integer := abs ----> function abs
+numeric(2) ----> 2
+numeric("2") ----> 2
+numeric(" 2") ----> 2
+numeric("2 ") ----> 2
+numeric("+2") ----> 2
+numeric("-2") ----> -2
+numeric("- 2") ----> none
+numeric(" - 2 ") ----> none
+numeric("") ----> none
+numeric("--2") ----> none
+numeric(" ") ----> none
+numeric("-") ----> none
+numeric("+") ----> none
+numeric("7r4") ----> 4
+numeric("4r7") ----> none
+numeric("4r 7") ----> none
+numeric("7r 4") ----> none
+numeric("16rff") ----> 255
+numeric("36rcat") ----> 15941
+numeric("36Rcat") ----> 15941
+numeric("36rCAT") ----> 15941
+numeric("1r1") ----> none
+numeric("2r0") ----> 0
+numeric(2) ----> 2
+numeric(2) ----> 2
+numeric(+2) ----> 2
+numeric(-2) ----> -2
+numeric() ----> none
+numeric(7r4) ----> 4
+numeric(16rff) ----> 255
+numeric(36rcat) ----> 15941
+numeric(36Rcat) ----> 15941
+numeric(36rCAT) ----> 15941
+numeric(2r0) ----> 0
+numeric(+-2) ----> -2
+numeric(++2) ----> 2
+numeric(--2) ----> 2
+36 ^ -9 ----> 0
+-36 ^ -9 ----> 0
+f := open("foo.baz","w") ----> file(foo.baz)
+write(f,"hello world") ----> "hello world"
+close(f) ----> file(foo.baz)
+
+cset sizes and images:
+ 0 ''
+ 4 '()<>'
+ 8 '\b\t\n\v\f\r\e\d'
+ 10 &digits
+ 10 &digits
+ 10 &digits
+ 10 '!#$%&()*@^'
+ 15 ' aceghilmnoprtu'
+ 26 &lcase
+ 26 &lcase
+ 26 &lcase
+ 26 'BDFHJLNPRTVXZacegikmoqsuwy'
+ 26 &ucase
+ 26 &ucase
+ 26 &ucase
+ 26 'AEIOUbcdfghjklmnpqrstvwxyz'
+ 31 ' \'BDFGJLOQTacdeghikmnoprsuvwxyz'
+ 52 &letters
+ 52 &letters
+ 52 &letters
+ 52 '.0125ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrstuvwxyz|'
+128 &ascii
+128 &ascii
+256 &cset
+256 &cset
+
+&ascii
+&cset
+2.718281828
+failed
+&input
+&lcase
+&null
+&output
+1.618033989
+3.141592654
+1
+0
+""
+&ucase
diff --git a/tests/general/checkfpc.icn b/tests/general/checkfpc.icn
new file mode 100644
index 0000000..947c4fe
--- /dev/null
+++ b/tests/general/checkfpc.icn
@@ -0,0 +1,127 @@
+procedure main()
+ write("This test of floating-point arithmetic is likely to show")
+ write("differences from platform to platform because of differences")
+ write("in floating-point precision and details of the routines that")
+ write("convert floating-point numbers to strings. If the values")
+ write("produced in local tests are approximately the same in magnitude")
+ write("as shown in the standard results, there's nothing to worry about.")
+ write("In addition, some platforms may show 0.0 as \"-0.0\". You can")
+ write("ignore this if you wish.")
+ p1()
+ p2()
+ p3()
+end
+
+procedure p1()
+ write("every 1 to 10 do write(?0) ----> ",(every 1 to 10 do write(Image(?0))) | "none")
+ write("every i := 1 to 50 do write(real(repl(\"0\",i) || \"2.\")) ----> ",Image(every i := 1 to 50 do write(real(repl("0",i) || "2."))) | "none")
+ write("every i := 1 to 30 do write(integer(repl(\"0\",i) || \"2\")) ----> ",Image(every i := 1 to 30 do write(integer(repl("0",i) || "2"))) | "none")
+ write("2.0 ~=== +2.0 ----> ",Image(2.0 ~=== +2.0) | "none")
+ write("abs(3.0) ----> ",Image(abs(3.0)) | "none")
+ write("Image(2e13) ----> ",Image(Image(2e13)) | "none")
+ write("Image(0.0006) ----> ",Image(Image(0.0006)) | "none")
+ write("Image(2.0) ----> ",Image(Image(2.0)) | "none")
+ write("integer(2.0) ----> ",Image(integer(2.0)) | "none")
+ write("integer(2.7) ----> ",Image(integer(2.7)) | "none")
+ write("integer(\".\") ----> ",Image(integer(".")) | "none")
+ write("integer(\".3\") ----> ",Image(integer(".3")) | "none")
+ write("integer(\"0.3\") ----> ",Image(integer("0.3")) | "none")
+ write("integer(\" . 3\") ----> ",Image(integer(" . 3")) | "none")
+ write("integer(\"e2\") ----> ",Image(integer("e2")) | "none")
+ write("integer(\"3e500\") ----> ",Image(integer("3e500")) | "none")
+ write("numeric(2.0) ----> ",Image(numeric(2.0)) | "none")
+ write("numeric(2.7) ----> ",Image(numeric(2.7)) | "none")
+ write("numeric(\".\") ----> ",Image(numeric(".")) | "none")
+ write("numeric(\".3\") ----> ",Image(numeric(".3")) | "none")
+ write("numeric(\"0.3\") ----> ",Image(numeric("0.3")) | "none")
+end
+
+procedure p2()
+ write("numeric(\" . 3\") ----> ",Image(numeric(" . 3")) | "none")
+ write("numeric(\"e2\") ----> ",Image(numeric("e2")) | "none")
+ write("numeric(\"3e500\") ----> ",Image(numeric("3e500")) | "none")
+ write("real(2) ----> ",Image(real(2)) | "none")
+ write("real(2.0) ----> ",Image(real(2.0)) | "none")
+ write("real(2.7) ----> ",Image(real(2.7)) | "none")
+ write("real(\"2\") ----> ",Image(real("2")) | "none")
+ write("real(\" 2\") ----> ",Image(real(" 2")) | "none")
+ write("real(\"2 \") ----> ",Image(real("2 ")) | "none")
+ write("real(\"+2\") ----> ",Image(real("+2")) | "none")
+ write("real(\"-2\") ----> ",Image(real("-2")) | "none")
+ write("real(\"- 2\") ----> ",Image(real("- 2")) | "none")
+ write("real(\" - 2 \") ----> ",Image(real(" - 2 ")) | "none")
+ write("real(\"\") ----> ",Image(real("")) | "none")
+ write("real(\"--2\") ----> ",Image(real("--2")) | "none")
+ write("real(\" \") ----> ",Image(real(" ")) | "none")
+ write("real(\"-\") ----> ",Image(real("-")) | "none")
+ write("real(\"+\") ----> ",Image(real("+")) | "none")
+ write("real(\".\") ----> ",Image(real(".")) | "none")
+ write("real(\".3\") ----> ",Image(real(".3")) | "none")
+ write("real(\"0.3\") ----> ",Image(real("0.3")) | "none")
+ write("real(\" . 3\") ----> ",Image(real(" . 3")) | "none")
+ write("real(\"e2\") ----> ",Image(real("e2")) | "none")
+ write("real(\"3e500\") ----> ",Image(real("3e500")) | "none")
+ write("real(\"7r4\") ----> ",Image(real("7r4")) | "none")
+ write("real(\"4r7\") ----> ",Image(real("4r7")) | "none")
+ write("real(\"4r 7\") ----> ",Image(real("4r 7")) | "none")
+ write("real(\"7r 4\") ----> ",Image(real("7r 4")) | "none")
+ write("real(\"16rff\") ----> ",Image(real("16rff")) | "none")
+ write("real(\"36rcat\") ----> ",Image(real("36rcat")) | "none")
+ write("real(\"36Rcat\") ----> ",Image(real("36Rcat")) | "none")
+ write("real(\"36rCAT\") ----> ",Image(real("36rCAT")) | "none")
+ write("real(\"1r1\") ----> ",Image(real("1r1")) | "none")
+ write("real(\"2r0\") ----> ",Image(real("2r0")) | "none")
+ write("real(\"22222222222222222222222222222\") ----> ",Image(real("22222222222222222222222222222")) | "none")
+ write("numeric(2.0) ----> ",Image(numeric(2.0)) | "none")
+ write("numeric(2.7) ----> ",Image(numeric(2.7)) | "none")
+ write("numeric(0.3) ----> ",Image(numeric(0.3)) | "none")
+ write("numeric(e2) ----> ",Image(numeric(e2)) | "none")
+ write("36. ^ 9 ----> ",Image(36. ^ 9) | "none")
+ write("36 ^ 9. ----> ",Image(36 ^ 9.) | "none")
+ write("36. ^ 9. ----> ",Image(36. ^ 9.) | "none")
+ write("-36. ^ 9 ----> ",Image(-36. ^ 9) | "none")
+ write("-36. ^ -9 ----> ",Image(-36. ^ -9) | "none")
+ write((every i := 1 to 37 do write(Image(real(repl("2",i) || ".")))) | "failed")
+ write((every i := 1 to 37 do write(Image(real(repl("2",i) || ".2")))) | "failed")
+ write((every i := 1 to 37 do write(Image((repl("2",i) || ".2") + 1))) | "failed")
+ write("2.0 === +2.0 ----> ",Image(2.0 === +2.0) | "none")
+ write("?30.0 ----> ",Image(?30.0) | "none")
+end
+
+procedure p3()
+ write("copy(1.0) ----> ",Image(copy(1.0)) | "none")
+ write("trim(3.14159,58) ----> ",Image(trim(3.14159,58)) | "none")
+ write("Image(2e13) ----> ",Image(Image(2e13)) | "none")
+ write("Image(0.0006) ----> ",Image(Image(0.0006)) | "none")
+end
+procedure Image(x)
+ local head, tail, exp, span
+
+ span := 9
+
+ if type(x) ~== "real" then return image(x)
+ else {
+ x ? {
+ if head := tab(upto('e'))
+ then {
+ tail := tab(0)
+ head ? return (tab(span | 0) || tail)
+ }
+ else {
+ head := tab(span - 1 | 0)
+ #
+ # if head is too small to include the ".", go to floating point
+ # format.
+ #
+ if exp := *tab(upto('.')) then
+ head ? return move(1) || "." || move(span - 3) ||
+ "e+" || (span - 3 + exp)
+ else {
+ if head[-1] == "." then
+ head ||:= (move(1) | "0")
+ return head
+ }
+ }
+ }
+ }
+end
diff --git a/tests/general/checkfpc.std b/tests/general/checkfpc.std
new file mode 100644
index 0000000..481dce3
--- /dev/null
+++ b/tests/general/checkfpc.std
@@ -0,0 +1,283 @@
+This test of floating-point arithmetic is likely to show
+differences from platform to platform because of differences
+in floating-point precision and details of the routines that
+convert floating-point numbers to strings. If the values
+produced in local tests are approximately the same in magnitude
+as shown in the standard results, there's nothing to worry about.
+In addition, some platforms may show 0.0 as "-0.0". You can
+ignore this if you wish.
+0.21132
+0.41242
+0.31579
+0.51044
+0.42173
+0.30569
+0.07960
+0.73752
+0.05072
+0.71694
+every 1 to 10 do write(?0) ----> none
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+every i := 1 to 50 do write(real(repl("0",i) || "2.")) ----> none
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+every i := 1 to 30 do write(integer(repl("0",i) || "2")) ----> none
+2.0 ~=== +2.0 ----> none
+abs(3.0) ----> 3.0
+Image(2e13) ----> "2e+13"
+Image(0.0006) ----> "0.0006"
+Image(2.0) ----> "2.0"
+integer(2.0) ----> 2
+integer(2.7) ----> 2
+integer(".") ----> none
+integer(".3") ----> 0
+integer("0.3") ----> 0
+integer(" . 3") ----> none
+integer("e2") ----> none
+integer("3e500") ----> none
+numeric(2.0) ----> 2.0
+numeric(2.7) ----> 2.7
+numeric(".") ----> none
+numeric(".3") ----> 0.3
+numeric("0.3") ----> 0.3
+numeric(" . 3") ----> none
+numeric("e2") ----> none
+numeric("3e500") ----> none
+real(2) ----> 2.0
+real(2.0) ----> 2.0
+real(2.7) ----> 2.7
+real("2") ----> 2.0
+real(" 2") ----> 2.0
+real("2 ") ----> 2.0
+real("+2") ----> 2.0
+real("-2") ----> -2.0
+real("- 2") ----> none
+real(" - 2 ") ----> none
+real("") ----> none
+real("--2") ----> none
+real(" ") ----> none
+real("-") ----> none
+real("+") ----> none
+real(".") ----> none
+real(".3") ----> 0.3
+real("0.3") ----> 0.3
+real(" . 3") ----> none
+real("e2") ----> none
+real("3e500") ----> none
+real("7r4") ----> 4.0
+real("4r7") ----> none
+real("4r 7") ----> none
+real("7r 4") ----> none
+real("16rff") ----> 255.0
+real("36rcat") ----> 15941.0
+real("36Rcat") ----> 15941.0
+real("36rCAT") ----> 15941.0
+real("1r1") ----> none
+real("2r0") ----> 0.0
+real("22222222222222222222222222222") ----> 2.222222e+28
+numeric(2.0) ----> 2.0
+numeric(2.7) ----> 2.7
+numeric(0.3) ----> 0.3
+numeric(e2) ----> none
+36. ^ 9 ----> 1.015599e+14
+36 ^ 9. ----> 1.015599e+14
+36. ^ 9. ----> 1.015599e+14
+-36. ^ 9 ----> -1.01559e+14
+-36. ^ -9 ----> -9.84640e-15
+2.0
+22.0
+222.0
+2222.0
+22222.0
+222222.0
+2.222222e+6
+2.222222e+7
+2.222222e+8
+2.222222e+9
+2.222222e+10
+2.222222e+11
+2.222222e+12
+2.222222e+13
+2.222222e+14
+2.222222e+15
+2.222222e+16
+2.222222e+17
+2.222222e+18
+2.222222e+19
+2.222222e+20
+2.222222e+21
+2.222222e+22
+2.222222e+23
+2.222222e+24
+2.222222e+25
+2.222222e+26
+2.222222e+27
+2.222222e+28
+2.222222e+29
+2.222222e+30
+2.222222e+31
+2.222222e+32
+2.222222e+33
+2.222222e+34
+2.222222e+35
+2.222222e+36
+failed
+2.2
+22.2
+222.2
+2222.2
+22222.2
+222222.2
+2.222222e+6
+2.222222e+7
+2.222222e+8
+2.222222e+9
+2.222222e+10
+2.222222e+11
+2.222222e+12
+2.222222e+13
+2.222222e+14
+2.222222e+15
+2.222222e+16
+2.222222e+17
+2.222222e+18
+2.222222e+19
+2.222222e+20
+2.222222e+21
+2.222222e+22
+2.222222e+23
+2.222222e+24
+2.222222e+25
+2.222222e+26
+2.222222e+27
+2.222222e+28
+2.222222e+29
+2.222222e+30
+2.222222e+31
+2.222222e+32
+2.222222e+33
+2.222222e+34
+2.222222e+35
+2.222222e+36
+failed
+3.2
+23.2
+223.2
+2223.2
+22223.2
+222223.2
+2.222223e+6
+2.222222e+7
+2.222222e+8
+2.222222e+9
+2.222222e+10
+2.222222e+11
+2.222222e+12
+2.222222e+13
+2.222222e+14
+2.222222e+15
+2.222222e+16
+2.222222e+17
+2.222222e+18
+2.222222e+19
+2.222222e+20
+2.222222e+21
+2.222222e+22
+2.222222e+23
+2.222222e+24
+2.222222e+25
+2.222222e+26
+2.222222e+27
+2.222222e+28
+2.222222e+29
+2.222222e+30
+2.222222e+31
+2.222222e+32
+2.222222e+33
+2.222222e+34
+2.222222e+35
+2.222222e+36
+failed
+2.0 === +2.0 ----> 2.0
+?30.0 ----> 5
+copy(1.0) ----> 1.0
+trim(3.14159,58) ----> "3.14159"
+Image(2e13) ----> "2e+13"
+Image(0.0006) ----> "0.0006"
diff --git a/tests/general/checkfpx.icn b/tests/general/checkfpx.icn
new file mode 100644
index 0000000..947c4fe
--- /dev/null
+++ b/tests/general/checkfpx.icn
@@ -0,0 +1,127 @@
+procedure main()
+ write("This test of floating-point arithmetic is likely to show")
+ write("differences from platform to platform because of differences")
+ write("in floating-point precision and details of the routines that")
+ write("convert floating-point numbers to strings. If the values")
+ write("produced in local tests are approximately the same in magnitude")
+ write("as shown in the standard results, there's nothing to worry about.")
+ write("In addition, some platforms may show 0.0 as \"-0.0\". You can")
+ write("ignore this if you wish.")
+ p1()
+ p2()
+ p3()
+end
+
+procedure p1()
+ write("every 1 to 10 do write(?0) ----> ",(every 1 to 10 do write(Image(?0))) | "none")
+ write("every i := 1 to 50 do write(real(repl(\"0\",i) || \"2.\")) ----> ",Image(every i := 1 to 50 do write(real(repl("0",i) || "2."))) | "none")
+ write("every i := 1 to 30 do write(integer(repl(\"0\",i) || \"2\")) ----> ",Image(every i := 1 to 30 do write(integer(repl("0",i) || "2"))) | "none")
+ write("2.0 ~=== +2.0 ----> ",Image(2.0 ~=== +2.0) | "none")
+ write("abs(3.0) ----> ",Image(abs(3.0)) | "none")
+ write("Image(2e13) ----> ",Image(Image(2e13)) | "none")
+ write("Image(0.0006) ----> ",Image(Image(0.0006)) | "none")
+ write("Image(2.0) ----> ",Image(Image(2.0)) | "none")
+ write("integer(2.0) ----> ",Image(integer(2.0)) | "none")
+ write("integer(2.7) ----> ",Image(integer(2.7)) | "none")
+ write("integer(\".\") ----> ",Image(integer(".")) | "none")
+ write("integer(\".3\") ----> ",Image(integer(".3")) | "none")
+ write("integer(\"0.3\") ----> ",Image(integer("0.3")) | "none")
+ write("integer(\" . 3\") ----> ",Image(integer(" . 3")) | "none")
+ write("integer(\"e2\") ----> ",Image(integer("e2")) | "none")
+ write("integer(\"3e500\") ----> ",Image(integer("3e500")) | "none")
+ write("numeric(2.0) ----> ",Image(numeric(2.0)) | "none")
+ write("numeric(2.7) ----> ",Image(numeric(2.7)) | "none")
+ write("numeric(\".\") ----> ",Image(numeric(".")) | "none")
+ write("numeric(\".3\") ----> ",Image(numeric(".3")) | "none")
+ write("numeric(\"0.3\") ----> ",Image(numeric("0.3")) | "none")
+end
+
+procedure p2()
+ write("numeric(\" . 3\") ----> ",Image(numeric(" . 3")) | "none")
+ write("numeric(\"e2\") ----> ",Image(numeric("e2")) | "none")
+ write("numeric(\"3e500\") ----> ",Image(numeric("3e500")) | "none")
+ write("real(2) ----> ",Image(real(2)) | "none")
+ write("real(2.0) ----> ",Image(real(2.0)) | "none")
+ write("real(2.7) ----> ",Image(real(2.7)) | "none")
+ write("real(\"2\") ----> ",Image(real("2")) | "none")
+ write("real(\" 2\") ----> ",Image(real(" 2")) | "none")
+ write("real(\"2 \") ----> ",Image(real("2 ")) | "none")
+ write("real(\"+2\") ----> ",Image(real("+2")) | "none")
+ write("real(\"-2\") ----> ",Image(real("-2")) | "none")
+ write("real(\"- 2\") ----> ",Image(real("- 2")) | "none")
+ write("real(\" - 2 \") ----> ",Image(real(" - 2 ")) | "none")
+ write("real(\"\") ----> ",Image(real("")) | "none")
+ write("real(\"--2\") ----> ",Image(real("--2")) | "none")
+ write("real(\" \") ----> ",Image(real(" ")) | "none")
+ write("real(\"-\") ----> ",Image(real("-")) | "none")
+ write("real(\"+\") ----> ",Image(real("+")) | "none")
+ write("real(\".\") ----> ",Image(real(".")) | "none")
+ write("real(\".3\") ----> ",Image(real(".3")) | "none")
+ write("real(\"0.3\") ----> ",Image(real("0.3")) | "none")
+ write("real(\" . 3\") ----> ",Image(real(" . 3")) | "none")
+ write("real(\"e2\") ----> ",Image(real("e2")) | "none")
+ write("real(\"3e500\") ----> ",Image(real("3e500")) | "none")
+ write("real(\"7r4\") ----> ",Image(real("7r4")) | "none")
+ write("real(\"4r7\") ----> ",Image(real("4r7")) | "none")
+ write("real(\"4r 7\") ----> ",Image(real("4r 7")) | "none")
+ write("real(\"7r 4\") ----> ",Image(real("7r 4")) | "none")
+ write("real(\"16rff\") ----> ",Image(real("16rff")) | "none")
+ write("real(\"36rcat\") ----> ",Image(real("36rcat")) | "none")
+ write("real(\"36Rcat\") ----> ",Image(real("36Rcat")) | "none")
+ write("real(\"36rCAT\") ----> ",Image(real("36rCAT")) | "none")
+ write("real(\"1r1\") ----> ",Image(real("1r1")) | "none")
+ write("real(\"2r0\") ----> ",Image(real("2r0")) | "none")
+ write("real(\"22222222222222222222222222222\") ----> ",Image(real("22222222222222222222222222222")) | "none")
+ write("numeric(2.0) ----> ",Image(numeric(2.0)) | "none")
+ write("numeric(2.7) ----> ",Image(numeric(2.7)) | "none")
+ write("numeric(0.3) ----> ",Image(numeric(0.3)) | "none")
+ write("numeric(e2) ----> ",Image(numeric(e2)) | "none")
+ write("36. ^ 9 ----> ",Image(36. ^ 9) | "none")
+ write("36 ^ 9. ----> ",Image(36 ^ 9.) | "none")
+ write("36. ^ 9. ----> ",Image(36. ^ 9.) | "none")
+ write("-36. ^ 9 ----> ",Image(-36. ^ 9) | "none")
+ write("-36. ^ -9 ----> ",Image(-36. ^ -9) | "none")
+ write((every i := 1 to 37 do write(Image(real(repl("2",i) || ".")))) | "failed")
+ write((every i := 1 to 37 do write(Image(real(repl("2",i) || ".2")))) | "failed")
+ write((every i := 1 to 37 do write(Image((repl("2",i) || ".2") + 1))) | "failed")
+ write("2.0 === +2.0 ----> ",Image(2.0 === +2.0) | "none")
+ write("?30.0 ----> ",Image(?30.0) | "none")
+end
+
+procedure p3()
+ write("copy(1.0) ----> ",Image(copy(1.0)) | "none")
+ write("trim(3.14159,58) ----> ",Image(trim(3.14159,58)) | "none")
+ write("Image(2e13) ----> ",Image(Image(2e13)) | "none")
+ write("Image(0.0006) ----> ",Image(Image(0.0006)) | "none")
+end
+procedure Image(x)
+ local head, tail, exp, span
+
+ span := 9
+
+ if type(x) ~== "real" then return image(x)
+ else {
+ x ? {
+ if head := tab(upto('e'))
+ then {
+ tail := tab(0)
+ head ? return (tab(span | 0) || tail)
+ }
+ else {
+ head := tab(span - 1 | 0)
+ #
+ # if head is too small to include the ".", go to floating point
+ # format.
+ #
+ if exp := *tab(upto('.')) then
+ head ? return move(1) || "." || move(span - 3) ||
+ "e+" || (span - 3 + exp)
+ else {
+ if head[-1] == "." then
+ head ||:= (move(1) | "0")
+ return head
+ }
+ }
+ }
+ }
+end
diff --git a/tests/general/checkfpx.std b/tests/general/checkfpx.std
new file mode 100644
index 0000000..481dce3
--- /dev/null
+++ b/tests/general/checkfpx.std
@@ -0,0 +1,283 @@
+This test of floating-point arithmetic is likely to show
+differences from platform to platform because of differences
+in floating-point precision and details of the routines that
+convert floating-point numbers to strings. If the values
+produced in local tests are approximately the same in magnitude
+as shown in the standard results, there's nothing to worry about.
+In addition, some platforms may show 0.0 as "-0.0". You can
+ignore this if you wish.
+0.21132
+0.41242
+0.31579
+0.51044
+0.42173
+0.30569
+0.07960
+0.73752
+0.05072
+0.71694
+every 1 to 10 do write(?0) ----> none
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+2.0
+every i := 1 to 50 do write(real(repl("0",i) || "2.")) ----> none
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+every i := 1 to 30 do write(integer(repl("0",i) || "2")) ----> none
+2.0 ~=== +2.0 ----> none
+abs(3.0) ----> 3.0
+Image(2e13) ----> "2e+13"
+Image(0.0006) ----> "0.0006"
+Image(2.0) ----> "2.0"
+integer(2.0) ----> 2
+integer(2.7) ----> 2
+integer(".") ----> none
+integer(".3") ----> 0
+integer("0.3") ----> 0
+integer(" . 3") ----> none
+integer("e2") ----> none
+integer("3e500") ----> none
+numeric(2.0) ----> 2.0
+numeric(2.7) ----> 2.7
+numeric(".") ----> none
+numeric(".3") ----> 0.3
+numeric("0.3") ----> 0.3
+numeric(" . 3") ----> none
+numeric("e2") ----> none
+numeric("3e500") ----> none
+real(2) ----> 2.0
+real(2.0) ----> 2.0
+real(2.7) ----> 2.7
+real("2") ----> 2.0
+real(" 2") ----> 2.0
+real("2 ") ----> 2.0
+real("+2") ----> 2.0
+real("-2") ----> -2.0
+real("- 2") ----> none
+real(" - 2 ") ----> none
+real("") ----> none
+real("--2") ----> none
+real(" ") ----> none
+real("-") ----> none
+real("+") ----> none
+real(".") ----> none
+real(".3") ----> 0.3
+real("0.3") ----> 0.3
+real(" . 3") ----> none
+real("e2") ----> none
+real("3e500") ----> none
+real("7r4") ----> 4.0
+real("4r7") ----> none
+real("4r 7") ----> none
+real("7r 4") ----> none
+real("16rff") ----> 255.0
+real("36rcat") ----> 15941.0
+real("36Rcat") ----> 15941.0
+real("36rCAT") ----> 15941.0
+real("1r1") ----> none
+real("2r0") ----> 0.0
+real("22222222222222222222222222222") ----> 2.222222e+28
+numeric(2.0) ----> 2.0
+numeric(2.7) ----> 2.7
+numeric(0.3) ----> 0.3
+numeric(e2) ----> none
+36. ^ 9 ----> 1.015599e+14
+36 ^ 9. ----> 1.015599e+14
+36. ^ 9. ----> 1.015599e+14
+-36. ^ 9 ----> -1.01559e+14
+-36. ^ -9 ----> -9.84640e-15
+2.0
+22.0
+222.0
+2222.0
+22222.0
+222222.0
+2.222222e+6
+2.222222e+7
+2.222222e+8
+2.222222e+9
+2.222222e+10
+2.222222e+11
+2.222222e+12
+2.222222e+13
+2.222222e+14
+2.222222e+15
+2.222222e+16
+2.222222e+17
+2.222222e+18
+2.222222e+19
+2.222222e+20
+2.222222e+21
+2.222222e+22
+2.222222e+23
+2.222222e+24
+2.222222e+25
+2.222222e+26
+2.222222e+27
+2.222222e+28
+2.222222e+29
+2.222222e+30
+2.222222e+31
+2.222222e+32
+2.222222e+33
+2.222222e+34
+2.222222e+35
+2.222222e+36
+failed
+2.2
+22.2
+222.2
+2222.2
+22222.2
+222222.2
+2.222222e+6
+2.222222e+7
+2.222222e+8
+2.222222e+9
+2.222222e+10
+2.222222e+11
+2.222222e+12
+2.222222e+13
+2.222222e+14
+2.222222e+15
+2.222222e+16
+2.222222e+17
+2.222222e+18
+2.222222e+19
+2.222222e+20
+2.222222e+21
+2.222222e+22
+2.222222e+23
+2.222222e+24
+2.222222e+25
+2.222222e+26
+2.222222e+27
+2.222222e+28
+2.222222e+29
+2.222222e+30
+2.222222e+31
+2.222222e+32
+2.222222e+33
+2.222222e+34
+2.222222e+35
+2.222222e+36
+failed
+3.2
+23.2
+223.2
+2223.2
+22223.2
+222223.2
+2.222223e+6
+2.222222e+7
+2.222222e+8
+2.222222e+9
+2.222222e+10
+2.222222e+11
+2.222222e+12
+2.222222e+13
+2.222222e+14
+2.222222e+15
+2.222222e+16
+2.222222e+17
+2.222222e+18
+2.222222e+19
+2.222222e+20
+2.222222e+21
+2.222222e+22
+2.222222e+23
+2.222222e+24
+2.222222e+25
+2.222222e+26
+2.222222e+27
+2.222222e+28
+2.222222e+29
+2.222222e+30
+2.222222e+31
+2.222222e+32
+2.222222e+33
+2.222222e+34
+2.222222e+35
+2.222222e+36
+failed
+2.0 === +2.0 ----> 2.0
+?30.0 ----> 5
+copy(1.0) ----> 1.0
+trim(3.14159,58) ----> "3.14159"
+Image(2e13) ----> "2e+13"
+Image(0.0006) ----> "0.0006"
diff --git a/tests/general/checkx.icn b/tests/general/checkx.icn
new file mode 100644
index 0000000..c1a8623
--- /dev/null
+++ b/tests/general/checkx.icn
@@ -0,0 +1,182 @@
+record array(a,b,c,d,e,f,g)
+
+procedure dummy(u,v,x,y,z)
+ suspend u | v
+ return x
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+end
+
+procedure p1()
+ write("image(2) ----> ",image(image(2)) | "none")
+ write("image('cab') ----> ",image(image('cab')) | "none")
+ write("image(&lcase) ----> ",image(image(&lcase)) | "none")
+ write("image('abcdefghijklmnopqrstuvwxyz') ----> ",image(image('abcdefghijklmnopqrstuvwxyz')) | "none")
+ write("image(&input) ----> ",image(image(&input)) | "none")
+ write("image() ----> ",image(image()) | "none")
+ write("image(&null) ----> ",image(image(&null)) | "none")
+ write("image([1,2,3]) ----> ",image(image([1,2,3])) | "none")
+ write("image([]) ----> ",image(image([])) | "none")
+ write("image([,]) ----> ",image(image([,])) | "none")
+ write("image(table()) ----> ",image(image(table())) | "none")
+ write("image(table(3)) ----> ",image(image(table(3))) | "none")
+ write("image(list(0)) ----> ",image(image(list(0))) | "none")
+ write("image(repl) ----> ",image(image(repl)) | "none")
+ write("image(main) ----> ",image(image(main)) | "none")
+ write("image(repl(&lcase,10)) ----> ",image(image(repl(&lcase,10))) | "none")
+ write("image(array) ----> ",image(image(array)) | "none")
+ write("image(a) ----> ",image(image(a)) | "none")
+ write("image(array) ----> ",image(image(array)) | "none")
+ write("image(image) ----> ",image(image(image)) | "none")
+end
+
+procedure p2()
+ write("integer(2) ----> ",image(integer(2)) | "none")
+ write("integer(\"2\") ----> ",image(integer("2")) | "none")
+ write("integer(\" 2\") ----> ",image(integer(" 2")) | "none")
+ write("integer(\"2 \") ----> ",image(integer("2 ")) | "none")
+ write("integer(\"+2\") ----> ",image(integer("+2")) | "none")
+ write("integer(\"-2\") ----> ",image(integer("-2")) | "none")
+ write("integer(\"- 2\") ----> ",image(integer("- 2")) | "none")
+ write("integer(\" - 2 \") ----> ",image(integer(" - 2 ")) | "none")
+ write("integer(\"\") ----> ",image(integer("")) | "none")
+ write("integer(\"--2\") ----> ",image(integer("--2")) | "none")
+ write("integer(\" \") ----> ",image(integer(" ")) | "none")
+ write("integer(\"-\") ----> ",image(integer("-")) | "none")
+ write("integer(\"+\") ----> ",image(integer("+")) | "none")
+ write("integer(\"7r4\") ----> ",image(integer("7r4")) | "none")
+ write("integer(\"4r7\") ----> ",image(integer("4r7")) | "none")
+ write("integer(\"4r 7\") ----> ",image(integer("4r 7")) | "none")
+ write("integer(\"7r 4\") ----> ",image(integer("7r 4")) | "none")
+ write("integer(\"16rff\") ----> ",image(integer("16rff")) | "none")
+ write("integer(\"36rcat\") ----> ",image(integer("36rcat")) | "none")
+ write("integer(\"36Rcat\") ----> ",image(integer("36Rcat")) | "none")
+ write("integer(\"36rCAT\") ----> ",image(integer("36rCAT")) | "none")
+ write("integer(\"1r1\") ----> ",image(integer("1r1")) | "none")
+ write("integer(\"2r0\") ----> ",image(integer("2r0")) | "none")
+ write("integer(integer) ----> ",image(integer(integer)) | "none")
+ write("integer := abs ----> ",image(integer := abs) | "none")
+end
+
+procedure p3()
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(\"2\") ----> ",image(numeric("2")) | "none")
+ write("numeric(\" 2\") ----> ",image(numeric(" 2")) | "none")
+ write("numeric(\"2 \") ----> ",image(numeric("2 ")) | "none")
+ write("numeric(\"+2\") ----> ",image(numeric("+2")) | "none")
+ write("numeric(\"-2\") ----> ",image(numeric("-2")) | "none")
+ write("numeric(\"- 2\") ----> ",image(numeric("- 2")) | "none")
+ write("numeric(\" - 2 \") ----> ",image(numeric(" - 2 ")) | "none")
+ write("numeric(\"\") ----> ",image(numeric("")) | "none")
+ write("numeric(\"--2\") ----> ",image(numeric("--2")) | "none")
+ write("numeric(\" \") ----> ",image(numeric(" ")) | "none")
+ write("numeric(\"-\") ----> ",image(numeric("-")) | "none")
+ write("numeric(\"+\") ----> ",image(numeric("+")) | "none")
+ write("numeric(\"7r4\") ----> ",image(numeric("7r4")) | "none")
+ write("numeric(\"4r7\") ----> ",image(numeric("4r7")) | "none")
+ write("numeric(\"4r 7\") ----> ",image(numeric("4r 7")) | "none")
+ write("numeric(\"7r 4\") ----> ",image(numeric("7r 4")) | "none")
+ write("numeric(\"16rff\") ----> ",image(numeric("16rff")) | "none")
+ write("numeric(\"36rcat\") ----> ",image(numeric("36rcat")) | "none")
+ write("numeric(\"36Rcat\") ----> ",image(numeric("36Rcat")) | "none")
+ write("numeric(\"36rCAT\") ----> ",image(numeric("36rCAT")) | "none")
+ write("numeric(\"1r1\") ----> ",image(numeric("1r1")) | "none")
+ write("numeric(\"2r0\") ----> ",image(numeric("2r0")) | "none")
+end
+
+procedure p4()
+end
+
+procedure p5()
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(+2) ----> ",image(numeric(+2)) | "none")
+ write("numeric(-2) ----> ",image(numeric(-2)) | "none")
+ write("numeric() ----> ",image(numeric()) | "none")
+ write("numeric(7r4) ----> ",image(numeric(7r4)) | "none")
+ write("numeric(16rff) ----> ",image(numeric(16rff)) | "none")
+ write("numeric(36rcat) ----> ",image(numeric(36rcat)) | "none")
+ write("numeric(36Rcat) ----> ",image(numeric(36Rcat)) | "none")
+ write("numeric(36rCAT) ----> ",image(numeric(36rCAT)) | "none")
+ write("numeric(2r0) ----> ",image(numeric(2r0)) | "none")
+ write("numeric(+-2) ----> ",image(numeric(+-2)) | "none")
+ write("numeric(++2) ----> ",image(numeric(++2)) | "none")
+ write("numeric(--2) ----> ",image(numeric(--2)) | "none")
+end
+
+procedure p6()
+ write("36 ^ -9 ----> ",image(36 ^ -9) | "none")
+ write("-36 ^ -9 ----> ",image(-36 ^ -9) | "none")
+end
+
+procedure p7()
+ write("f := open(\"foo.baz\",\"w\") ----> ",image(f := open("foo.baz","w")) | "none")
+ write("write(f,\"hello world\") ----> ",image(write(f,"hello world")) | "none")
+ write("close(f) ----> ",image(close(f)) | "none")
+end
+
+procedure p8()
+ write("\ncset sizes and images:")
+ L := [
+ '',
+ '<()>',
+ '\b\d\e\f\l\n\r\t\v',
+ &digits,
+ '0123456789',
+ '02468' ++ '13579',
+ ')!@#$%^&*(',
+ 'the icon programming language',
+ &lcase,
+ 'abcdefghijklmnopqrstuvwxyz',
+ &letters -- &ucase,
+ 'aBcDeFgHiJkLmNoPqRsTuVwXyZ',
+ &ucase,
+ 'ZYXWVUTSRQPONMLKJIHGFEDCBA',
+ &letters -- &lcase,
+ 'AbcdEfghIjklmnOpqrstUvwxyz',
+ 'The Quick Brown Fox Jumped Over The Lazy Gray Dog\'s Back',
+ &letters,
+ 'abcdefghijklmnopqrstuvwxyzZYXWVUTSRQPONMLKJIHGFEDCBA',
+ &lcase ++ &ucase,
+ 'abcdefghijk|mn.pqrstuvwxyz2YXWVUT5RQP0NMLKJ1HGFEDCBA',
+ &ascii,
+ &cset -- ~&ascii,
+ &cset,
+ &letters ++ ~&ucase,
+ &null]
+ pull(L)
+ every e := !L do {
+ s := image(e) # do this first to make image() calc the cset size
+ s[76:0] := ""
+ write (right(*e,3), " ", s)
+ }
+ write()
+end
+
+procedure p9()
+ write(image(&ascii) | "failed")
+ write(image(&cset) | "failed")
+ write(image(&e) | "failed")
+ write(image(&fail) | "failed")
+ write(image(&input) | "failed")
+ write(image(&lcase) | "failed")
+ write(image(&null) | "failed")
+ write(image(&output) | "failed")
+ write(image(&phi) | "failed")
+ write(image(&pi) | "failed")
+ write(image(&pos) | "failed")
+ write(image(&random) | "failed")
+ write(image(&subject) | "failed")
+ write(image(&ucase) | "failed")
+ exit(abs(3.0))
+end
diff --git a/tests/general/checkx.std b/tests/general/checkx.std
new file mode 100644
index 0000000..15bd17f
--- /dev/null
+++ b/tests/general/checkx.std
@@ -0,0 +1,129 @@
+image(2) ----> "2"
+image('cab') ----> "'abc'"
+image(&lcase) ----> "&lcase"
+image('abcdefghijklmnopqrstuvwxyz') ----> "&lcase"
+image(&input) ----> "&input"
+image() ----> "&null"
+image(&null) ----> "&null"
+image([1,2,3]) ----> "list_1(3)"
+image([]) ----> "list_2(0)"
+image([,]) ----> "list_3(2)"
+image(table()) ----> "table_1(0)"
+image(table(3)) ----> "table_2(0)"
+image(list(0)) ----> "list_4(0)"
+image(repl) ----> "function repl"
+image(main) ----> "procedure main"
+image(repl(&lcase,10)) ----> "\"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\""
+image(array) ----> "record constructor array"
+image(a) ----> "&null"
+image(array) ----> "record constructor array"
+image(image) ----> "function image"
+integer(2) ----> 2
+integer("2") ----> 2
+integer(" 2") ----> 2
+integer("2 ") ----> 2
+integer("+2") ----> 2
+integer("-2") ----> -2
+integer("- 2") ----> none
+integer(" - 2 ") ----> none
+integer("") ----> none
+integer("--2") ----> none
+integer(" ") ----> none
+integer("-") ----> none
+integer("+") ----> none
+integer("7r4") ----> 4
+integer("4r7") ----> none
+integer("4r 7") ----> none
+integer("7r 4") ----> none
+integer("16rff") ----> 255
+integer("36rcat") ----> 15941
+integer("36Rcat") ----> 15941
+integer("36rCAT") ----> 15941
+integer("1r1") ----> none
+integer("2r0") ----> 0
+integer(integer) ----> none
+integer := abs ----> function abs
+numeric(2) ----> 2
+numeric("2") ----> 2
+numeric(" 2") ----> 2
+numeric("2 ") ----> 2
+numeric("+2") ----> 2
+numeric("-2") ----> -2
+numeric("- 2") ----> none
+numeric(" - 2 ") ----> none
+numeric("") ----> none
+numeric("--2") ----> none
+numeric(" ") ----> none
+numeric("-") ----> none
+numeric("+") ----> none
+numeric("7r4") ----> 4
+numeric("4r7") ----> none
+numeric("4r 7") ----> none
+numeric("7r 4") ----> none
+numeric("16rff") ----> 255
+numeric("36rcat") ----> 15941
+numeric("36Rcat") ----> 15941
+numeric("36rCAT") ----> 15941
+numeric("1r1") ----> none
+numeric("2r0") ----> 0
+numeric(2) ----> 2
+numeric(2) ----> 2
+numeric(+2) ----> 2
+numeric(-2) ----> -2
+numeric() ----> none
+numeric(7r4) ----> 4
+numeric(16rff) ----> 255
+numeric(36rcat) ----> 15941
+numeric(36Rcat) ----> 15941
+numeric(36rCAT) ----> 15941
+numeric(2r0) ----> 0
+numeric(+-2) ----> -2
+numeric(++2) ----> 2
+numeric(--2) ----> 2
+36 ^ -9 ----> 0
+-36 ^ -9 ----> 0
+f := open("foo.baz","w") ----> file(foo.baz)
+write(f,"hello world") ----> "hello world"
+close(f) ----> file(foo.baz)
+
+cset sizes and images:
+ 0 ''
+ 4 '()<>'
+ 8 '\b\t\n\v\f\r\e\d'
+ 10 &digits
+ 10 &digits
+ 10 &digits
+ 10 '!#$%&()*@^'
+ 15 ' aceghilmnoprtu'
+ 26 &lcase
+ 26 &lcase
+ 26 &lcase
+ 26 'BDFHJLNPRTVXZacegikmoqsuwy'
+ 26 &ucase
+ 26 &ucase
+ 26 &ucase
+ 26 'AEIOUbcdfghjklmnpqrstvwxyz'
+ 31 ' \'BDFGJLOQTacdeghikmnoprsuvwxyz'
+ 52 &letters
+ 52 &letters
+ 52 &letters
+ 52 '.0125ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrstuvwxyz|'
+128 &ascii
+128 &ascii
+256 &cset
+256 &cset
+
+&ascii
+&cset
+2.718281828
+failed
+&input
+&lcase
+&null
+&output
+1.618033989
+3.141592654
+1
+0
+""
+&ucase
diff --git a/tests/general/ck.icn b/tests/general/ck.icn
new file mode 100644
index 0000000..4922683
--- /dev/null
+++ b/tests/general/ck.icn
@@ -0,0 +1,190 @@
+procedure main()
+ write("This test of floating-point arithmetic is likely to show")
+ write("differences from platform to platform because of differences")
+ write("in floating-point precision and details of the routines that")
+ write("convert floating-point numbers to strings. If the values")
+ write("produced in local tests are approximately the same in magnitude")
+ write("as shown in the standard results, there's nothing to worry about.")
+ write("In addition, some platforms may show 0.0 as \"-0.0\". You can")
+ write("ignore this if you wish.")
+ p4()
+ p5()
+ p6()
+end
+
+procedure p4()
+ write("Image(2.0) ----> ",Image(Image(2.0)) | "none")
+ write("string(2.0) ----> ",Image(string(2.0)) | "none")
+ write("string(2.7) ----> ",Image(string(2.7)) | "none")
+ write("string(\".\") ----> ",Image(string(".")) | "none")
+ write("string(\".3\") ----> ",Image(string(".3")) | "none")
+ write("string(\"0.3\") ----> ",Image(string("0.3")) | "none")
+ write("string(\" . 3\") ----> ",Image(string(" . 3")) | "none")
+ write("string(\"e2\") ----> ",Image(string("e2")) | "none")
+ write("string(\"3e500\") ----> ",Image(string("3e500")) | "none")
+ write("type(1.0) ----> ",Image(type(1.0)) | "none")
+ write("cset(2.0) ----> ",Image(cset(2.0)) | "none")
+ write("cset(2.7) ----> ",Image(cset(2.7)) | "none")
+ write("cset(\".\") ----> ",Image(cset(".")) | "none")
+ write("cset(\".3\") ----> ",Image(cset(".3")) | "none")
+ write("cset(\"0.3\") ----> ",Image(cset("0.3")) | "none")
+ write("cset(\" . 3\") ----> ",Image(cset(" . 3")) | "none")
+ write("cset(\"e2\") ----> ",Image(cset("e2")) | "none")
+ write("cset(\"3e500\") ----> ",Image(cset("3e500")) | "none")
+ write("+1.0 ----> ",Image(+1.0) | "none")
+ write("-1.0 ----> ",Image(-1.0) | "none")
+end
+
+procedure p5()
+ write("real(2) ----> ",Image(real(2)) | "none")
+ write("real(2.0) ----> ",Image(real(2.0)) | "none")
+ write("real(2.7) ----> ",Image(real(2.7)) | "none")
+ write("real(\"2\") ----> ",Image(real("2")) | "none")
+ write("real(\" 2\") ----> ",Image(real(" 2")) | "none")
+ write("real(\"2 \") ----> ",Image(real("2 ")) | "none")
+ write("real(\"+2\") ----> ",Image(real("+2")) | "none")
+ write("real(\"-2\") ----> ",Image(real("-2")) | "none")
+ write("real(\"- 2\") ----> ",Image(real("- 2")) | "none")
+ write("real(\" - 2 \") ----> ",Image(real(" - 2 ")) | "none")
+ write("real(\"\") ----> ",Image(real("")) | "none")
+ write("real(\"--2\") ----> ",Image(real("--2")) | "none")
+ write("real(\" \") ----> ",Image(real(" ")) | "none")
+ write("real(\"-\") ----> ",Image(real("-")) | "none")
+ write("real(\"+\") ----> ",Image(real("+")) | "none")
+ write("real(\".\") ----> ",Image(real(".")) | "none")
+ write("real(\".3\") ----> ",Image(real(".3")) | "none")
+ write("real(\"0.3\") ----> ",Image(real("0.3")) | "none")
+ write("real(\" . 3\") ----> ",Image(real(" . 3")) | "none")
+ write("real(\"e2\") ----> ",Image(real("e2")) | "none")
+ write("real(\"3e500\") ----> ",Image(real("3e500")) | "none")
+ write("real(\"7r4\") ----> ",Image(real("7r4")) | "none")
+ write("real(\"4r7\") ----> ",Image(real("4r7")) | "none")
+ write("real(\"4r 7\") ----> ",Image(real("4r 7")) | "none")
+ write("real(\"7r 4\") ----> ",Image(real("7r 4")) | "none")
+ write("real(\"16rff\") ----> ",Image(real("16rff")) | "none")
+ write("real(\"36rcat\") ----> ",Image(real("36rcat")) | "none")
+ write("real(\"36Rcat\") ----> ",Image(real("36Rcat")) | "none")
+ write("real(\"36rCAT\") ----> ",Image(real("36rCAT")) | "none")
+ write("real(\"1r1\") ----> ",Image(real("1r1")) | "none")
+ write("integer(2.0) ----> ",Image(integer(2.0)) | "none")
+ write("integer(2.7) ----> ",Image(integer(2.7)) | "none")
+ write("integer(\".\") ----> ",Image(integer(".")) | "none")
+ write("integer(\".3\") ----> ",Image(integer(".3")) | "none")
+ write("integer(\"0.3\") ----> ",Image(integer("0.3")) | "none")
+ write("integer(\" . 3\") ----> ",Image(integer(" . 3")) | "none")
+ write("numeric(2.0) ----> ",Image(numeric(2.0)) | "none")
+ write("numeric(2.7) ----> ",Image(numeric(2.7)) | "none")
+ write("numeric(\".\") ----> ",Image(numeric(".")) | "none")
+ write("numeric(\".3\") ----> ",Image(numeric(".3")) | "none")
+ write("numeric(\"0.3\") ----> ",Image(numeric("0.3")) | "none")
+ write("numeric(\" . 3\") ----> ",Image(numeric(" . 3")) | "none")
+ write("real(2.0) ----> ",Image(real(2.0)) | "none")
+ write("real(2.7) ----> ",Image(real(2.7)) | "none")
+ write("real(\".\") ----> ",Image(real(".")) | "none")
+ write("real(\".3\") ----> ",Image(real(".3")) | "none")
+ write("real(\"0.3\") ----> ",Image(real("0.3")) | "none")
+ write("real(\" . 3\") ----> ",Image(real(" . 3")) | "none")
+ write("abs(3.0) ----> ",Image(abs(3.0)) | "none")
+ write("abs(0.0) ----> ",Image(abs(0.0)) | "none")
+ write("abs(-3.0) ----> ",Image(abs(-3.0)) | "none")
+ write("36. % 7 ----> ",Image(36. % 7) | "none")
+ write("36 % 7. ----> ",Image(36 % 7.) | "none")
+ write("36. % 7. ----> ",Image(36. % 7.) | "none")
+ write("-36. % 7 ----> ",Image(-36. % 7) | "none")
+ write("36 % -7. ----> ",Image(36 % -7.) | "none")
+ write("-36. % -7. ----> ",Image(-36. % -7.) | "none")
+ write("36. * 9 ----> ",Image(36. * 9) | "none")
+ write("36 * 9. ----> ",Image(36 * 9.) | "none")
+ write("36. * 9. ----> ",Image(36. * 9.) | "none")
+ write("-36. * 9 ----> ",Image(-36. * 9) | "none")
+end
+
+procedure p6()
+ write("36 * -9. ----> ",Image(36 * -9.) | "none")
+ write("-36. * -9. ----> ",Image(-36. * -9.) | "none")
+ write("36. / 9 ----> ",Image(36. / 9) | "none")
+ write("36 / 9. ----> ",Image(36 / 9.) | "none")
+ write("36. / 9. ----> ",Image(36. / 9.) | "none")
+ write("-36. / 9 ----> ",Image(-36. / 9) | "none")
+ write("36 / -9. ----> ",Image(36 / -9.) | "none")
+ write("-36. / -9. ----> ",Image(-36. / -9.) | "none")
+ write("36. + 9 ----> ",Image(36. + 9) | "none")
+ write("36 + 9. ----> ",Image(36 + 9.) | "none")
+ write("36. + 9. ----> ",Image(36. + 9.) | "none")
+ write("-36. + 9 ----> ",Image(-36. + 9) | "none")
+ write("36 + -9. ----> ",Image(36 + -9.) | "none")
+ write("-36. + -9. ----> ",Image(-36. + -9.) | "none")
+ write("1. < 1 ----> ",Image(1. < 1) | "none")
+ write("1 < 2. ----> ",Image(1 < 2.) | "none")
+ write("1. < 0. ----> ",Image(1. < 0.) | "none")
+ write("-1 < 0. ----> ",Image(-1 < 0.) | "none")
+ write("1. < -2 ----> ",Image(1. < -2) | "none")
+ write("-1 < -0. ----> ",Image(-1 < -0.) | "none")
+ write("1. > 1 ----> ",Image(1. > 1) | "none")
+ write("1 > 2. ----> ",Image(1 > 2.) | "none")
+ write("1. > 0. ----> ",Image(1. > 0.) | "none")
+ write("-1 > 0. ----> ",Image(-1 > 0.) | "none")
+ write("1. > -2 ----> ",Image(1. > -2) | "none")
+ write("-1 > -0. ----> ",Image(-1 > -0.) | "none")
+ write("1. <= 1 ----> ",Image(1. <= 1) | "none")
+ write("1 <= 2. ----> ",Image(1 <= 2.) | "none")
+ write("1. <= 0. ----> ",Image(1. <= 0.) | "none")
+ write("-1 <= 0. ----> ",Image(-1 <= 0.) | "none")
+ write("1. <= -2 ----> ",Image(1. <= -2) | "none")
+ write("-1 <= -0. ----> ",Image(-1 <= -0.) | "none")
+ write("1. >= 1 ----> ",Image(1. >= 1) | "none")
+ write("1 >= 2. ----> ",Image(1 >= 2.) | "none")
+ write("1. >= 0. ----> ",Image(1. >= 0.) | "none")
+ write("-1 >= 0. ----> ",Image(-1 >= 0.) | "none")
+ write("1. >= -2 ----> ",Image(1. >= -2) | "none")
+ write("-1 >= -0. ----> ",Image(-1 >= -0.) | "none")
+ write("1. = 1 ----> ",Image(1. = 1) | "none")
+ write("1 = 2. ----> ",Image(1 = 2.) | "none")
+ write("1. = 0. ----> ",Image(1. = 0.) | "none")
+ write("-1 = 0. ----> ",Image(-1 = 0.) | "none")
+ write("1. = -2 ----> ",Image(1. = -2) | "none")
+ write("-1 = -0. ----> ",Image(-1 = -0.) | "none")
+ write("1. ~= 1 ----> ",Image(1. ~= 1) | "none")
+ write("1 ~= 2. ----> ",Image(1 ~= 2.) | "none")
+ write("1. ~= 0. ----> ",Image(1. ~= 0.) | "none")
+ write("-1 ~= 0. ----> ",Image(-1 ~= 0.) | "none")
+ write("1. ~= -2 ----> ",Image(1. ~= -2) | "none")
+ write("-1 ~= -0. ----> ",Image(-1 ~= -0.) | "none")
+ write("36. ^ 9 ----> ",Image(36. ^ 9) | "none")
+ write("36 ^ 9. ----> ",Image(36 ^ 9.) | "none")
+ write("36. ^ 9. ----> ",Image(36. ^ 9.) | "none")
+ write("-36. ^ 9 ----> ",Image(-36. ^ 9) | "none")
+ write("-36. ^ -9 ----> ",Image(-36. ^ -9) | "none")
+end
+
+procedure Image(x)
+ local head, tail, exp, span
+
+ span := 9
+
+ if type(x) ~== "real" then return image(x)
+ else {
+ x ? {
+ if head := tab(upto('e'))
+ then {
+ tail := tab(0)
+ head ? return (tab(span | 0) || tail)
+ }
+ else {
+ head := tab(span - 1 | 0)
+ #
+ # if head is too small to include the ".", go to floating point
+ # format.
+ #
+ if exp := *tab(upto('.')) then
+ head ? return move(1) || "." || move(span - 3) ||
+ "e+" || (span - 3 + exp)
+ else {
+ if head[-1] == "." then
+ head ||:= (move(1) | "0")
+ return head
+ }
+ }
+ }
+ }
+end
diff --git a/tests/general/ck.std b/tests/general/ck.std
new file mode 100644
index 0000000..4c42f81
--- /dev/null
+++ b/tests/general/ck.std
@@ -0,0 +1,144 @@
+This test of floating-point arithmetic is likely to show
+differences from platform to platform because of differences
+in floating-point precision and details of the routines that
+convert floating-point numbers to strings. If the values
+produced in local tests are approximately the same in magnitude
+as shown in the standard results, there's nothing to worry about.
+In addition, some platforms may show 0.0 as "-0.0". You can
+ignore this if you wish.
+Image(2.0) ----> "2.0"
+string(2.0) ----> "2.0"
+string(2.7) ----> "2.7"
+string(".") ----> "."
+string(".3") ----> ".3"
+string("0.3") ----> "0.3"
+string(" . 3") ----> " . 3"
+string("e2") ----> "e2"
+string("3e500") ----> "3e500"
+type(1.0) ----> "real"
+cset(2.0) ----> '.02'
+cset(2.7) ----> '.27'
+cset(".") ----> '.'
+cset(".3") ----> '.3'
+cset("0.3") ----> '.03'
+cset(" . 3") ----> ' .3'
+cset("e2") ----> '2e'
+cset("3e500") ----> '035e'
++1.0 ----> 1.0
+-1.0 ----> -1.0
+real(2) ----> 2.0
+real(2.0) ----> 2.0
+real(2.7) ----> 2.7
+real("2") ----> 2.0
+real(" 2") ----> 2.0
+real("2 ") ----> 2.0
+real("+2") ----> 2.0
+real("-2") ----> -2.0
+real("- 2") ----> none
+real(" - 2 ") ----> none
+real("") ----> none
+real("--2") ----> none
+real(" ") ----> none
+real("-") ----> none
+real("+") ----> none
+real(".") ----> none
+real(".3") ----> 0.3
+real("0.3") ----> 0.3
+real(" . 3") ----> none
+real("e2") ----> none
+real("3e500") ----> none
+real("7r4") ----> 4.0
+real("4r7") ----> none
+real("4r 7") ----> none
+real("7r 4") ----> none
+real("16rff") ----> 255.0
+real("36rcat") ----> 15941.0
+real("36Rcat") ----> 15941.0
+real("36rCAT") ----> 15941.0
+real("1r1") ----> none
+integer(2.0) ----> 2
+integer(2.7) ----> 2
+integer(".") ----> none
+integer(".3") ----> 0
+integer("0.3") ----> 0
+integer(" . 3") ----> none
+numeric(2.0) ----> 2.0
+numeric(2.7) ----> 2.7
+numeric(".") ----> none
+numeric(".3") ----> 0.3
+numeric("0.3") ----> 0.3
+numeric(" . 3") ----> none
+real(2.0) ----> 2.0
+real(2.7) ----> 2.7
+real(".") ----> none
+real(".3") ----> 0.3
+real("0.3") ----> 0.3
+real(" . 3") ----> none
+abs(3.0) ----> 3.0
+abs(0.0) ----> 0.0
+abs(-3.0) ----> 3.0
+36. % 7 ----> 1.0
+36 % 7. ----> 1.0
+36. % 7. ----> 1.0
+-36. % 7 ----> -1.0
+36 % -7. ----> 1.0
+-36. % -7. ----> -1.0
+36. * 9 ----> 324.0
+36 * 9. ----> 324.0
+36. * 9. ----> 324.0
+-36. * 9 ----> -324.0
+36 * -9. ----> -324.0
+-36. * -9. ----> 324.0
+36. / 9 ----> 4.0
+36 / 9. ----> 4.0
+36. / 9. ----> 4.0
+-36. / 9 ----> -4.0
+36 / -9. ----> -4.0
+-36. / -9. ----> 4.0
+36. + 9 ----> 45.0
+36 + 9. ----> 45.0
+36. + 9. ----> 45.0
+-36. + 9 ----> -27.0
+36 + -9. ----> 27.0
+-36. + -9. ----> -45.0
+1. < 1 ----> none
+1 < 2. ----> 2.0
+1. < 0. ----> none
+-1 < 0. ----> 0.0
+1. < -2 ----> none
+-1 < -0. ----> 0.0
+1. > 1 ----> none
+1 > 2. ----> none
+1. > 0. ----> 0.0
+-1 > 0. ----> none
+1. > -2 ----> -2.0
+-1 > -0. ----> none
+1. <= 1 ----> 1.0
+1 <= 2. ----> 2.0
+1. <= 0. ----> none
+-1 <= 0. ----> 0.0
+1. <= -2 ----> none
+-1 <= -0. ----> 0.0
+1. >= 1 ----> 1.0
+1 >= 2. ----> none
+1. >= 0. ----> 0.0
+-1 >= 0. ----> none
+1. >= -2 ----> -2.0
+-1 >= -0. ----> none
+1. = 1 ----> 1.0
+1 = 2. ----> none
+1. = 0. ----> none
+-1 = 0. ----> none
+1. = -2 ----> none
+-1 = -0. ----> none
+1. ~= 1 ----> none
+1 ~= 2. ----> 2.0
+1. ~= 0. ----> 0.0
+-1 ~= 0. ----> 0.0
+1. ~= -2 ----> -2.0
+-1 ~= -0. ----> 0.0
+36. ^ 9 ----> 1.015599e+14
+36 ^ 9. ----> 1.015599e+14
+36. ^ 9. ----> 1.015599e+14
+-36. ^ 9 ----> -1.01559e+14
+-36. ^ -9 ----> -9.84640e-15
diff --git a/tests/general/coerce.icn b/tests/general/coerce.icn
new file mode 100644
index 0000000..8b9ecbe
--- /dev/null
+++ b/tests/general/coerce.icn
@@ -0,0 +1,67 @@
+#SRC: JCON
+
+# check coercion of operator arguments
+# uses string invocation of operations
+
+
+procedure main()
+ local i, r, c, s
+
+ i := 1
+ r := 2
+ c := '3'
+ s := "9"
+
+ every unop(!"+-*!/\\", i, r, c, s)
+
+ write()
+ every binop(!"+-*/%^<=>" | "<<" | "==" | ">>" , i, r, c, s)
+ binop("[]", i, r, '12345', "67890")
+ every binop("++" | "--" | "**", 12, .23, 'x1', "x2")
+
+ write()
+ every toby(2.3 | '20' | "2", 17.5 | '71' | "17", 3.1 | '30' | "3.2")
+
+ write()
+ every writes(" ", ~~(1257787 | 3.14159 | "arizona") | "\n")
+ every writes(" ", ((123456 | 678.901 | 'tucson') ? move(5)) | "\n")
+
+end
+
+
+procedure toby(i, j, k)
+ local n, s
+ s := image(i) || " to " || image(j) || " by " || image(k) || ":"
+ writes(left(s, 24))
+ every n := i to j by k do
+ writes(" ", n)
+ write()
+end
+
+
+procedure unop(o, i, r, c, s)
+ write(left(o || "x", 7),
+ right(o(i) | "---", 6),
+ right(o(r) | "---", 6),
+ right(o(c) | "---", 6),
+ right(o(s) | "---", 6))
+ return
+end
+
+
+procedure binop(o, i, r, c, s)
+ write("x ", left(o || " y", 5),
+ right(o(i, r) | "---", 6),
+ right(o(i, c) | "---", 6),
+ right(o(i, s) | "---", 6),
+ right(o(r, i) | "---", 6),
+ right(o(r, c) | "---", 6),
+ right(o(r, s) | "---", 6),
+ right(o(c, i) | "---", 6),
+ right(o(c, r) | "---", 6),
+ right(o(c, s) | "---", 6),
+ right(o(s, i) | "---", 6),
+ right(o(s, r) | "---", 6),
+ right(o(s, c) | "---", 6))
+ return
+end
diff --git a/tests/general/coerce.std b/tests/general/coerce.std
new file mode 100644
index 0000000..aa26011
--- /dev/null
+++ b/tests/general/coerce.std
@@ -0,0 +1,54 @@
++x 1 2 3 9
+-x -1 -2 -3 -9
+*x 1 1 1 1
+!x 1 2 3 9
+/x --- --- --- ---
+\x 1 2 3 9
+
+x + y 3 4 10 3 5 11 4 5 12 10 11 12
+x - y -1 -2 -8 1 -1 -7 2 1 -6 8 7 6
+x * y 2 3 9 2 6 18 3 6 27 9 18 27
+x / y 0 0 0 2 0 0 3 1 0 9 4 3
+x % y 1 1 1 0 2 2 0 1 3 0 1 0
+x ^ y 1 1 1 2 8 512 3 9 19683 9 81 729
+x < y 2 3 9 --- 3 9 --- --- 9 --- --- ---
+x = y --- --- --- --- --- --- --- --- --- --- --- ---
+x > y --- --- --- 1 --- --- 1 2 --- 1 2 3
+x << y 2 3 9 --- 3 9 --- --- 9 --- --- ---
+x == y --- --- --- --- --- --- --- --- --- --- --- ---
+x >> y --- --- --- 1 --- --- 1 2 --- 1 2 3
+x [] y --- --- --- 2 --- --- 1 2 --- 6 7 ---
+x ++ y .0123 12x 12x .0123.0123x .023x 12x.0123x 12x 12x .023x 12x
+x -- y 1 2 1 .03 .023 .03 x 1x 1 x x 2
+x ** y 2 1 2 2 2 1 x 2 2 x
+
+2.3 to 17.5 by 3.1: 2 5 8 11 14 17
+2.3 to 17.5 by '03': 2 5 8 11 14 17
+2.3 to 17.5 by "3.2": 2 5 8 11 14 17
+2.3 to '17' by 3.1: 2 5 8 11 14 17
+2.3 to '17' by '03': 2 5 8 11 14 17
+2.3 to '17' by "3.2": 2 5 8 11 14 17
+2.3 to "17" by 3.1: 2 5 8 11 14 17
+2.3 to "17" by '03': 2 5 8 11 14 17
+2.3 to "17" by "3.2": 2 5 8 11 14 17
+'02' to 17.5 by 3.1: 2 5 8 11 14 17
+'02' to 17.5 by '03': 2 5 8 11 14 17
+'02' to 17.5 by "3.2": 2 5 8 11 14 17
+'02' to '17' by 3.1: 2 5 8 11 14 17
+'02' to '17' by '03': 2 5 8 11 14 17
+'02' to '17' by "3.2": 2 5 8 11 14 17
+'02' to "17" by 3.1: 2 5 8 11 14 17
+'02' to "17" by '03': 2 5 8 11 14 17
+'02' to "17" by "3.2": 2 5 8 11 14 17
+"2" to 17.5 by 3.1: 2 5 8 11 14 17
+"2" to 17.5 by '03': 2 5 8 11 14 17
+"2" to 17.5 by "3.2": 2 5 8 11 14 17
+"2" to '17' by 3.1: 2 5 8 11 14 17
+"2" to '17' by '03': 2 5 8 11 14 17
+"2" to '17' by "3.2": 2 5 8 11 14 17
+"2" to "17" by 3.1: 2 5 8 11 14 17
+"2" to "17" by '03': 2 5 8 11 14 17
+"2" to "17" by "3.2": 2 5 8 11 14 17
+
+ 12578 .13459 ainorz
+ 12345 678.9 cnost
diff --git a/tests/general/coexpr.icn b/tests/general/coexpr.icn
new file mode 100644
index 0000000..e4fc621
--- /dev/null
+++ b/tests/general/coexpr.icn
@@ -0,0 +1,72 @@
+record array(a,b,c,d,e,f,g)
+
+procedure dummy(u,v,x,y,z)
+ suspend u | v
+ return x
+end
+
+
+procedure f(x,y,z)
+end
+
+procedure main()
+ if not(&features == "co-expressions") then
+ stop("co-expressions not supported")
+ write(image(&main))
+ write(image(&source))
+ write(image(&current))
+ e := create foo
+ write(image(foo))
+ f(&main,&source,e)
+ write(image(x := [array(),table(),write,input,1,"abc",'aa',&null,create 1]) | "failed")
+ write(image(x := sort(x)) | "failed")
+ write(image(every write(image(!x))) | "failed")
+ write(image(e := create 1 to 10) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(e := ^e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(@e) | "failed")
+ write(image(*e) | "failed")
+ write(image(*e) | "failed")
+ write(image(image(e)) | "failed")
+ write(image(tab := create {write("entering tab"); 1 | 2 | 3}) | "failed")
+ write(image(trim := create {write("entering trim"); @tab | (main @:= tab)}) | "failed")
+ write(image(@trim) | "failed")
+ write(image(@trim) | "failed")
+ write(image(write(image(trim))) | "failed")
+ write(image(write(image(tab))) | "failed")
+ write(image(write(image(main))) | "failed")
+ &trace := -1
+ dummy{1,2,3,4}
+ dummy{}
+ dummy(image{1,2,3,4})
+ dummy(put{1,2,3,4})
+ dummy("*"{1,2,3,4})
+ dummy(image("|||"([],[])))
+ dummy("+"(1,2))
+ dummy("+"(1))
+ dummy("image"(image(image)))
+ &trace := 0
+ e := create writer(1 to 4)
+ while write("return value ", @e)
+end
+
+procedure writer(n)
+ return write("in cx write ", n)
+end
+
+invocable "*", "|||", "+", "image"
diff --git a/tests/general/coexpr.std b/tests/general/coexpr.std
new file mode 100644
index 0000000..d80471e
--- /dev/null
+++ b/tests/general/coexpr.std
@@ -0,0 +1,76 @@
+co-expression_1(1)
+co-expression_1(1)
+co-expression_1(1)
+&null
+list_1(9)
+list_2(9)
+&null
+&null
+1
+"abc"
+'a'
+co-expression_3(0)
+function write
+table_1(0)
+record array_1(7)
+failed
+co-expression_4(0)
+1
+2
+3
+co-expression_5(0)
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+failed
+failed
+failed
+failed
+10
+10
+"co-expression_5(10)"
+co-expression_6(0)
+co-expression_7(0)
+entering trim
+entering tab
+1
+2
+co-expression_7(2)
+"co-expression_7(2)"
+co-expression_6(2)
+"co-expression_6(2)"
+2
+"2"
+coexpr.icn : 54 | dummy(list_3 = [co-expression_8(0),co-expression_9(0),co-expression_10(0),co-expression_11(0)],&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended list_3 = [co-expression_8(0),co-expression_9(0),co-expression_10(0),co-expression_11(0)]
+coexpr.icn : 55 | dummy(list_4 = [],&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended list_4 = []
+coexpr.icn : 56 | dummy("list_5(4)",&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended "list_5(4)"
+coexpr.icn : 57 | dummy(list_6 = [co-expression_16(0),co-expression_17(0),co-expression_18(0),co-expression_19(0),&null],&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended list_6 = [co-expression_16(0),co-expression_17(0),co-expression_18(0),co-expression_19(0),&null]
+coexpr.icn : 58 | dummy(4,&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended 4
+coexpr.icn : 59 | dummy("list_10(0)",&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended "list_10(0)"
+coexpr.icn : 60 | dummy(3,&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended 3
+coexpr.icn : 61 | dummy(1,&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended 1
+coexpr.icn : 62 | dummy("\"function image\"",&null,&null,&null,&null)
+coexpr.icn : 4 | dummy suspended "\"function image\""
+in cx write 1
+return value 1
+in cx write 2
+return value 2
+in cx write 3
+return value 3
+in cx write 4
+return value 4
diff --git a/tests/general/collate.icn b/tests/general/collate.icn
new file mode 100644
index 0000000..34fae21
--- /dev/null
+++ b/tests/general/collate.icn
@@ -0,0 +1,78 @@
+procedure main()
+ s1 := collate(&cset,&cset)
+ s2 := collate(reverse(&cset),reverse(&cset))
+ write(image(decollate(s1,0)))
+ write(image(decollate(s1,1)))
+ write(image(decollate(s2,1)))
+ write(image(decollate(s2,0)))
+ perm()
+end
+
+procedure collate(s1,s2)
+ local length, ltemp, rtemp, t
+ static llabels, rlabels, clabels, blabels, half
+ initial {
+ llabels := "abxy"
+ rlabels := "cduv"
+ blabels := llabels || rlabels
+ clabels := "acbdxuyv"
+ half := 4
+ ltemp := left(&cset,*&cset/2)
+ rtemp := right(&cset,*&cset/2)
+ clabels := collate(ltemp,rtemp)
+ llabels := ltemp
+ rlabels := rtemp
+ blabels := string(&cset)
+ half := *llabels
+ }
+ if *s1 > *s2 then {
+ t := s1[*s2+1:0]
+ s1 := s1[1:*s2+1]
+ }
+ else if *s2 > *s1 then {
+ t := s2[*s1+1:0]
+ s2 := s2[1:*s1+1]
+ }
+ else t := ""
+ length := *s1
+ if length <= half then
+ return map(left(clabels,2*length),left(llabels,length) ||
+ left(rlabels,length),s1 || s2) || t
+ else
+ return map(clabels,blabels,left(s1,half) || left(s2,half)) ||
+ collate(right(s1,length-half),right(s2,length-half)) || t
+end
+
+procedure decollate(s,n)
+ static dsize, image, object
+ local ssize
+ initial {
+ image := collate(&cset[2:0],repl(&cset[1],*&cset-1))
+ object := string(&cset)
+ dsize := *image
+ }
+ n %:= 2
+ ssize := *s
+ if ssize + n <= dsize then
+ return map(object[1+:(ssize+n)/2],image[(n+1)+:ssize],s)
+ else
+ return map(object[1+:(dsize-2)/2],image[(n+1)+:dsize-2],
+ s[1+:(dsize-2)]) || decollate(s[dsize-1:0],n)
+end
+procedure perm()
+ output := set()
+ every 1 to 2 do
+ every insert(output,permute("ogram"))
+ every write(!sort(output))
+end
+
+procedure permute(s)
+ local i, x, t
+ if s == "" then return ""
+ every i := 1 to *s do {
+ x := s[i]
+ t := s
+ t[i] := ""
+ suspend x || permute(t)
+ }
+end
diff --git a/tests/general/collate.std b/tests/general/collate.std
new file mode 100644
index 0000000..4b2fac2
--- /dev/null
+++ b/tests/general/collate.std
@@ -0,0 +1,124 @@
+"\xfd\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xff\xfe"
+"\xfd\x01\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xff\x01"
+"\x02\x01\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0\xef\xee\xed\xec\xeb\xea\xe9\xe8\xe7\xe6\xe5\xe4\xe3\xe2\xe1\xe0\xdf\xde\xdd\xdc\xdb\xda\xd9\xd8\xd7\xd6\xd5\xd4\xd3\xd2\xd1\xd0\xcf\xce\xcd\xcc\xcb\xca\xc9\xc8\xc7\xc6\xc5\xc4\xc3\xc2\xc1\xc0\xbf\xbe\xbd\xbc\xbb\xba\xb9\xb8\xb7\xb6\xb5\xb4\xb3\xb2\xb1\xb0\xaf\xae\xad\xac\xab\xaa\xa9\xa8\xa7\xa6\xa5\xa4\xa3\xa2\xa1\xa0\x9f\x9e\x9d\x9c\x9b\x9a\x99\x98\x97\x96\x95\x94\x93\x92\x91\x90\x8f\x8e\x8d\x8c\x8b\x8a\x89\x88\x87\x86\x85\x84\x83\x82\x81\x80\d~}|{zyxwvutsrqponmlkjihgfedcba`_^]\\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\"! \x1f\x1e\x1d\x1c\e\x1a\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10\x0f\x0e\r\f\v\n\t\b\x07\x06\x05\x04\x00\x01"
+"\x02\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8\xf7\xf6\xf5\xf4\xf3\xf2\xf1\xf0\xef\xee\xed\xec\xeb\xea\xe9\xe8\xe7\xe6\xe5\xe4\xe3\xe2\xe1\xe0\xdf\xde\xdd\xdc\xdb\xda\xd9\xd8\xd7\xd6\xd5\xd4\xd3\xd2\xd1\xd0\xcf\xce\xcd\xcc\xcb\xca\xc9\xc8\xc7\xc6\xc5\xc4\xc3\xc2\xc1\xc0\xbf\xbe\xbd\xbc\xbb\xba\xb9\xb8\xb7\xb6\xb5\xb4\xb3\xb2\xb1\xb0\xaf\xae\xad\xac\xab\xaa\xa9\xa8\xa7\xa6\xa5\xa4\xa3\xa2\xa1\xa0\x9f\x9e\x9d\x9c\x9b\x9a\x99\x98\x97\x96\x95\x94\x93\x92\x91\x90\x8f\x8e\x8d\x8c\x8b\x8a\x89\x88\x87\x86\x85\x84\x83\x82\x81\x80\d~}|{zyxwvutsrqponmlkjihgfedcba`_^]\\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#\"! \x1f\x1e\x1d\x1c\e\x1a\x19\x18\x17\x16\x15\x14\x13\x12\x11\x10\x0f\x0e\r\f\v\n\t\b\x07\x06\x05\x04\x03\x00\x01"
+agmor
+agmro
+agomr
+agorm
+agrmo
+agrom
+amgor
+amgro
+amogr
+amorg
+amrgo
+amrog
+aogmr
+aogrm
+aomgr
+aomrg
+aorgm
+aormg
+argmo
+argom
+armgo
+armog
+arogm
+aromg
+gamor
+gamro
+gaomr
+gaorm
+garmo
+garom
+gmaor
+gmaro
+gmoar
+gmora
+gmrao
+gmroa
+goamr
+goarm
+gomar
+gomra
+goram
+gorma
+gramo
+graom
+grmao
+grmoa
+groam
+groma
+magor
+magro
+maogr
+maorg
+margo
+marog
+mgaor
+mgaro
+mgoar
+mgora
+mgrao
+mgroa
+moagr
+moarg
+mogar
+mogra
+morag
+morga
+mrago
+mraog
+mrgao
+mrgoa
+mroag
+mroga
+oagmr
+oagrm
+oamgr
+oamrg
+oargm
+oarmg
+ogamr
+ogarm
+ogmar
+ogmra
+ogram
+ogrma
+omagr
+omarg
+omgar
+omgra
+omrag
+omrga
+oragm
+oramg
+orgam
+orgma
+ormag
+ormga
+ragmo
+ragom
+ramgo
+ramog
+raogm
+raomg
+rgamo
+rgaom
+rgmao
+rgmoa
+rgoam
+rgoma
+rmago
+rmaog
+rmgao
+rmgoa
+rmoag
+rmoga
+roagm
+roamg
+rogam
+rogma
+romag
+romga
diff --git a/tests/general/concord.dat b/tests/general/concord.dat
new file mode 100644
index 0000000..4e62fe7
--- /dev/null
+++ b/tests/general/concord.dat
@@ -0,0 +1,17 @@
+Order, Coleoptera, (Beetles). Many beetles are colored so as
+to resemble the surfaces which they habitually frequent, and they thus
+escape detection by their enemies. Other species, for instance, diamond-beetles, are ornamented
+with splendid colors, which are often arranged in stripes, spots, crosses,
+and other elegant patterns. Such colors can hardly serve directly as a protection, except in the case
+of certain flower-feeding species; but they may serve as a warning or means of
+recognition, on the same principle as the
+phosphorescence of the glow-worm.
+As with beetles the colors of the two sexes are generally alike, we have
+no evidence that they have been gained through sexual selection; but this is
+at least possible, for they may have been developed in one sex and then
+transferred to the other; and this view is even in some degree probable
+in those groups which possess other well-marked secondary
+sexual characters. Blind beetles, which cannot, of course, behold each
+other's beauty, never, as I hear from Mr. Waterhouse, Jr., exhibit bright
+colors, though they often have polished coats; but the explanation of their
+obscurity may be that they generally inhabit caves and other obscure stations.
diff --git a/tests/general/concord.icn b/tests/general/concord.icn
new file mode 100644
index 0000000..171c9e8
--- /dev/null
+++ b/tests/general/concord.icn
@@ -0,0 +1,31 @@
+procedure main()
+ local letters, line, wordlist, word, words, maxword, lineno, i
+ local j, lines, numbers
+ letters := &lcase ++ &ucase ++ '\''
+ words := table("")
+ maxword := lineno := 0
+ while line := read() do {
+ lineno +:= 1
+ write(right(lineno,6)," ",line)
+ line := map(line) # fold to lowercase
+ i := 1
+ while j := upto(letters,line,i) do {
+ i := many(letters,line,j)
+ word := line[j:i]
+ if *word < 3 then next # skip short words
+ maxword <:= *word # keep track of longest word
+ # if it's a new word, start set
+ if *words[word] = 0 then words[word] := set([lineno])
+ else insert(words[word],lineno) # else add the line number
+ }
+ }
+ write()
+ wordlist := sort(words) # sort by words
+ i := 0
+ while word := wordlist[i +:= 1][1] do {
+ lines := "" # build up line numbers
+ numbers := sort(wordlist[i][2])
+ while lines ||:= get(numbers) || ", "
+ write(left(word,maxword + 2),": ",lines[1:-2])
+ }
+end
diff --git a/tests/general/concord.std b/tests/general/concord.std
new file mode 100644
index 0000000..849e0d2
--- /dev/null
+++ b/tests/general/concord.std
@@ -0,0 +1,128 @@
+ 1 Order, Coleoptera, (Beetles). Many beetles are colored so as
+ 2 to resemble the surfaces which they habitually frequent, and they thus
+ 3 escape detection by their enemies. Other species, for instance, diamond-beetles, are ornamented
+ 4 with splendid colors, which are often arranged in stripes, spots, crosses,
+ 5 and other elegant patterns. Such colors can hardly serve directly as a protection, except in the case
+ 6 of certain flower-feeding species; but they may serve as a warning or means of
+ 7 recognition, on the same principle as the
+ 8 phosphorescence of the glow-worm.
+ 9 As with beetles the colors of the two sexes are generally alike, we have
+ 10 no evidence that they have been gained through sexual selection; but this is
+ 11 at least possible, for they may have been developed in one sex and then
+ 12 transferred to the other; and this view is even in some degree probable
+ 13 in those groups which possess other well-marked secondary
+ 14 sexual characters. Blind beetles, which cannot, of course, behold each
+ 15 other's beauty, never, as I hear from Mr. Waterhouse, Jr., exhibit bright
+ 16 colors, though they often have polished coats; but the explanation of their
+ 17 obscurity may be that they generally inhabit caves and other obscure stations.
+
+alike : 9
+and : 2, 5, 11, 12, 17
+are : 1, 3, 4, 9
+arranged : 4
+beauty : 15
+been : 10, 11
+beetles : 1, 3, 9, 14
+behold : 14
+blind : 14
+bright : 15
+but : 6, 10, 16
+can : 5
+cannot : 14
+case : 5
+caves : 17
+certain : 6
+characters : 14
+coats : 16
+coleoptera : 1
+colored : 1
+colors : 4, 5, 9, 16
+course : 14
+crosses : 4
+degree : 12
+detection : 3
+developed : 11
+diamond : 3
+directly : 5
+each : 14
+elegant : 5
+enemies : 3
+escape : 3
+even : 12
+evidence : 10
+except : 5
+exhibit : 15
+explanation : 16
+feeding : 6
+flower : 6
+for : 3, 11
+frequent : 2
+from : 15
+gained : 10
+generally : 9, 17
+glow : 8
+groups : 13
+habitually : 2
+hardly : 5
+have : 9, 10, 11, 16
+hear : 15
+inhabit : 17
+instance : 3
+least : 11
+many : 1
+marked : 13
+may : 6, 11, 17
+means : 6
+never : 15
+obscure : 17
+obscurity : 17
+often : 4, 16
+one : 11
+order : 1
+ornamented : 3
+other : 3, 5, 12, 13, 17
+other's : 15
+patterns : 5
+phosphorescence : 8
+polished : 16
+possess : 13
+possible : 11
+principle : 7
+probable : 12
+protection : 5
+recognition : 7
+resemble : 2
+same : 7
+secondary : 13
+selection : 10
+serve : 5, 6
+sex : 11
+sexes : 9
+sexual : 10, 14
+some : 12
+species : 3, 6
+splendid : 4
+spots : 4
+stations : 17
+stripes : 4
+such : 5
+surfaces : 2
+that : 10, 17
+the : 2, 5, 7, 8, 9, 12, 16
+their : 3, 16
+then : 11
+they : 2, 6, 10, 11, 16, 17
+this : 10, 12
+those : 13
+though : 16
+through : 10
+thus : 2
+transferred : 12
+two : 9
+view : 12
+warning : 6
+waterhouse : 15
+well : 13
+which : 2, 4, 13, 14
+with : 4, 9
+worm : 8
diff --git a/tests/general/cset.icn b/tests/general/cset.icn
new file mode 100644
index 0000000..dce1685
--- /dev/null
+++ b/tests/general/cset.icn
@@ -0,0 +1,85 @@
+#SRC: JCON
+
+# test csets and character conversions
+
+procedure main()
+ local a, c, i, n, s, cs, ct, x, y
+
+ x := 'a1b2c3'
+ write("x: ", x);
+ write("*x: ", *x)
+ every writes("!x: " | !x | "\n");
+ write("?z: ", ?'z')
+ write("?empty: ", ?'', " (OOPS)") # should fail
+ write()
+
+ kw("digits", &digits)
+ kw("lcase", &lcase)
+ kw("ucase", &ucase)
+ kw("letters", &letters)
+ write(" &ascii: ", *&ascii, " elements")
+ write()
+
+ write (" x y ",
+ " x++y y++x x--y y--x x**y y**x ~~x")
+
+ every x := ( 'a1b2c3' | "a1b2c3" | 1234 | 12.34 | '') &
+ y := ( 'xyzabc' | "xyzabc" | 3456 | 34.56 | "@ 90") do {
+ write(
+ right(image(x),8), right(image(y),9),
+ right(x++y, 13), right(y++x, 13),
+ right(x--y, 7), right(y--x, 7),
+ right(x**y, 7), right(y**x, 7),
+ right(~~x, 7))
+ }
+
+ # various tests involving chars with the sign bit set
+
+ # test conversion of int to char (string) and back
+ write()
+ every i := 0 to 255 by 15 do {
+ s := ""
+ c := char(i)
+ s ||:= c
+ n := ord(c)
+ cs := cset(c)
+ write(right(i, 3), right(image(c), 8), right(image(s), 8), right(n, 5),
+ right(image(cs), 8))
+ }
+
+ # test more and stranger conversions
+ write()
+ a := [0, 15.71, "32rU", "16r2D", "60", "8r113", "90", "105", "120", "8r207",
+ "16r96", "16ra5", "16rB4", "16rc3", "16rD2", "16re1", "16rf0", "16rfF"]
+ every s := !a do {
+ c := char(s)
+ n := ord(c)
+ write(right(image(s), 8), right(image(c), 8), right(n, 5))
+ }
+
+ # test conversion of string to int and back
+ write()
+ a := ["\x00", "\x0F", "\x1e", "-", "<", "\113", "Z", "i", "x", "\x87",
+ "\x96", "\xa5", "\xB4", "\xc3", "\xD2", "\xe1", "\xf0", "\xfF"]
+ every s := !a do {
+ n := ord(s)
+ c := char(n)
+ write(right(image(s), 6), right(n, 5), right(image(c), 8))
+ }
+
+ # test conversion of cset to string and int
+ write()
+ a := ['\x00', '\x0F', '\x1e', '-', '<', '\113', 'Z', 'i', 'x', '\x87',
+ '\x96', '\xa5', '\xB4', '\xc3', '\xD2', '\xe1', '\xf0', '\xfF']
+ every cs := !a do {
+ s := string(cs)
+ n := ord(cs)
+ write(right(image(cs), 6), right(image(s), 8), right(n, 5))
+ }
+end
+
+procedure kw(label, value)
+ write(right("&" || label, 10), ": '", value, "'")
+ return
+end
+
diff --git a/tests/general/cset.std b/tests/general/cset.std
new file mode 100644
index 0000000..524132c
--- /dev/null
+++ b/tests/general/cset.std
@@ -0,0 +1,113 @@
+x: 123abc
+*x: 6
+!x: 123abc
+?z: z
+
+ &digits: '0123456789'
+ &lcase: 'abcdefghijklmnopqrstuvwxyz'
+ &ucase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ &letters: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
+ &ascii: 128 elements
+
+ x y x++y y++x x--y y--x x**y y**x ~~x
+'123abc' 'abcxyz' 123abcxyz 123abcxyz 123 xyz abc abc 123abc
+'123abc' "xyzabc" 123abcxyz 123abcxyz 123 xyz abc abc 123abc
+'123abc' 3456 123456abc 123456abc 12abc 456 3 3 123abc
+'123abc' 34.56 .123456abc .123456abc 12abc .456 3 3 123abc
+'123abc' "@ 90" 01239@abc 01239@abc 123abc 09@ 123abc
+"a1b2c3" 'abcxyz' 123abcxyz 123abcxyz 123 xyz abc abc 123abc
+"a1b2c3" "xyzabc" 123abcxyz 123abcxyz 123 xyz abc abc 123abc
+"a1b2c3" 3456 123456abc 123456abc 12abc 456 3 3 123abc
+"a1b2c3" 34.56 .123456abc .123456abc 12abc .456 3 3 123abc
+"a1b2c3" "@ 90" 01239@abc 01239@abc 123abc 09@ 123abc
+ 1234 'abcxyz' 1234abcxyz 1234abcxyz 1234 abcxyz 1234
+ 1234 "xyzabc" 1234abcxyz 1234abcxyz 1234 abcxyz 1234
+ 1234 3456 123456 123456 12 56 34 34 1234
+ 1234 34.56 .123456 .123456 12 .56 34 34 1234
+ 1234 "@ 90" 012349@ 012349@ 1234 09@ 1234
+ 12.34 'abcxyz' .1234abcxyz .1234abcxyz .1234 abcxyz .1234
+ 12.34 "xyzabc" .1234abcxyz .1234abcxyz .1234 abcxyz .1234
+ 12.34 3456 .123456 .123456 .12 56 34 34 .1234
+ 12.34 34.56 .123456 .123456 12 56 .34 .34 .1234
+ 12.34 "@ 90" .012349@ .012349@ .1234 09@ .1234
+ '' 'abcxyz' abcxyz abcxyz abcxyz
+ '' "xyzabc" abcxyz abcxyz abcxyz
+ '' 3456 3456 3456 3456
+ '' 34.56 .3456 .3456 .3456
+ '' "@ 90" 09@ 09@ 09@
+
+ 0 "\x00" "\x00" 0 '\x00'
+ 15 "\x0f" "\x0f" 15 '\x0f'
+ 30 "\x1e" "\x1e" 30 '\x1e'
+ 45 "-" "-" 45 '-'
+ 60 "<" "<" 60 '<'
+ 75 "K" "K" 75 'K'
+ 90 "Z" "Z" 90 'Z'
+105 "i" "i" 105 'i'
+120 "x" "x" 120 'x'
+135 "\x87" "\x87" 135 '\x87'
+150 "\x96" "\x96" 150 '\x96'
+165 "\xa5" "\xa5" 165 '\xa5'
+180 "\xb4" "\xb4" 180 '\xb4'
+195 "\xc3" "\xc3" 195 '\xc3'
+210 "\xd2" "\xd2" 210 '\xd2'
+225 "\xe1" "\xe1" 225 '\xe1'
+240 "\xf0" "\xf0" 240 '\xf0'
+255 "\xff" "\xff" 255 '\xff'
+
+ 0 "\x00" 0
+ 15.71 "\x0f" 15
+ "32rU" "\x1e" 30
+ "16r2D" "-" 45
+ "60" "<" 60
+ "8r113" "K" 75
+ "90" "Z" 90
+ "105" "i" 105
+ "120" "x" 120
+ "8r207" "\x87" 135
+ "16r96" "\x96" 150
+ "16ra5" "\xa5" 165
+ "16rB4" "\xb4" 180
+ "16rc3" "\xc3" 195
+ "16rD2" "\xd2" 210
+ "16re1" "\xe1" 225
+ "16rf0" "\xf0" 240
+ "16rfF" "\xff" 255
+
+"\x00" 0 "\x00"
+"\x0f" 15 "\x0f"
+"\x1e" 30 "\x1e"
+ "-" 45 "-"
+ "<" 60 "<"
+ "K" 75 "K"
+ "Z" 90 "Z"
+ "i" 105 "i"
+ "x" 120 "x"
+"\x87" 135 "\x87"
+"\x96" 150 "\x96"
+"\xa5" 165 "\xa5"
+"\xb4" 180 "\xb4"
+"\xc3" 195 "\xc3"
+"\xd2" 210 "\xd2"
+"\xe1" 225 "\xe1"
+"\xf0" 240 "\xf0"
+"\xff" 255 "\xff"
+
+'\x00' "\x00" 0
+'\x0f' "\x0f" 15
+'\x1e' "\x1e" 30
+ '-' "-" 45
+ '<' "<" 60
+ 'K' "K" 75
+ 'Z' "Z" 90
+ 'i' "i" 105
+ 'x' "x" 120
+'\x87' "\x87" 135
+'\x96' "\x96" 150
+'\xa5' "\xa5" 165
+'\xb4' "\xb4" 180
+'\xc3' "\xc3" 195
+'\xd2' "\xd2" 210
+'\xe1' "\xe1" 225
+'\xf0' "\xf0" 240
+'\xff' "\xff" 255
diff --git a/tests/general/cxprimes.icn b/tests/general/cxprimes.icn
new file mode 100644
index 0000000..25a5df7
--- /dev/null
+++ b/tests/general/cxprimes.icn
@@ -0,0 +1,20 @@
+# prime number generation using co-expressions
+
+procedure main(args)
+ local s, n, x
+
+ n := integer(get(args)) | 100
+ s := create (2 to n)
+ while (x := @s) do {
+ write(x)
+ s := create sieve(x, s)
+ }
+end
+
+procedure sieve(x, s)
+ local t
+
+ while t := @s do {
+ if t % x ~= 0 then suspend t
+ }
+end
diff --git a/tests/general/cxprimes.std b/tests/general/cxprimes.std
new file mode 100644
index 0000000..afc67fd
--- /dev/null
+++ b/tests/general/cxprimes.std
@@ -0,0 +1,25 @@
+2
+3
+5
+7
+11
+13
+17
+19
+23
+29
+31
+37
+41
+43
+47
+53
+59
+61
+67
+71
+73
+79
+83
+89
+97
diff --git a/tests/general/diffwrds.dat b/tests/general/diffwrds.dat
new file mode 100644
index 0000000..4d609c1
--- /dev/null
+++ b/tests/general/diffwrds.dat
@@ -0,0 +1,12 @@
+procedure main()
+ local limit, s, i
+ limit := 100
+ s := set([])
+ every insert(s,1 to limit)
+ every member(s,i := 2 to limit) do
+ every delete(s,i + i to limit by i)
+ primes := sort(s)
+ write("There are ",*primes," primes in the first ",limit," integers.")
+ write("The primes are:")
+ every write(right(!primes,*limit + 1))
+end
diff --git a/tests/general/diffwrds.icn b/tests/general/diffwrds.icn
new file mode 100644
index 0000000..5b5e4de
--- /dev/null
+++ b/tests/general/diffwrds.icn
@@ -0,0 +1,14 @@
+#
+# D I F F E R E N T W O R D S
+#
+
+# This program lists all the different words in the input text.
+# The definition of a "word" is naive.
+
+procedure main()
+ words := set()
+ while text := read() do
+ text ? while tab(upto(&letters)) do
+ insert(words,tab(many(&letters)))
+ every write(!sort(words))
+end
diff --git a/tests/general/diffwrds.std b/tests/general/diffwrds.std
new file mode 100644
index 0000000..52526b8
--- /dev/null
+++ b/tests/general/diffwrds.std
@@ -0,0 +1,26 @@
+The
+There
+are
+by
+delete
+do
+end
+every
+first
+i
+in
+insert
+integers
+limit
+local
+main
+member
+primes
+procedure
+right
+s
+set
+sort
+the
+to
+write
diff --git a/tests/general/endetab.dat b/tests/general/endetab.dat
new file mode 100644
index 0000000..76976a8
--- /dev/null
+++ b/tests/general/endetab.dat
@@ -0,0 +1,258 @@
+## test data for entab/detab tester; see driver program's comments for details
+#
+# Remember that the characters --> "!.$" <-- are metacharacters, and cannot
+# be used randomly for punctuation; I got away with it that time by placing
+# them carefully <stop>
+
+# first try with default parameters (9,17,25,33,etc)
+
+x
+ x
+ x
+ x
+ x
+ x
+ x
+ x
+!.......x
+!....... x
+!....... x
+!....... x
+!....... x
+!....... x
+!....... x
+!....... x
+!.......!.......x
+x!......!.......x
+ x!.....!.......x
+ x!....!.......x
+ x!...!.......x
+ x!..!.......x
+ x!.!.......x
+ x!!.......x # tab replaces one char as part of longer run
+ x!.......x
+!.......x!......x
+!....... x!.....x
+!....... x!....x
+!....... x!...x
+!....... x!..x
+!....... x!.x
+!....... x x # tab does not replace one-char run
+!....... xx
+!.......!.......x
+abcde!..x
+abcdef!.x
+abcdefg x
+abcdefg x
+abcdefg x
+abcdefg x
+abcdefg x
+abcdefg x
+abcdefg x
+abcdefg x
+abcdefg!!.......x
+
+# test some lines with trailing spaces
+$
+ $
+ $
+ $
+ $
+ $
+ $
+ $
+!.......$
+!....... $
+!....... $
+!....... $
+!....... $
+!....... $
+!....... $
+!....... $
+!.......!.......$
+!.......!....... $
+!.......!....... $
+
+!.......!.......!.......!.......!.......!.......!.......!....... wxyz
+!.......!.......!.......!.......!.......!.......!.......!.......!.......xyz
+!.......!.......!.......!.......!.......!.......!.......!.......!....... yz
+!.......!.......!.......!.......!.......!.......!.......!.......!....... z
+
+!.......ENTRY!..SUUO
+!.......ENTRY!..NUUO
+!.......CAI!....1,[BYTE (9)"s","u","u","o","/","n","u","u","o",0]
+SUUO:!..TRZA!...T1,1!...!.......; flag suuo call
+NUUO:!..TRO!....T1,1!...!.......; flag nuuo call
+!.......MOVE!...T0,1-OFF(P)!....; get UUO code
+!.......MOVEM!..T0,UUO!.!.......; save uuo
+!.......MOVE!...T0,2-OFF(P)!....; load register value
+!.......XCT!....UUO!....!.......; issue UUO
+!....... TRZE!..T1,1!...!.......; skip unless non-skip from nuuo call
+!....... TRZE!..T1,1!...!.......; skip unless skip-return from nuuo call
+!....... HRREI!.T0,ERR!.!.......; indicate UUO failure
+!.......MOVE!...T1,T0!..!.......; return result in r1
+!.......POPJ!...P,!.....!.......; return
+
+# now try tabs every 4 columns
+= entab(s,5)
+
+x
+xx
+ xx
+ x x
+ x x
+ x x
+ x x
+ x x
+!...x!..x
+!...x!.. x
+!... x!. x
+!... x!. x
+!... x!!...x
+!... x!!... x
+!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...xyz
+
+xxxx
+xxx x
+xxx x
+xxx x
+xxx x
+xxx!!...x
+xxx!!... x
+
+xxx$
+xxx $
+xxx $
+xxx $
+xxx $
+xxx!!...$
+xxx!!... $
+
+smatch(s1,s2)
+char *s1, *s2;
+{
+!...while (~((*s1 ^ *s2) & 0137))
+!...!...if (~*s1)
+!...!...!...return 0;
+!...!...else
+!...!...!...s1++, s2++;
+!...return ((*s1 & 0137) - (*s2 & 0137));
+}
+
+# try col 8, then every 4
+= entab(s,8,12)
+!......01!.student-record
+!......!...03!.name pic x(25)
+!......!...03!.home-address
+!......!...!...05!.city pic x(15)
+!......!...!...05!.state pic xx
+!......!...!...05!.big-zip
+!......!...!...!...07!.zip pic 9(5)
+!......!...!...!...07!.plus-4 pic 9(4)
+!......!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...!...xyz
+
+# try irregular columns
+= entab(11,18,30,36)
+!.........entry!.sys=
+ sys2!....xj
+ sys3!....sa1!...a6
+!.........lx1!...59-40
+!.........mi x1,sys3!......wait until done if RCL bit set
+ sys=!....subr!..=!..........entry / exit
+ sys1!....sa1!...1
+!.........nz x1,sys1!......wait ra+1 clear
+!.........sa6!...1!..........store request
+!.........eq sys2
+!.........!.......!..........!.....!.....!.....!.....!.....!.....!..... xyz
+
+# and now for something completely different
+= entab(s,11,60)
+# (11,60,61) would need less scratch space on detab but few will know/use this
+
+loop:!....line = input!....................................:f(end)
+!.........output = line!...................................:(loop)
+
+# end cases
+= entab(s,2)
+x
+ x
+!!x
+!!!x
+!!!!x
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!xyz
+
+= entab(s,2,4)
+x
+ x
+ x
+!!.x
+!!. x
+!!.!.x
+!!.!.!.!.!.!.!.!.!.!.xyz
+!!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.xyz
+
+= entab(s,3)
+x
+ x
+!.x
+!. x
+!.!.x
+!.!.!.!.!.!.!.!.!.!.xyz
+!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.!.xyz
+
+= entab(s,3,4)
+x
+ x
+!.x
+!.!x
+!.!!x
+!.!!!x
+!.!!!!x
+!.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!xyz
+
+# now go back to an interval of 4 and test special characters in input
+= entab(s,5)
+
+# first, just tabs in the input
+\t$
+\t $
+\t $
+\t $
+\t!...$
+ \t!...$
+ \t!...$
+ \t!...$
+!...\t!...$
+\tx
+\t x
+\t x
+\t x
+\t!...x
+ \t!...x
+ \t!...x
+ \t!...x
+!...\t!...x
+abc\tdef\tghi\tjkl
+
+
+smatch(s1,s2)
+char *s1, *s2;
+{
+\twhile (~((*s1 ^ *s2) & 0137))
+\t\tif (~*s1)
+!...!...!...return 0;
+ \t\telse
+!...!...!...s1++, s2++;
+ \treturn ((*s1 & 0137) - (*s2 & 0137));
+}
+
+# now some backspaces
+abc\b!.de\b!..fghij\b!...k
+
+# use irregular stops for testing wierder situations
+= entab(5,7,10)
+!...!.!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..!..
+!...!.!..\b\b\b\b\b\b\b\b\b!...!.!..!..
+!...!.!..\n!...!.!..\r!...!.!..\n\r!...!.!..\r\n!...!.!..
+!...\a!.\a!..\a!..
+!...\b\b\b\b!...\b\a\b\a!.!.!..\n\n\n \t!.!..\n
diff --git a/tests/general/endetab.icn b/tests/general/endetab.icn
new file mode 100644
index 0000000..b84ef08
--- /dev/null
+++ b/tests/general/endetab.icn
@@ -0,0 +1,145 @@
+# test type conversion and error handling in entab/detab
+
+procedure main ()
+ s := "rutabaga"
+ if entab('1987') ~== "1789" then write ("oops 1")
+ if detab('1492') ~== "1249" then write ("oops 2")
+ if entab(" ","3") ~== "\t\t" then write ("oops 3")
+ if detab("\t\t","3") ~== " " then write ("oops 4")
+ ferr (103, entab, [])
+ ferr (103, detab, [])
+ ferr (103, entab, [[]])
+ ferr (103, detab, [[]])
+ ferr (101, entab, [s,2,3,&lcase])
+ ferr (101, detab, [s,4,5,&ucase])
+ ferr (210, entab, [s,7,4])
+ ferr (210, entab, [s,6,6])
+ ferr (210, detab, [s,8,5])
+ ferr (210, detab, [s,3,3])
+
+ endetab1()
+
+ end
+
+
+# ferr(err,func,arglst) -- call func(args), verify that error "err" is produced
+
+procedure ferr (err, func, args)
+ local val
+
+ val := ""
+ every val ||:= image(!args) || ","
+ val := val[1:-1]
+ msg := "oops -- " || image(func) || "(" || val || ") "
+ &error := 1
+ if func!args
+ then write (msg, "succeeded")
+ else if &error ~= 0
+ then write (msg, "failed but no error")
+ else if &errornumber ~= err
+ then write (msg, "got error ",&errornumber," instead of ",err)
+ &error := 0
+ return
+ end
+
+## Test driver for entab and detab
+#
+# Input is read from standard input. Commentary and error reports go to
+# standard output.
+#
+# Input lines are first preprocessed by interpreting escape sequences \a, \b,
+# \n, \r, and \t and trimming a trailing '$' character.
+#
+# Input lines beginning with "=" establish tab stop settings. Each numeric
+# field specifies a tab stop, according to the entab/detab specs.
+#
+# All other lines are passed through entab and then detab, and the results are
+# checked. The characters "!" and "." are replaced by spaces before calling
+# entab; "!" positions are expected to be replaced by tabs, with "." positions
+# disappearing. For example, "abcd!...ijk" tests that entab("abcd ijk")
+# returns "abcd\tijk".
+#
+# The result of each entab call is then passed to detab, with results expected
+# to match the original entab argument (or its detab, if it had any tabs).
+
+procedure endetab1 ()
+ params := setup ("=") # start with default tabs (no args)
+ while line := escape (read ()) do { # read and preprocess line
+ if line[1] == "=" then
+ params := setup (line) # '=' line sets tab stops (arg list)
+ else {
+ s := map (line, "!.", " ") # turn "!." characters into spaces
+ params[1] := s
+ t := invoke (entab, params) # run entab
+ if t ~== interp (line) then { # check results
+ write ("entab failed for: ", map(line,"\t\r\n\b\007","!RNBA"))
+ write (" returned value: ", map(t, "\t\r\n\b\007","!RNBA"))
+ } else {
+ if upto ('\t', s) then # detab input if it had a tab
+ s := invoke (detab, params)
+ params[1] := t
+ t := invoke (detab, params) # detab the result of the entab
+ if t ~== s then { # compare results
+ write ("detab failed for: ", map(line,"\t\r\n\b\007","!RNBA"))
+ write (" returned value: ", map(t, "\t\r\n\b\007","!RNBA"))
+ }
+ }
+ }
+ }
+ end
+
+procedure escape (line) # interpret escape sequences and trim one '$'
+ if line[-1] == "$" then
+ line := line[1:-1]
+ s := ""
+ line ?
+ while not pos (0) do {
+ s ||:= tab (upto ('\\') | 0)
+ s ||:= (="\\" & case (c := move(1)) of {
+ "a": "\007"
+ "b": "\b"
+ "n": "\n"
+ "r": "\r"
+ "t": "\t"
+ default: "\\" || c
+ })
+ }
+ return s
+ end
+
+procedure interp (pattern) # interpret metacharacters '!.'
+ s := ""
+ pattern ?
+ while not pos (0) do {
+ tab (many ('.'))
+ s ||:= tab (upto ('.') | 0)
+ }
+ return map (s, "!", "\t")
+ end
+
+procedure setup (line) # interpret and report a column spec line
+ p := [&null]
+ line ? while tab (upto (&digits)) do
+ put (p, integer (tab (many (&digits))))
+ writes ("testing entab/detab(s")
+ every writes (",", \!p)
+ write (")")
+ return p
+ end
+
+procedure invoke (func, a) # invoke a function with a list of up to 10 args
+ return case *a of {
+ 0: func ()
+ 1: func (a[1])
+ 2: func (a[1], a[2])
+ 3: func (a[1], a[2], a[3])
+ 4: func (a[1], a[2], a[3], a[4])
+ 5: func (a[1], a[2], a[3], a[4], a[5])
+ 6: func (a[1], a[2], a[3], a[4], a[5], a[6])
+ 7: func (a[1], a[2], a[3], a[4], a[5], a[6], a[7])
+ 8: func (a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8])
+ 9: func (a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9])
+ 10: func (a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10])
+ default: stop ("too many args for invoke")
+ }
+ end
diff --git a/tests/general/endetab.std b/tests/general/endetab.std
new file mode 100644
index 0000000..dddfbce
--- /dev/null
+++ b/tests/general/endetab.std
@@ -0,0 +1,11 @@
+testing entab/detab(s)
+testing entab/detab(s,5)
+testing entab/detab(s,8,12)
+testing entab/detab(s,11,18,30,36)
+testing entab/detab(s,11,60)
+testing entab/detab(s,2)
+testing entab/detab(s,2,4)
+testing entab/detab(s,3)
+testing entab/detab(s,3,4)
+testing entab/detab(s,5)
+testing entab/detab(s,5,7,10)
diff --git a/tests/general/env.icn b/tests/general/env.icn
new file mode 100644
index 0000000..f048c2c
--- /dev/null
+++ b/tests/general/env.icn
@@ -0,0 +1,14 @@
+procedure main()
+ write()
+ write("&host: ", &host)
+ write("&dateline: ", &dateline)
+ write(" &date: ", &date)
+ write(" &clock: ", &clock)
+ write("&version: ", &version)
+ write("&features:")
+ every write(" ", &features)
+ write("getenv(\"HOME\"): ", getenv("HOME") | "[failed]")
+ write("getenv(\"SHELL\"): ", getenv("SHELL") | "[failed]")
+ write("uname -a: ", read(open("uname -a", "p")) | "[failed]")
+ write()
+end
diff --git a/tests/general/errkwds.icn b/tests/general/errkwds.icn
new file mode 100644
index 0000000..c61a771
--- /dev/null
+++ b/tests/general/errkwds.icn
@@ -0,0 +1,25 @@
+#SRC: JCON
+#OPT: -fe
+
+procedure main()
+ write(&error)
+ write(&errornumber | "fail")
+ write(&errortext | "fail")
+ write(image(&errorvalue) | "fail")
+ &error := 1
+ write(&error)
+ write(&null() | "fail")
+ write(&error)
+ write(&errornumber | "fail")
+ write(&errortext | "fail")
+ write(image(&errorvalue) | "fail")
+ write(&error)
+ write(&errornumber | "fail")
+ write(&errortext | "fail")
+ write(image(&errorvalue) | "fail")
+ errorclear()
+ write(&error)
+ write(&errornumber | "fail")
+ write(&errortext | "fail")
+ write(image(&errorvalue) | "fail")
+end
diff --git a/tests/general/errkwds.std b/tests/general/errkwds.std
new file mode 100644
index 0000000..5f057ab
--- /dev/null
+++ b/tests/general/errkwds.std
@@ -0,0 +1,18 @@
+0
+fail
+fail
+fail
+1
+fail
+0
+106
+procedure or integer expected
+&null
+0
+106
+procedure or integer expected
+&null
+0
+fail
+fail
+fail
diff --git a/tests/general/errors.icn b/tests/general/errors.icn
new file mode 100644
index 0000000..fa3b776
--- /dev/null
+++ b/tests/general/errors.icn
@@ -0,0 +1,203 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write("seq(\"a\") | monitor(&line) ----> ",
+ image(seq("a") | monitor(&line)) | "none")
+ write("\"|\"(1,2) | monitor(&line) ----> ",
+ image("|"(1,2) | monitor(&line)) | "none")
+ write("member(x,x) | monitor(&line) ----> ",
+ image(member(x,x) | monitor(&line)) | "none")
+ write("(set([]) ++ 'a') | monitor(&line) ----> ",
+ image((set([]) ++ 'a') | monitor(&line)) | "none")
+ write("(every i := 1 to *a - 1 by 2 do write(image(a[i]),\" \",a[i + 1])) | monitor(&line) ----> ",
+ image((every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | monitor(&line)) | "none")
+ write("(every i := 1 to *a - 1 by 2 do write(image(a[i]),\" \",a[i + 1])) | monitor(&line) ----> ",
+ image((every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | monitor(&line)) | "none")
+ write("(c |||:= s) | monitor(&line) ----> ",
+ image((c |||:= s) | monitor(&line)) | "none")
+ write("?&null | monitor(&line) ----> ",
+ image(?&null | monitor(&line)) | "none")
+ write("c[1] | monitor(&line) ----> ",
+ image(c[1] | monitor(&line)) | "none")
+ write("(image + image) | monitor(&line) ----> ",
+ image((image + image) | monitor(&line)) | "none")
+ write(".1(s[1],s := &null) | monitor(&line) ----> ",
+ image(.1(s[1],s := &null) | monitor(&line)) | "none")
+end
+
+procedure p2()
+ write("display(,[]) | monitor(&line) ----> ",
+ image(display(,[]) | monitor(&line)) | "none")
+ write("([] ~== \"x\") | monitor(&line) ----> ",
+ image(([] ~== "x") | monitor(&line)) | "none")
+ write("(x + 1) | monitor(&line) ----> ",
+ image((x + 1) | monitor(&line)) | "none")
+ write("\"a\"(1,2,3) | monitor(&line) ----> ",
+ image("a"(1,2,3) | monitor(&line)) | "none")
+ write("(\"o\" + 0) | monitor(&line) ----> ",
+ image(("o" + 0) | monitor(&line)) | "none")
+ write("(&cset ++ []) | monitor(&line) ----> ",
+ image((&cset ++ []) | monitor(&line)) | "none")
+ write("(every 1 to \"a\") | monitor(&line) ----> ",
+ image((every 1 to "a") | monitor(&line)) | "none")
+ write("!image | monitor(&line) ----> ",
+ image(!image | monitor(&line)) | "none")
+end
+
+procedure p3()
+ write("(0 to 0 by 0) | monitor(&line) ----> ",
+ image((0 to 0 by 0) | monitor(&line)) | "none")
+ write("repl(\"b\",\"a\") | monitor(&line) ----> ",
+ image(repl("b","a") | monitor(&line)) | "none")
+ write("t(t) | monitor(&line) ----> ",
+ image(t(t) | monitor(&line)) | "none")
+ write("sort(&cset) | monitor(&line) ----> ",
+ image(sort(&cset) | monitor(&line)) | "none")
+ write("pull(&null) | monitor(&line) ----> ",
+ image(pull(&null) | monitor(&line)) | "none")
+ write("c[-4] | monitor(&line) ----> ",
+ image(c[-4] | monitor(&line)) | "none")
+ write("(type(type)(type)) | monitor(&line) ----> ",
+ image((type(type)(type)) | monitor(&line)) | "none")
+ write("r[r] | monitor(&line) ----> ",
+ image(r[r] | monitor(&line)) | "none")
+ write("([] ** \"abc\") | monitor(&line) ----> ",
+ image(([] ** "abc") | monitor(&line)) | "none")
+ write("('abc' ~= ('abc' ++ '')) | monitor(&line) ----> ",
+ image(('abc' ~= ('abc' ++ '')) | monitor(&line)) | "none")
+end
+
+procedure p4()
+ write("(&lcase || numeric) | monitor(&line) ----> ",
+ image((&lcase || numeric) | monitor(&line)) | "none")
+ write("x[\"a\"] | monitor(&line) ----> ",
+ image(x["a"] | monitor(&line)) | "none")
+ write("(100-()) | monitor(&line) ----> ",
+ image((100-()) | monitor(&line)) | "none")
+ write("((1 := y) & &fail) | monitor(&line) ----> ",
+ image(((1 := y) & &fail) | monitor(&line)) | "none")
+ write("(a[1:3] := a) | monitor(&line) ----> ",
+ image((a[1:3] := a) | monitor(&line)) | "none")
+ write("(a[3] :=: a3[&null]) | monitor(&line) ----> ",
+ image((a[3] :=: a3[&null]) | monitor(&line)) | "none")
+ write("a5[a5] | monitor(&line) ----> ",
+ image(a5[a5] | monitor(&line)) | "none")
+ write("pull[c] | monitor(&line) ----> ",
+ image(pull[c] | monitor(&line)) | "none")
+ write("(&subject := []) | monitor(&line) ----> ",
+ image((&subject := []) | monitor(&line)) | "none")
+ write("([] ? []) | monitor(&line) ----> ",
+ image(([] ? []) | monitor(&line)) | "none")
+ write("+\"a\" | monitor(&line) ----> ",
+ image(+"a" | monitor(&line)) | "none")
+end
+
+procedure p5()
+ write("(i <= []) | monitor(&line) ----> ",
+ image((i <= []) | monitor(&line)) | "none")
+ write("([] ^ i) | monitor(&line) ----> ",
+ image(([] ^ i) | monitor(&line)) | "none")
+ write("(s ?:= &subject[3]) | monitor(&line) ----> ",
+ image((s ?:= &subject[3]) | monitor(&line)) | "none")
+ write("(s >>:= 0) | monitor(&line) ----> ",
+ image((s >>:= 0) | monitor(&line)) | "none")
+ write("(s = 0) | monitor(&line) ----> ",
+ image((s = 0) | monitor(&line)) | "none")
+ write("put(s) | monitor(&line) ----> ",
+ image(put(s) | monitor(&line)) | "none")
+ write("('abc' = ('abc' ++ '')) | monitor(&line) ----> ",
+ image(('abc' = ('abc' ++ '')) | monitor(&line)) | "none")
+ write("=[] | monitor(&line) ----> ",
+ image(=[] | monitor(&line)) | "none")
+ write("((1 <-> y) & &fail) | monitor(&line) ----> ",
+ image(((1 <-> y) & &fail) | monitor(&line)) | "none")
+ write("!&null | monitor(&line) ----> ",
+ image(!&null | monitor(&line)) | "none")
+ write("(2 \\ \"a\") | monitor(&line) ----> ",
+ image((2 \ "a") | monitor(&line)) | "none")
+end
+
+procedure p6()
+ write("right(\"\",\"\") | monitor(&line) ----> ",
+ image(right("","") | monitor(&line)) | "none")
+ write("close(\"F\") | monitor(&line) ----> ",
+ image(close("F") | monitor(&line)) | "none")
+ write("trim(&lcase,[]) | monitor(&line) ----> ",
+ image(trim(&lcase,[]) | monitor(&line)) | "none")
+ write("list([]) | monitor(&line) ----> ",
+ image(list([]) | monitor(&line)) | "none")
+ write("reads(f,0) | monitor(&line) ----> ",
+ image(reads(f,0) | monitor(&line)) | "none")
+ write("read(\"f\") | monitor(&line) ----> ",
+ image(read("f") | monitor(&line)) | "none")
+ write("bal([],,,\"\") | monitor(&line) ----> ",
+ image(bal([],,,"") | monitor(&line)) | "none")
+ write("pos(\"a\") | monitor(&line) ----> ",
+ image(pos("a") | monitor(&line)) | "none")
+ write(("\"abcdef\" ? (tab(0) & (while write(move(\"a\"))))) | monitor(&line) ----> ",
+ image(("abcdef" ? (tab(0) & (while write(move("a")))))) | monitor(&line)) | "none")
+ write("(2 % \"a\") | monitor(&line) ----> ",
+ image((2 % "a") | monitor(&line)) | "none")
+end
+
+procedure p7()
+ write("(2 * \"a\") | monitor(&line) ----> ",
+ image((2 * "a") | monitor(&line)) | "none")
+ write("(2 / \"a\") | monitor(&line) ----> ",
+ image((2 / "a") | monitor(&line)) | "none")
+ write("(2 + \"a\") | monitor(&line) ----> ",
+ image((2 + "a") | monitor(&line)) | "none")
+ write("(-36 ^ -9) | monitor(&line) ----> ",
+ image((-36 ^ -9) | monitor(&line)) | "none")
+ write("(2 < \"a\") | monitor(&line) ----> ",
+ image((2 < "a") | monitor(&line)) | "none")
+ write("(0 > &null) | monitor(&line) ----> ",
+ image((0 > &null) | monitor(&line)) | "none")
+ write("(2 <= \"a\") | monitor(&line) ----> ",
+ image((2 <= "a") | monitor(&line)) | "none")
+ write("(2 > \"a\") | monitor(&line) ----> ",
+ image((2 > "a") | monitor(&line)) | "none")
+ write("(2 = \"a\") | monitor(&line) ----> ",
+ image((2 = "a") | monitor(&line)) | "none")
+ write("(2 ~= \"a\") | monitor(&line) ----> ",
+ image((2 ~= "a") | monitor(&line)) | "none")
+ write("(list(10)) ||| \"abc\" | monitor(&line) ----> ",
+ image((list(10)) ||| "abc" | monitor(&line)) | "none")
+end
+
+procedure p8()
+ write("(x :=: \"a\") | monitor(&line) ----> ",
+ image((x :=: "a") | monitor(&line)) | "none")
+ write("(x <-> \"b\") | monitor(&line) ----> ",
+ image((x <-> "b") | monitor(&line)) | "none")
+ write("((x & 2 & 3 & 4) := 3) | monitor(&line) ----> ",
+ image(((x & 2 & 3 & 4) := 3) | monitor(&line)) | "none")
+ write("((1 <- y) & &fail) | monitor(&line) ----> ",
+ image(((1 <- y) & &fail) | monitor(&line)) | "none")
+ write("(-36. ^ -9.) | monitor(&line) ----> ",
+ image((-36. ^ -9.) | monitor(&line)) | "none")
+end
+
+procedure main()
+ &error := -1
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ write("stop(&output,'testing stop') | monitor(&line) ----> ",
+ image(stop(&output,'testing stop') | monitor(&line)) | "none")
+end
+
+procedure monitor(line)
+ write("\nerror in line ",line,":")
+ write(" &error = ",&error)
+ write(" &errornumber = ",&errornumber)
+ write(" &errortext = ",
+ image(&errortext))
+ write(" &errorvalue = ", image(&errorvalue))
+ return line
+end
diff --git a/tests/general/errors.std b/tests/general/errors.std
new file mode 100644
index 0000000..25cd604
--- /dev/null
+++ b/tests/general/errors.std
@@ -0,0 +1,533 @@
+
+error in line 5:
+ &error = -2
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = "a"
+seq("a") | monitor(&line) ----> 5
+
+error in line 7:
+ &error = -3
+ &errornumber = 106
+ &errortext = "procedure or integer expected"
+ &errorvalue = "|"
+"|"(1,2) | monitor(&line) ----> 7
+
+error in line 9:
+ &error = -4
+ &errornumber = 122
+ &errortext = "set or table expected"
+ &errorvalue = &null
+member(x,x) | monitor(&line) ----> 9
+
+error in line 11:
+ &error = -5
+ &errornumber = 120
+ &errortext = "two csets or two sets expected"
+ &errorvalue = set_1(0)
+(set([]) ++ 'a') | monitor(&line) ----> 11
+
+error in line 13:
+ &error = -6
+ &errornumber = 112
+ &errortext = "invalid type to size operation"
+ &errorvalue = &null
+(every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | monitor(&line) ----> 13
+
+error in line 15:
+ &error = -7
+ &errornumber = 112
+ &errortext = "invalid type to size operation"
+ &errorvalue = &null
+(every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | monitor(&line) ----> 15
+
+error in line 17:
+ &error = -8
+ &errornumber = 108
+ &errortext = "list expected"
+ &errorvalue = &null
+(c |||:= s) | monitor(&line) ----> 17
+
+error in line 19:
+ &error = -9
+ &errornumber = 113
+ &errortext = "invalid type to random operation"
+ &errorvalue = &null
+?&null | monitor(&line) ----> 19
+
+error in line 21:
+ &error = -10
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+c[1] | monitor(&line) ----> 21
+
+error in line 23:
+ &error = -11
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = function image
+(image + image) | monitor(&line) ----> 23
+
+error in line 25:
+ &error = -12
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+.1(s[1],s := &null) | monitor(&line) ----> 25
+
+error in line 30:
+ &error = -13
+ &errornumber = 105
+ &errortext = "file expected"
+ &errorvalue = list_2(0)
+display(,[]) | monitor(&line) ----> 30
+
+error in line 32:
+ &error = -14
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = list_3(0)
+([] ~== "x") | monitor(&line) ----> 32
+
+error in line 34:
+ &error = -15
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = &null
+(x + 1) | monitor(&line) ----> 34
+
+error in line 36:
+ &error = -16
+ &errornumber = 106
+ &errortext = "procedure or integer expected"
+ &errorvalue = "a"
+"a"(1,2,3) | monitor(&line) ----> 36
+
+error in line 38:
+ &error = -17
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "o"
+("o" + 0) | monitor(&line) ----> 38
+
+error in line 40:
+ &error = -18
+ &errornumber = 120
+ &errortext = "two csets or two sets expected"
+ &errorvalue = list_4(0)
+(&cset ++ []) | monitor(&line) ----> 40
+
+error in line 42:
+ &error = -19
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = "a"
+(every 1 to "a") | monitor(&line) ----> 42
+
+error in line 44:
+ &error = -20
+ &errornumber = 116
+ &errortext = "invalid type to element generator"
+ &errorvalue = function image
+!image | monitor(&line) ----> 44
+
+error in line 49:
+ &error = -21
+ &errornumber = 211
+ &errortext = "by value equal to zero"
+ &errorvalue = 0
+(0 to 0 by 0) | monitor(&line) ----> 49
+
+error in line 51:
+ &error = -22
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = "a"
+repl("b","a") | monitor(&line) ----> 51
+
+error in line 53:
+ &error = -23
+ &errornumber = 106
+ &errortext = "procedure or integer expected"
+ &errorvalue = &null
+t(t) | monitor(&line) ----> 53
+
+error in line 55:
+ &error = -24
+ &errornumber = 115
+ &errortext = "structure expected"
+ &errorvalue = &cset
+sort(&cset) | monitor(&line) ----> 55
+
+error in line 57:
+ &error = -25
+ &errornumber = 108
+ &errortext = "list expected"
+ &errorvalue = &null
+pull(&null) | monitor(&line) ----> 57
+
+error in line 59:
+ &error = -26
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+c[-4] | monitor(&line) ----> 59
+
+error in line 61:
+ &error = -27
+ &errornumber = 106
+ &errortext = "procedure or integer expected"
+ &errorvalue = "procedure"
+(type(type)(type)) | monitor(&line) ----> 61
+
+error in line 63:
+ &error = -28
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+r[r] | monitor(&line) ----> 63
+
+error in line 65:
+ &error = -29
+ &errornumber = 120
+ &errortext = "two csets or two sets expected"
+ &errorvalue = list_5(0)
+([] ** "abc") | monitor(&line) ----> 65
+
+error in line 67:
+ &error = -30
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = 'abc'
+('abc' ~= ('abc' ++ '')) | monitor(&line) ----> 67
+
+error in line 72:
+ &error = -31
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = function numeric
+(&lcase || numeric) | monitor(&line) ----> 72
+
+error in line 74:
+ &error = -32
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+x["a"] | monitor(&line) ----> 74
+
+error in line 76:
+ &error = -33
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = &null
+(100-()) | monitor(&line) ----> 76
+
+error in line 78:
+ &error = -34
+ &errornumber = 111
+ &errortext = "variable expected"
+ &errorvalue = 1
+((1 := y) & &fail) | monitor(&line) ----> 78
+
+error in line 80:
+ &error = -35
+ &errornumber = 110
+ &errortext = "string or list expected"
+ &errorvalue = &null
+(a[1:3] := a) | monitor(&line) ----> 80
+
+error in line 82:
+ &error = -36
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+(a[3] :=: a3[&null]) | monitor(&line) ----> 82
+
+error in line 84:
+ &error = -37
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = &null
+a5[a5] | monitor(&line) ----> 84
+
+error in line 86:
+ &error = -38
+ &errornumber = 114
+ &errortext = "invalid type to subscript operation"
+ &errorvalue = function pull
+pull[c] | monitor(&line) ----> 86
+
+error in line 88:
+ &error = -39
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = list_6(0)
+(&subject := []) | monitor(&line) ----> 88
+
+error in line 90:
+ &error = -40
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = list_7(0)
+([] ? []) | monitor(&line) ----> 90
+
+error in line 92:
+ &error = -41
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
++"a" | monitor(&line) ----> 92
+
+error in line 97:
+ &error = -42
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = &null
+(i <= []) | monitor(&line) ----> 97
+
+error in line 99:
+ &error = -43
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = list_9(0)
+([] ^ i) | monitor(&line) ----> 99
+
+error in line 101:
+ &error = -44
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = &null
+(s ?:= &subject[3]) | monitor(&line) ----> 101
+
+error in line 103:
+ &error = -45
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = &null
+(s >>:= 0) | monitor(&line) ----> 103
+
+error in line 105:
+ &error = -46
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = &null
+(s = 0) | monitor(&line) ----> 105
+
+error in line 107:
+ &error = -47
+ &errornumber = 108
+ &errortext = "list expected"
+ &errorvalue = &null
+put(s) | monitor(&line) ----> 107
+
+error in line 109:
+ &error = -48
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = 'abc'
+('abc' = ('abc' ++ '')) | monitor(&line) ----> 109
+
+error in line 111:
+ &error = -49
+ &errornumber = 103
+ &errortext = "string expected"
+ &errorvalue = list_10(0)
+=[] | monitor(&line) ----> 111
+
+error in line 113:
+ &error = -50
+ &errornumber = 111
+ &errortext = "variable expected"
+ &errorvalue = 1
+((1 <-> y) & &fail) | monitor(&line) ----> 113
+
+error in line 115:
+ &error = -51
+ &errornumber = 116
+ &errortext = "invalid type to element generator"
+ &errorvalue = &null
+!&null | monitor(&line) ----> 115
+
+error in line 117:
+ &error = -52
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = "a"
+(2 \ "a") | monitor(&line) ----> 117
+
+error in line 122:
+ &error = -53
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = ""
+right("","") | monitor(&line) ----> 122
+
+error in line 124:
+ &error = -54
+ &errornumber = 105
+ &errortext = "file expected"
+ &errorvalue = "F"
+close("F") | monitor(&line) ----> 124
+
+error in line 126:
+ &error = -55
+ &errornumber = 104
+ &errortext = "cset expected"
+ &errorvalue = list_11(0)
+trim(&lcase,[]) | monitor(&line) ----> 126
+
+error in line 128:
+ &error = -56
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = list_12(0)
+list([]) | monitor(&line) ----> 128
+
+error in line 130:
+ &error = -57
+ &errornumber = 205
+ &errortext = "invalid value"
+ &errorvalue = 0
+reads(f,0) | monitor(&line) ----> 130
+
+error in line 132:
+ &error = -58
+ &errornumber = 105
+ &errortext = "file expected"
+ &errorvalue = "f"
+read("f") | monitor(&line) ----> 132
+
+error in line 134:
+ &error = -59
+ &errornumber = 104
+ &errortext = "cset expected"
+ &errorvalue = list_13(0)
+bal([],,,"") | monitor(&line) ----> 134
+
+error in line 136:
+ &error = -60
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = "a"
+pos("a") | monitor(&line) ----> 136
+
+error in line 138:
+ &error = -61
+ &errornumber = 101
+ &errortext = "integer expected or out of range"
+ &errorvalue = "a"
+138
+
+error in line 140:
+ &error = -62
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 % "a") | monitor(&line) ----> 140
+
+error in line 145:
+ &error = -63
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 * "a") | monitor(&line) ----> 145
+
+error in line 147:
+ &error = -64
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 / "a") | monitor(&line) ----> 147
+
+error in line 149:
+ &error = -65
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 + "a") | monitor(&line) ----> 149
+(-36 ^ -9) | monitor(&line) ----> 0
+
+error in line 153:
+ &error = -66
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 < "a") | monitor(&line) ----> 153
+
+error in line 155:
+ &error = -67
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = &null
+(0 > &null) | monitor(&line) ----> 155
+
+error in line 157:
+ &error = -68
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 <= "a") | monitor(&line) ----> 157
+
+error in line 159:
+ &error = -69
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 > "a") | monitor(&line) ----> 159
+
+error in line 161:
+ &error = -70
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 = "a") | monitor(&line) ----> 161
+
+error in line 163:
+ &error = -71
+ &errornumber = 102
+ &errortext = "numeric expected"
+ &errorvalue = "a"
+(2 ~= "a") | monitor(&line) ----> 163
+
+error in line 165:
+ &error = -72
+ &errornumber = 108
+ &errortext = "list expected"
+ &errorvalue = "abc"
+(list(10)) ||| "abc" | monitor(&line) ----> 165
+
+error in line 170:
+ &error = -73
+ &errornumber = 111
+ &errortext = "variable expected"
+ &errorvalue = "a"
+(x :=: "a") | monitor(&line) ----> 170
+
+error in line 172:
+ &error = -74
+ &errornumber = 111
+ &errortext = "variable expected"
+ &errorvalue = "b"
+(x <-> "b") | monitor(&line) ----> 172
+
+error in line 174:
+ &error = -75
+ &errornumber = 111
+ &errortext = "variable expected"
+ &errorvalue = 4
+((x & 2 & 3 & 4) := 3) | monitor(&line) ----> 174
+
+error in line 176:
+ &error = -76
+ &errornumber = 111
+ &errortext = "variable expected"
+ &errorvalue = 1
+((1 <- y) & &fail) | monitor(&line) ----> 176
+
+error in line 178:
+ &error = -77
+ &errornumber = 206
+ &errortext = "negative first argument to real exponentiation"
+(-36. ^ -9.) | monitor(&line) ----> 178
+ eginopst
diff --git a/tests/general/evalx.icn b/tests/general/evalx.icn
new file mode 100644
index 0000000..bf72867
--- /dev/null
+++ b/tests/general/evalx.icn
@@ -0,0 +1,233 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write(" ----> ",image() | "none")
+ write("2 === +2 ----> ",image(2 === +2) | "none")
+ write("3 === *\"abc\" ----> ",image(3 === *"abc") | "none")
+ write("'abc' === ('abc' ++ '') ----> ",image('abc' === ('abc' ++ '')) | "none")
+ write("'a' ----> ",image('a') | "none")
+ write("'ab' ----> ",image('ab') | "none")
+ write("'\\xb9' ----> ",image('\xb9') | "none")
+ write("'\\xb8\\xb4' ----> ",image('\xb8\xb4') | "none")
+ write("'\\^d' ----> ",image('\^d') | "none")
+ write("'\\^a\\^d' ----> ",image('\^a\^d') | "none")
+end
+
+procedure p2()
+ write("\"a\" ----> ",image("a") | "none")
+ write("\"ab\" ----> ",image("ab") | "none")
+ write("\"\\xb9\" ----> ",image("\xb9") | "none")
+ write("\"\\xb8\\xb4\" ----> ",image("\xb8\xb4") | "none")
+ write("\"\\^d\" ----> ",image("\^d") | "none")
+ write("\"\\^a\\^d\" ----> ",image("\^a\^d") | "none")
+ write("*'a' ----> ",image(*'a') | "none")
+ write("*'ab' ----> ",image(*'ab') | "none")
+ write("*'\\xb9' ----> ",image(*'\xb9') | "none")
+ write("*'\\xb8\\xb4' ----> ",image(*'\xb8\xb4') | "none")
+ write("*'\\^d' ----> ",image(*'\^d') | "none")
+end
+
+procedure p3()
+ write("*'\\^a\\^d' ----> ",image(*'\^a\^d') | "none")
+ write("*\"a\" ----> ",image(*"a") | "none")
+ write("*\"ab\" ----> ",image(*"ab") | "none")
+ write("*\"\\xb9\" ----> ",image(*"\xb9") | "none")
+ write("*\"\\xb8\\xb4\" ----> ",image(*"\xb8\xb4") | "none")
+ write("*\"\\^d\" ----> ",image(*"\^d") | "none")
+ write("\"*\\^a\\^d\" ----> ",image("*\^a\^d") | "none")
+ write("every write(\"...\"(1,10,2)) ----> ",image(every write("..."(1,10,2))) | "none")
+ write("every write(\"image\"(write)) ----> ",image(every write("image"(write))) | "none")
+ write("\"[:]\"(\"abcdef\",3,5) ----> ",image("[:]"("abcdef",3,5)) | "none")
+ write("\"[]\"(&lcase,3) ----> ",image("[]"(&lcase,3)) | "none")
+end
+
+procedure p4()
+ write("image(proc(\"^\",1)) ----> ",image(image(proc("^",1))) | "none")
+ write("image(proc(\"^\",2)) ----> ",image(image(proc("^",2))) | "none")
+ write("proc(\"+\",2)(3,4) ----> ",image(proc("+",2)(3,4)) | "none")
+ write("proc(proc)(\"write\") ----> ",image(proc(proc)("write")) | "none")
+ write("proc(\"+\") ----> ",image(proc("+")) | "none")
+ write("?10 ----> ",image(?10) | "none")
+ write("?10 ----> ",image(?10) | "none")
+ write("?10 ----> ",image(?10) | "none")
+ write("?20 ----> ",image(?20) | "none")
+ write("?[1,2,3,4] ----> ",image(?[1,2,3,4]) | "none")
+ write("?[1,2,3,4] ----> ",image(?[1,2,3,4]) | "none")
+end
+
+procedure p5()
+ write("x := array(1,2,3,4,5,6,7) ----> ",image(x := array(1,2,3,4,5,6,7)) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("?x ----> ",image(?x) | "none")
+ write("every 1 to 10 do write(?10) ----> ",image(every 1 to 10 do write(?10)) | "none")
+ write("every 1 to 10 do write(?[1,2,3,4,5,6,7,8,9,10]) ----> ",image(every 1 to 10 do write(?[1,2,3,4,5,6,7,8,9,10])) | "none")
+end
+
+procedure p6()
+ write("every 1 to 10 do write(?\"abcdef\") ----> ",image(every 1 to 10 do write(?"abcdef")) | "none")
+ write("x := array(1,2,3,4,5,6,7) ----> ",image(x := array(1,2,3,4,5,6,7)) | "none")
+ write("every 1 to 10 do write(?x) ----> ",image(every 1 to 10 do write(?x)) | "none")
+ write("(1,2,3,4,5) ----> ",image((1,2,3,4,5)) | "none")
+ write("every write((1 to 5)(1,2,3,4,5)) ----> ",image(every write((1 to 5)(1,2,3,4,5))) | "none")
+ write("0(1,2) ----> ",image(0(1,2)) | "none")
+end
+
+procedure p7()
+ write("1(1) ----> ",image(1(1)) | "none")
+ write("2(1) ----> ",image(2(1)) | "none")
+ write("(-1)(1,2,3) ----> ",image((-1)(1,2,3)) | "none")
+ write("3(1,2,3,&fail) ----> ",image(3(1,2,3,&fail)) | "none")
+ write("every write(2(1 to 5,!\"abc\",1 to 2)) ----> ",image(every write(2(1 to 5,!"abc",1 to 2))) | "none")
+ write("x := 1 ----> ",image(x := 1) | "none")
+ write("y := 2 ----> ",image(y := 2) | "none")
+ write("(x := y) & &fail ----> ",image((x := y) & &fail) | "none")
+ write("every write(!\"abcdef\") ----> ",image(every write(!"abcdef")) | "none")
+ write("every write(![1,2,3,4,5]) ----> ",image(every write(![1,2,3,4,5])) | "none")
+ write("every write(!![1,2,3,4,5]) ----> ",image(every write(!![1,2,3,4,5])) | "none")
+end
+
+procedure p8()
+ write("every write(!![1,\"ab\",[1,2,3],34]) ----> ",image(every write(!![1,"ab",[1,2,3],34])) | "none")
+ write("every write(!([1,\"ab\",[1,2,3],34][1 to 4])) ----> ",image(every write(!([1,"ab",[1,2,3],34][1 to 4]))) | "none")
+ write("x := array(1,2,3,4,5) ----> ",image(x := array(1,2,3,4,5)) | "none")
+ write("every write(!x) ----> ",image(every write(!x)) | "none")
+ write("x := 1 ----> ",image(x := 1) | "none")
+ write("y := 2 ----> ",image(y := 2) | "none")
+ write("x <-> y ----> ",image(x <-> y) | "none")
+ write("y <-> x ----> ",image(y <-> x) | "none")
+ write("(x <-> y) & &fail ----> ",image((x <-> y) & &fail) | "none")
+ write("x ----> ",image(x) | "none")
+ write("y ----> ",image(y) | "none")
+end
+
+procedure p9()
+ write("*\"\" ----> ",image(*"") | "none")
+ write("*'' ----> ",image(*'') | "none")
+ write("*[] ----> ",image(*[]) | "none")
+ write("*table() ----> ",image(*table()) | "none")
+ write("*30 ----> ",image(*30) | "none")
+ write("!\"abc\" ----> ",image(!"abc") | "none")
+ write("![1,2,3] ----> ",image(![1,2,3]) | "none")
+ write("!&lcase ----> ",image(!&lcase) | "none")
+ write("!30 ----> ",image(!30) | "none")
+ write("!table() ----> ",image(!table()) | "none")
+ write("?\"abc\" ----> ",image(?"abc") | "none")
+end
+
+procedure p10()
+ write("?&lcase ----> ",image(?&lcase) | "none")
+ write("?[1,2,3] ----> ",image(?[1,2,3]) | "none")
+ write("?table() ----> ",image(?table()) | "none")
+ write("?30 ----> ",image(?30) | "none")
+ write(".x ----> ",image(.x) | "none")
+ write(".\"abc\" ----> ",image(."abc") | "none")
+ write(".[] ----> ",image(.[]) | "none")
+ write(".main ----> ",image(.main) | "none")
+ write("/main ----> ",image(/main) | "none")
+ write("/\"abc\" ----> ",image(/"abc") | "none")
+end
+
+procedure p11()
+ write("/&null ----> ",image(/&null) | "none")
+ write("/[] ----> ",image(/[]) | "none")
+ write("/&lcase ----> ",image(/&lcase) | "none")
+ write("\\main ----> ",image(\main) | "none")
+ write("\\\"abc\" ----> ",image(\"abc") | "none")
+ write("\\x ----> ",image(\x) | "none")
+ write("\\[] ----> ",image(\[]) | "none")
+ write("\\&null ----> ",image(\&null) | "none")
+ write("1 | 2 | 3 ----> ",image(1 | 2 | 3) | "none")
+ write("|(1 to 10) ----> ",image(|(1 to 10)) | "none")
+ write("||(1 to 10) ----> ",image(||(1 to 10)) | "none")
+end
+
+procedure p12()
+ write("|||(1 to 10) ----> ",image(|||(1 to 10)) | "none")
+ write("||||(1 to 10) ----> ",image(||||(1 to 10)) | "none")
+ write("|||||(1 to 10) ----> ",image(|||||(1 to 10)) | "none")
+ write("|||||||(1 to 10) ----> ",image(|||||||(1 to 10)) | "none")
+ write("2 \\ 2 ----> ",image(2 \ 2) | "none")
+ write("while 1 do break ----> ",image(while 1 do break) | "none")
+ write("while 1 do break \"hello\" ----> ",image(while 1 do break "hello") | "none")
+ write("while break ----> ",image(while break) | "none")
+ write("case 1 of {2:3; \"1\":4; 1: 4 to 10; default: \"whoa\"} ----> ",image(case 1 of {2:3; "1":4; 1: 4 to 10; default: "whoa"}) | "none")
+ write("not 1 ----> ",image(not 1) | "none")
+ write("not \\&null ----> ",image(not \&null) | "none")
+end
+
+procedure p13()
+ write("repeat break ----> ",image(repeat break) | "none")
+ write("until 1 do 2 ----> ",image(until 1 do 2) | "none")
+ write("if 1 then 2 else 3 ----> ",image(if 1 then 2 else 3) | "none")
+ write("every write(if 1 then 1 to 10 else 5) ----> ",image(every write(if 1 then 1 to 10 else 5)) | "none")
+ write("every write(if 1 = 0 then 1 to 10 else 10 to 1 by -1) ----> ",image(every write(if 1 = 0 then 1 to 10 else 10 to 1 by -1)) | "none")
+ write("if 1 then 2 ----> ",image(if 1 then 2) | "none")
+ write("if 1 = 0 then 2 ----> ",image(if 1 = 0 then 2) | "none")
+ write("x := 1 ----> ",image(x := 1) | "none")
+ write("y := 2 ----> ",image(y := 2) | "none")
+ write("z := 3 ----> ",image(z := 3) | "none")
+ write("x :=: y ----> ",image(x :=: y) | "none")
+end
+
+procedure p14()
+ write("y :=: x ----> ",image(y :=: x) | "none")
+ write("x ----> ",image(x) | "none")
+ write("y ----> ",image(y) | "none")
+ write("z ----> ",image(z) | "none")
+ write("x :=: y :=: z ----> ",image(x :=: y :=: z) | "none")
+ write("x ----> ",image(x) | "none")
+ write("y ----> ",image(y) | "none")
+ write("z ----> ",image(z) | "none")
+ write("x := 1 ----> ",image(x := 1) | "none")
+ write("y := 2 ----> ",image(y := 2) | "none")
+ write("z := 3 ----> ",image(z := 3) | "none")
+end
+
+procedure p15()
+ write("x <-> y ----> ",image(x <-> y) | "none")
+ write("y <-> x ----> ",image(y <-> x) | "none")
+ write("x ----> ",image(x) | "none")
+ write("y ----> ",image(y) | "none")
+ write("z ----> ",image(z) | "none")
+ write("x <-> y :=: z ----> ",image(x <-> y :=: z) | "none")
+ write("x ----> ",image(x) | "none")
+ write("y ----> ",image(y) | "none")
+ write("z ----> ",image(z) | "none")
+ write("1 & 2 & 3 & 4 ----> ",image(1 & 2 & 3 & 4) | "none")
+ write("(1 & 2 & 3 & x) := 3 ----> ",image((1 & 2 & 3 & x) := 3) | "none")
+end
+
+procedure p16()
+ write("x ----> ",image(x) | "none")
+ write("x := 1 ----> ",image(x := 1) | "none")
+ write("y := 2 ----> ",image(y := 2) | "none")
+ write("(x <- y) & &fail ----> ",image((x <- y) & &fail) | "none")
+ write("x ----> ",image(x) | "none")
+ write("y ----> ",image(y) | "none")
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+ p10()
+ p11()
+ p12()
+ p13()
+ p14()
+ p15()
+ p16()
+end
+
diff --git a/tests/general/evalx.std b/tests/general/evalx.std
new file mode 100644
index 0000000..14781fd
--- /dev/null
+++ b/tests/general/evalx.std
@@ -0,0 +1,304 @@
+ ----> &null
+2 === +2 ----> 2
+3 === *"abc" ----> 3
+'abc' === ('abc' ++ '') ----> 'abc'
+'a' ----> 'a'
+'ab' ----> 'ab'
+'\xb9' ----> '\xb9'
+'\xb8\xb4' ----> '\xb4\xb8'
+'\^d' ----> '\x04'
+'\^a\^d' ----> '\x01\x04'
+"a" ----> "a"
+"ab" ----> "ab"
+"\xb9" ----> "\xb9"
+"\xb8\xb4" ----> "\xb8\xb4"
+"\^d" ----> "\x04"
+"\^a\^d" ----> "\x01\x04"
+*'a' ----> 1
+*'ab' ----> 2
+*'\xb9' ----> 1
+*'\xb8\xb4' ----> 2
+*'\^d' ----> 1
+*'\^a\^d' ----> 2
+*"a" ----> 1
+*"ab" ----> 2
+*"\xb9" ----> 1
+*"\xb8\xb4" ----> 2
+*"\^d" ----> 1
+"*\^a\^d" ----> "*\x01\x04"
+1
+3
+5
+7
+9
+every write("..."(1,10,2)) ----> none
+function write
+every write("image"(write)) ----> none
+"[:]"("abcdef",3,5) ----> "cd"
+"[]"(&lcase,3) ----> "c"
+image(proc("^",1)) ----> "function ^"
+image(proc("^",2)) ----> "function ^"
+proc("+",2)(3,4) ----> 7
+proc(proc)("write") ----> function write
+proc("+") ----> function +
+?10 ----> 3
+?10 ----> 5
+?10 ----> 4
+?20 ----> 11
+?[1,2,3,4] ----> 2
+?[1,2,3,4] ----> 2
+x := array(1,2,3,4,5,6,7) ----> record array_1(7)
+?x ----> 1
+?x ----> 6
+?x ----> 1
+?x ----> 6
+?x ----> 1
+?x ----> 3
+?x ----> 4
+?x ----> 5
+6
+8
+8
+3
+9
+4
+4
+9
+9
+1
+every 1 to 10 do write(?10) ----> none
+8
+4
+7
+5
+9
+10
+4
+5
+6
+7
+every 1 to 10 do write(?[1,2,3,4,5,6,7,8,9,10]) ----> none
+a
+f
+c
+c
+a
+f
+d
+d
+f
+b
+every 1 to 10 do write(?"abcdef") ----> none
+x := array(1,2,3,4,5,6,7) ----> record array_2(7)
+3
+6
+7
+7
+4
+6
+4
+1
+6
+6
+every 1 to 10 do write(?x) ----> none
+(1,2,3,4,5) ----> 5
+1
+2
+3
+4
+5
+every write((1 to 5)(1,2,3,4,5)) ----> none
+0(1,2) ----> none
+1(1) ----> 1
+2(1) ----> none
+(-1)(1,2,3) ----> 3
+3(1,2,3,&fail) ----> none
+a
+a
+b
+b
+c
+c
+a
+a
+b
+b
+c
+c
+a
+a
+b
+b
+c
+c
+a
+a
+b
+b
+c
+c
+a
+a
+b
+b
+c
+c
+every write(2(1 to 5,!"abc",1 to 2)) ----> none
+x := 1 ----> 1
+y := 2 ----> 2
+(x := y) & &fail ----> none
+a
+b
+c
+d
+e
+f
+every write(!"abcdef") ----> none
+1
+2
+3
+4
+5
+every write(![1,2,3,4,5]) ----> none
+1
+2
+3
+4
+5
+every write(!![1,2,3,4,5]) ----> none
+1
+a
+b
+1
+2
+3
+3
+4
+every write(!![1,"ab",[1,2,3],34]) ----> none
+1
+a
+b
+1
+2
+3
+3
+4
+every write(!([1,"ab",[1,2,3],34][1 to 4])) ----> none
+x := array(1,2,3,4,5) ----> record array_3(7)
+1
+2
+3
+4
+5
+
+
+every write(!x) ----> none
+x := 1 ----> 1
+y := 2 ----> 2
+x <-> y ----> 2
+y <-> x ----> 2
+(x <-> y) & &fail ----> none
+x ----> 1
+y ----> 2
+*"" ----> 0
+*'' ----> 0
+*[] ----> 0
+*table() ----> 0
+*30 ----> 2
+!"abc" ----> "a"
+![1,2,3] ----> 1
+!&lcase ----> "a"
+!30 ----> "3"
+!table() ----> none
+?"abc" ----> "c"
+?&lcase ----> "f"
+?[1,2,3] ----> 2
+?table() ----> none
+?30 ----> 27
+.x ----> &null
+."abc" ----> "abc"
+.[] ----> list_22(0)
+.main ----> procedure main
+/main ----> none
+/"abc" ----> none
+/&null ----> &null
+/[] ----> none
+/&lcase ----> none
+\main ----> procedure main
+\"abc" ----> "abc"
+\x ----> none
+\[] ----> list_24(0)
+\&null ----> none
+1 | 2 | 3 ----> 1
+|(1 to 10) ----> 1
+||(1 to 10) ----> 1
+|||(1 to 10) ----> 1
+||||(1 to 10) ----> 1
+|||||(1 to 10) ----> 1
+|||||||(1 to 10) ----> 1
+2 \ 2 ----> 2
+while 1 do break ----> &null
+while 1 do break "hello" ----> "hello"
+while break ----> &null
+case 1 of {2:3; "1":4; 1: 4 to 10; default: "whoa"} ----> 4
+not 1 ----> none
+not \&null ----> &null
+repeat break ----> &null
+until 1 do 2 ----> none
+if 1 then 2 else 3 ----> 2
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+every write(if 1 then 1 to 10 else 5) ----> none
+10
+9
+8
+7
+6
+5
+4
+3
+2
+1
+every write(if 1 = 0 then 1 to 10 else 10 to 1 by -1) ----> none
+if 1 then 2 ----> 2
+if 1 = 0 then 2 ----> none
+x := 1 ----> 1
+y := 2 ----> 2
+z := 3 ----> 3
+x :=: y ----> 2
+y :=: x ----> &null
+x ----> &null
+y ----> &null
+z ----> &null
+x :=: y :=: z ----> &null
+x ----> &null
+y ----> &null
+z ----> &null
+x := 1 ----> 1
+y := 2 ----> 2
+z := 3 ----> 3
+x <-> y ----> &null
+y <-> x ----> &null
+x ----> &null
+y ----> &null
+z ----> &null
+x <-> y :=: z ----> &null
+x ----> &null
+y ----> &null
+z ----> &null
+1 & 2 & 3 & 4 ----> 4
+(1 & 2 & 3 & x) := 3 ----> 3
+x ----> &null
+x := 1 ----> 1
+y := 2 ----> 2
+(x <- y) & &fail ----> none
+x ----> 1
+y ----> 2
diff --git a/tests/general/every.icn b/tests/general/every.icn
new file mode 100644
index 0000000..eb25151
--- /dev/null
+++ b/tests/general/every.icn
@@ -0,0 +1,34 @@
+#SRC: JCON
+
+procedure main()
+ local s
+
+ every write("a. ")
+ every write("b. ", -3)
+ every write("c. ", 1 to 10)
+ every write("d. ", 1 to 10 by 3)
+ every write("e. ", 1 to 11 by 3)
+ every write("f. ", 1 to 12 by 3)
+ every write("g. ", 1 to 10 by -3)
+ every write("h. ", 10 to 1 by -3)
+ every write("i. ", 11 to 1 by -3)
+ every write("j. ", 12 to 1 by -3)
+ every write("k. ", (7 | 6.5) + (2 | 2.1))
+ every write("l. ", , "hello" | "goodbye", " ", "world" | "mom")
+ every write("m. ", !"")
+ every write("n. ", !"a")
+ every write("o. ", !"abcde")
+ every write("p. ", !-514)
+ every write("q. ", !12.5)
+
+ s := "abcde"
+ every !s := "." do write("r. ", s)
+
+ every write("s. ", (-3|-2|-1|0|1|2|3)(101,102))
+ every write("t. ", (-3|-2|-1|0|1|2|3) ! [201,202])
+ every write("u. ", f ! [5])
+end
+
+procedure f(n)
+ suspend n | -n
+end
diff --git a/tests/general/every.std b/tests/general/every.std
new file mode 100644
index 0000000..5cb1fff
--- /dev/null
+++ b/tests/general/every.std
@@ -0,0 +1,73 @@
+a.
+b. -3
+c. 1
+c. 2
+c. 3
+c. 4
+c. 5
+c. 6
+c. 7
+c. 8
+c. 9
+c. 10
+d. 1
+d. 4
+d. 7
+d. 10
+e. 1
+e. 4
+e. 7
+e. 10
+f. 1
+f. 4
+f. 7
+f. 10
+h. 10
+h. 7
+h. 4
+h. 1
+i. 11
+i. 8
+i. 5
+i. 2
+j. 12
+j. 9
+j. 6
+j. 3
+k. 9
+k. 9.1
+k. 8.5
+k. 8.6
+l. hello world
+l. hello mom
+l. goodbye world
+l. goodbye mom
+n. a
+o. a
+o. b
+o. c
+o. d
+o. e
+p. -
+p. 5
+p. 1
+p. 4
+q. 1
+q. 2
+q. .
+q. 5
+r. .bcde
+r. ..cde
+r. ...de
+r. ....e
+r. .....
+s. 101
+s. 102
+s. 101
+s. 102
+t. 201
+t. 202
+t. 201
+t. 202
+u. 5
+u. -5
diff --git a/tests/general/fncs.icn b/tests/general/fncs.icn
new file mode 100644
index 0000000..c4de685
--- /dev/null
+++ b/tests/general/fncs.icn
@@ -0,0 +1,185 @@
+record array(a,b,c,d,e,f,g)
+global F, f
+global w, t
+
+procedure p1()
+ write(" ----> ",image() | "none")
+ write("copy(1) ----> ",image(copy(1)) | "none")
+ write("copy(\"abc\") ----> ",image(copy("abc")) | "none")
+ write("copy('aabbcc') ----> ",image(copy('aabbcc')) | "none")
+ write("copy(main) ----> ",image(copy(main)) | "none")
+ write("copy([1,2,3]) ----> ",image(copy([1,2,3])) | "none")
+ write("copy(table(0)) ----> ",image(copy(table(0))) | "none")
+ write("copy() ----> ",image(copy()) | "none")
+ write("copy(&input) ----> ",image(copy(&input)) | "none")
+ write("w := copy(write) ----> ",image(w := copy(write)) | "none")
+end
+
+procedure p2()
+ write("w(image(w)) ----> ",image(w(image(w))) | "none")
+ write("copy(array()) ----> ",image(copy(array())) | "none")
+ write("copy := copy(copy) ----> ",image(copy := copy(copy)) | "none")
+ write("x := copy(array) ----> ",image(x := copy(array)) | "none")
+ write("x := x(1,2,3,4,5,6,7) ----> ",image(x := x(1,2,3,4,5,6,7)) | "none")
+ write("x[-4] ----> ",image(x[-4]) | "none")
+ write("v := copy(c) ----> ",image(v := copy(c)) | "none")
+ write("x := repl(\"123\",4) ----> ",image(x := repl("123",4)) | "none")
+ write("t := table() ----> ",image(t := table()) | "none")
+ write("every i := 1 to 100 do t[i] := i ----> ",image(every i := 1 to 100 do t[i] := i) | "none")
+end
+
+procedure p3()
+ write("x := sort(t) ----> ",image(x := sort(t)) | "none")
+ write("every write((!x)[2]) ----> ",image(every write((!x)[2])) | "none")
+ write("every write(center(\"abcdef\",1 to 20,\" \" | \"0\" | \"=-\")) ----> ",image(every write(center("abcdef",1 to 20," " | "0" | "=-"))) | "none")
+ write("every write(left(\"abcdef\",1 to 20,\" \" | \"0\" | \"=-\")) ----> ",image(every write(left("abcdef",1 to 20," " | "0" | "=-"))) | "none")
+ write("every write(right(\"abcdef\",1 to 20,\" \" | \"0\" | \"=-\")) ----> ",image(every write(right("abcdef",1 to 20," " | "0" | "=-"))) | "none")
+ write("center(\"\",20,repl(\"x.\",30)) ----> ",image(center("",20,repl("x.",30))) | "none")
+ write("left(\"\",20,repl(\"x.\",30)) ----> ",image(left("",20,repl("x.",30))) | "none")
+ write("right(\"\",20,repl(\"x.\",30)) ----> ",image(right("",20,repl("x.",30))) | "none")
+ write("every write(repl(\"a\" | \"ab\" | \"ba\",1 to 5)) ----> ",image(every write(repl("a" | "ab" | "ba",1 to 5))) | "none")
+ write("repl(\"\",0) ----> ",image(repl("",0)) | "none")
+ write("repl(&cset,0) ----> ",image(repl(&cset,0)) | "none")
+end
+
+procedure p4()
+ write("trim(&lcase) ----> ",image(trim(&lcase)) | "none")
+ write("trim(&lcase,&lcase) ----> ",image(trim(&lcase,&lcase)) | "none")
+ write("image(2) ----> ",image(image(2)) | "none")
+ write("image('cab') ----> ",image(image('cab')) | "none")
+ write("image(&lcase) ----> ",image(image(&lcase)) | "none")
+ write("image('abcdefghijklmnopqrstuvwxyz') ----> ",image(image('abcdefghijklmnopqrstuvwxyz')) | "none")
+ write("image(&input) ----> ",image(image(&input)) | "none")
+end
+
+procedure p5()
+ write("image() ----> ",image(image()) | "none")
+ write("image(&null) ----> ",image(image(&null)) | "none")
+ write("image([1,2,3]) ----> ",image(image([1,2,3])) | "none")
+ write("image([]) ----> ",image(image([])) | "none")
+ write("image([,]) ----> ",image(image([,])) | "none")
+ write("image(table()) ----> ",image(image(table())) | "none")
+ write("image(table(3)) ----> ",image(image(table(3))) | "none")
+ write("image(list(0)) ----> ",image(image(list(0))) | "none")
+ write("image(set()) ----> ",image(image(set())) | "none")
+ write("image(set([1,2,3,3,3,3,3,4])) ----> ",image(image(set([1,2,3,3,3,3,3,4]))) | "none")
+ write("image(repl) ----> ",image(image(repl)) | "none")
+end
+
+procedure p6()
+ write("image(main) ----> ",image(image(main)) | "none")
+ write("image(repl(&lcase,10)) ----> ",image(image(repl(&lcase,10))) | "none")
+ write("image(array) ----> ",image(image(array)) | "none")
+ write("image(a) ----> ",image(image(a)) | "none")
+ write("image(array) ----> ",image(image(array)) | "none")
+ write("image(image) ----> ",image(image(image)) | "none")
+ write("string(2) ----> ",image(string(2)) | "none")
+ write("string(\"2\") ----> ",image(string("2")) | "none")
+ write("string(\" 2\") ----> ",image(string(" 2")) | "none")
+end
+
+procedure p7()
+ write("string(\"2 \") ----> ",image(string("2 ")) | "none")
+ write("string(\"+2\") ----> ",image(string("+2")) | "none")
+ write("string(\"-2\") ----> ",image(string("-2")) | "none")
+ write("string(\"- 2\") ----> ",image(string("- 2")) | "none")
+ write("string(\" - 2 \") ----> ",image(string(" - 2 ")) | "none")
+ write("string(\"\") ----> ",image(string("")) | "none")
+ write("string(\"--2\") ----> ",image(string("--2")) | "none")
+ write("string(\" \") ----> ",image(string(" ")) | "none")
+ write("string(\"-\") ----> ",image(string("-")) | "none")
+ write("string(\"+\") ----> ",image(string("+")) | "none")
+end
+
+procedure p8()
+ write("string(\"22222222222222222222222222222222222222222222222222222222222\") ----> ",image(string("22222222222222222222222222222222222222222222222222222222222")) | "none")
+ write("string(\"7r4\") ----> ",image(string("7r4")) | "none")
+ write("string(\"4r7\") ----> ",image(string("4r7")) | "none")
+ write("string(\"4r 7\") ----> ",image(string("4r 7")) | "none")
+ write("string(\"7r 4\") ----> ",image(string("7r 4")) | "none")
+ write("string(\"16rff\") ----> ",image(string("16rff")) | "none")
+end
+
+procedure p9()
+ write("string(\"36rcat\") ----> ",image(string("36rcat")) | "none")
+ write("string(\"36Rcat\") ----> ",image(string("36Rcat")) | "none")
+ write("string(\"36rCAT\") ----> ",image(string("36rCAT")) | "none")
+ write("string(\"1r1\") ----> ",image(string("1r1")) | "none")
+ write("string(\"2r0\") ----> ",image(string("2r0")) | "none")
+ write("type(0) ----> ",image(type(0)) | "none")
+ write("type(\"abc\") ----> ",image(type("abc")) | "none")
+ write("type('aba') ----> ",image(type('aba')) | "none")
+ write("type() ----> ",image(type()) | "none")
+ write("type(&null) ----> ",image(type(&null)) | "none")
+end
+
+procedure p10()
+ write("type([]) ----> ",image(type([])) | "none")
+ write("type(table()) ----> ",image(type(table())) | "none")
+ write("type(main) ----> ",image(type(main)) | "none")
+ write("type(write) ----> ",image(type(write)) | "none")
+ write("type(array()) ----> ",image(type(array())) | "none")
+ write("type(array) ----> ",image(type(array)) | "none")
+ write("type(f) ----> ",image(type(f)) | "none")
+ write("cset(2) ----> ",image(cset(2)) | "none")
+end
+
+procedure p11()
+ write("cset(\"2\") ----> ",image(cset("2")) | "none")
+ write("cset(\" 2\") ----> ",image(cset(" 2")) | "none")
+ write("cset(\"2 \") ----> ",image(cset("2 ")) | "none")
+ write("cset(\"+2\") ----> ",image(cset("+2")) | "none")
+ write("cset(\"-2\") ----> ",image(cset("-2")) | "none")
+ write("cset(\"- 2\") ----> ",image(cset("- 2")) | "none")
+ write("cset(\" - 2 \") ----> ",image(cset(" - 2 ")) | "none")
+ write("cset(\"\") ----> ",image(cset("")) | "none")
+ write("cset(\"--2\") ----> ",image(cset("--2")) | "none")
+ write("cset(\" \") ----> ",image(cset(" ")) | "none")
+ write("cset(\"-\") ----> ",image(cset("-")) | "none")
+end
+
+procedure p12()
+ write("cset(\"+\") ----> ",image(cset("+")) | "none")
+ write("cset(\"22222222222222222222222222222222222222222222222222222222222\") ----> ",image(cset("22222222222222222222222222222222222222222222222222222222222")) | "none")
+ write("cset(\"7r4\") ----> ",image(cset("7r4")) | "none")
+ write("cset(\"4r7\") ----> ",image(cset("4r7")) | "none")
+ write("cset(\"4r 7\") ----> ",image(cset("4r 7")) | "none")
+end
+
+procedure p13()
+ write("cset(\"7r 4\") ----> ",image(cset("7r 4")) | "none")
+ write("cset(\"16rff\") ----> ",image(cset("16rff")) | "none")
+ write("cset(\"36rcat\") ----> ",image(cset("36rcat")) | "none")
+ write("cset(\"36Rcat\") ----> ",image(cset("36Rcat")) | "none")
+ write("cset(\"36rCAT\") ----> ",image(cset("36rCAT")) | "none")
+ write("cset(\"1r1\") ----> ",image(cset("1r1")) | "none")
+ write("cset(\"2r0\") ----> ",image(cset("2r0")) | "none")
+ write("every write(seq()) \\ 10 ----> ",image(every write(seq()) \ 10) | "none")
+ write("every write(seq(2)) \\ 10 ----> ",image(every write(seq(2)) \ 10) | "none")
+ write("every write(seq(-10)) \\ 10 ----> ",image(every write(seq(-10)) \ 10) | "none")
+ write("every write(seq(,3)) \\ 10 ----> ",image(every write(seq(,3)) \ 10) | "none")
+end
+
+procedure p14()
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+ p10()
+ p11()
+ p12()
+ p13()
+ p14()
+end
+
+procedure wf (v)
+ writes(left(v,5)," ")
+ end
diff --git a/tests/general/fncs.std b/tests/general/fncs.std
new file mode 100644
index 0000000..65658dd
--- /dev/null
+++ b/tests/general/fncs.std
@@ -0,0 +1,455 @@
+ ----> &null
+copy(1) ----> 1
+copy("abc") ----> "abc"
+copy('aabbcc') ----> 'abc'
+copy(main) ----> procedure main
+copy([1,2,3]) ----> list_2(3)
+copy(table(0)) ----> table_2(0)
+copy() ----> &null
+copy(&input) ----> &input
+w := copy(write) ----> function write
+function write
+w(image(w)) ----> "function write"
+copy(array()) ----> record array_2(7)
+copy := copy(copy) ----> function copy
+x := copy(array) ----> record constructor array
+x := x(1,2,3,4,5,6,7) ----> record array_3(7)
+x[-4] ----> 4
+v := copy(c) ----> &null
+x := repl("123",4) ----> "123123123123"
+t := table() ----> table_3(0)
+every i := 1 to 100 do t[i] := i ----> none
+x := sort(t) ----> list_3(100)
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+every write((!x)[2]) ----> none
+d
+d
+d
+cd
+cd
+cd
+cde
+cde
+cde
+bcde
+bcde
+bcde
+bcdef
+bcdef
+bcdef
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef0
+abcdef-
+ abcdef
+0abcdef0
+=abcdef-
+ abcdef
+0abcdef00
+=abcdef=-
+ abcdef
+00abcdef00
+=-abcdef=-
+ abcdef
+00abcdef000
+=-abcdef-=-
+ abcdef
+000abcdef000
+=-=abcdef-=-
+ abcdef
+000abcdef0000
+=-=abcdef=-=-
+ abcdef
+0000abcdef0000
+=-=-abcdef=-=-
+ abcdef
+0000abcdef00000
+=-=-abcdef-=-=-
+ abcdef
+00000abcdef00000
+=-=-=abcdef-=-=-
+ abcdef
+00000abcdef000000
+=-=-=abcdef=-=-=-
+ abcdef
+000000abcdef000000
+=-=-=-abcdef=-=-=-
+ abcdef
+000000abcdef0000000
+=-=-=-abcdef-=-=-=-
+ abcdef
+0000000abcdef0000000
+=-=-=-=abcdef-=-=-=-
+every write(center("abcdef",1 to 20," " | "0" | "=-")) ----> none
+a
+a
+a
+ab
+ab
+ab
+abc
+abc
+abc
+abcd
+abcd
+abcd
+abcde
+abcde
+abcde
+abcdef
+abcdef
+abcdef
+abcdef
+abcdef0
+abcdef-
+abcdef
+abcdef00
+abcdef=-
+abcdef
+abcdef000
+abcdef-=-
+abcdef
+abcdef0000
+abcdef=-=-
+abcdef
+abcdef00000
+abcdef-=-=-
+abcdef
+abcdef000000
+abcdef=-=-=-
+abcdef
+abcdef0000000
+abcdef-=-=-=-
+abcdef
+abcdef00000000
+abcdef=-=-=-=-
+abcdef
+abcdef000000000
+abcdef-=-=-=-=-
+abcdef
+abcdef0000000000
+abcdef=-=-=-=-=-
+abcdef
+abcdef00000000000
+abcdef-=-=-=-=-=-
+abcdef
+abcdef000000000000
+abcdef=-=-=-=-=-=-
+abcdef
+abcdef0000000000000
+abcdef-=-=-=-=-=-=-
+abcdef
+abcdef00000000000000
+abcdef=-=-=-=-=-=-=-
+every write(left("abcdef",1 to 20," " | "0" | "=-")) ----> none
+f
+f
+f
+ef
+ef
+ef
+def
+def
+def
+cdef
+cdef
+cdef
+bcdef
+bcdef
+bcdef
+abcdef
+abcdef
+abcdef
+ abcdef
+0abcdef
+=abcdef
+ abcdef
+00abcdef
+=-abcdef
+ abcdef
+000abcdef
+=-=abcdef
+ abcdef
+0000abcdef
+=-=-abcdef
+ abcdef
+00000abcdef
+=-=-=abcdef
+ abcdef
+000000abcdef
+=-=-=-abcdef
+ abcdef
+0000000abcdef
+=-=-=-=abcdef
+ abcdef
+00000000abcdef
+=-=-=-=-abcdef
+ abcdef
+000000000abcdef
+=-=-=-=-=abcdef
+ abcdef
+0000000000abcdef
+=-=-=-=-=-abcdef
+ abcdef
+00000000000abcdef
+=-=-=-=-=-=abcdef
+ abcdef
+000000000000abcdef
+=-=-=-=-=-=-abcdef
+ abcdef
+0000000000000abcdef
+=-=-=-=-=-=-=abcdef
+ abcdef
+00000000000000abcdef
+=-=-=-=-=-=-=-abcdef
+every write(right("abcdef",1 to 20," " | "0" | "=-")) ----> none
+center("",20,repl("x.",30)) ----> "x.x.x.x.x.x.x.x.x.x."
+left("",20,repl("x.",30)) ----> "x.x.x.x.x.x.x.x.x.x."
+right("",20,repl("x.",30)) ----> "x.x.x.x.x.x.x.x.x.x."
+a
+aa
+aaa
+aaaa
+aaaaa
+ab
+abab
+ababab
+abababab
+ababababab
+ba
+baba
+bababa
+babababa
+bababababa
+every write(repl("a" | "ab" | "ba",1 to 5)) ----> none
+repl("",0) ----> ""
+repl(&cset,0) ----> ""
+trim(&lcase) ----> "abcdefghijklmnopqrstuvwxyz"
+trim(&lcase,&lcase) ----> ""
+image(2) ----> "2"
+image('cab') ----> "'abc'"
+image(&lcase) ----> "&lcase"
+image('abcdefghijklmnopqrstuvwxyz') ----> "&lcase"
+image(&input) ----> "&input"
+image() ----> "&null"
+image(&null) ----> "&null"
+image([1,2,3]) ----> "list_104(3)"
+image([]) ----> "list_105(0)"
+image([,]) ----> "list_106(2)"
+image(table()) ----> "table_4(0)"
+image(table(3)) ----> "table_5(0)"
+image(list(0)) ----> "list_107(0)"
+image(set()) ----> "set_1(0)"
+image(set([1,2,3,3,3,3,3,4])) ----> "set_2(4)"
+image(repl) ----> "function repl"
+image(main) ----> "procedure main"
+image(repl(&lcase,10)) ----> "\"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\""
+image(array) ----> "record constructor array"
+image(a) ----> "&null"
+image(array) ----> "record constructor array"
+image(image) ----> "function image"
+string(2) ----> "2"
+string("2") ----> "2"
+string(" 2") ----> " 2"
+string("2 ") ----> "2 "
+string("+2") ----> "+2"
+string("-2") ----> "-2"
+string("- 2") ----> "- 2"
+string(" - 2 ") ----> " - 2 "
+string("") ----> ""
+string("--2") ----> "--2"
+string(" ") ----> " "
+string("-") ----> "-"
+string("+") ----> "+"
+string("22222222222222222222222222222222222222222222222222222222222") ----> "22222222222222222222222222222222222222222222222222222222222"
+string("7r4") ----> "7r4"
+string("4r7") ----> "4r7"
+string("4r 7") ----> "4r 7"
+string("7r 4") ----> "7r 4"
+string("16rff") ----> "16rff"
+string("36rcat") ----> "36rcat"
+string("36Rcat") ----> "36Rcat"
+string("36rCAT") ----> "36rCAT"
+string("1r1") ----> "1r1"
+string("2r0") ----> "2r0"
+type(0) ----> "integer"
+type("abc") ----> "string"
+type('aba') ----> "cset"
+type() ----> "null"
+type(&null) ----> "null"
+type([]) ----> "list"
+type(table()) ----> "table"
+type(main) ----> "procedure"
+type(write) ----> "procedure"
+type(array()) ----> "array"
+type(array) ----> "procedure"
+type(f) ----> "null"
+cset(2) ----> '2'
+cset("2") ----> '2'
+cset(" 2") ----> ' 2'
+cset("2 ") ----> ' 2'
+cset("+2") ----> '+2'
+cset("-2") ----> '-2'
+cset("- 2") ----> ' -2'
+cset(" - 2 ") ----> ' -2'
+cset("") ----> ''
+cset("--2") ----> '-2'
+cset(" ") ----> ' '
+cset("-") ----> '-'
+cset("+") ----> '+'
+cset("22222222222222222222222222222222222222222222222222222222222") ----> '2'
+cset("7r4") ----> '47r'
+cset("4r7") ----> '47r'
+cset("4r 7") ----> ' 47r'
+cset("7r 4") ----> ' 47r'
+cset("16rff") ----> '16fr'
+cset("36rcat") ----> '36acrt'
+cset("36Rcat") ----> '36Ract'
+cset("36rCAT") ----> '36ACTr'
+cset("1r1") ----> '1r'
+cset("2r0") ----> '02r'
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+every write(seq()) \ 10 ----> none
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+every write(seq(2)) \ 10 ----> none
+-10
+-9
+-8
+-7
+-6
+-5
+-4
+-3
+-2
+-1
+every write(seq(-10)) \ 10 ----> none
+1
+4
+7
+10
+13
+16
+19
+22
+25
+28
+every write(seq(,3)) \ 10 ----> none
diff --git a/tests/general/fncs1.icn b/tests/general/fncs1.icn
new file mode 100644
index 0000000..1d85619
--- /dev/null
+++ b/tests/general/fncs1.icn
@@ -0,0 +1,72 @@
+record array(a,b,c,d,e,f,g)
+global F, f
+global w, t
+
+procedure main()
+ q1()
+ q2()
+ q3()
+ q4()
+ q5()
+end
+
+procedure q1()
+ write(" ----> ",image() | "none")
+ write("f := open(\"foo.baz\",\"w\") ----> ",image(f := open("foo.baz","w")) | "none")
+ write("write(f,\"hello world\") ----> ",image(write(f,"hello world")) | "none")
+ write("close(f) ----> ",image(close(f)) | "none")
+ write("F := open(\"gc1.icn\") ----> ",image(F := open("gc1.icn")) | "none")
+ write("every write(reverse(!F)) ----> ",image(every write(reverse(!F))) | "none")
+ write("close(F) ----> ",image(close(F)) | "none")
+ write("F := open(\"gc1.icn\") ----> ",image(F := open("gc1.icn")) | "none")
+ write("every write(map(!F)) ----> ",image(every write(map(!F))) | "none")
+ write("close(F) ----> ",image(close(F)) | "none")
+ write("F := open(\"gc1.icn\") ----> ",image(F := open("gc1.icn")) | "none")
+end
+
+procedure q2()
+ write("every write(map(!F,&cset || \"aeiou\",&cset || \"-----\")) ----> ",image(every write(map(!F,&cset || "aeiou",&cset || "-----"))) | "none")
+ write("close(F) ----> ",image(close(F)) | "none")
+ write("F := open(\"gc1.icn\") ----> ",image(F := open("gc1.icn")) | "none")
+ write("every write(map(!F,&cset || \" \",&cset || \"aeiou\")) ----> ",image(every write(map(!F,&cset || " ",&cset || "aeiou"))) | "none")
+ write("close(F) ----> ",image(close(F)) | "none")
+ write("f := open(\"gc1.icn\") ----> ",image(f := open("gc1.icn")) | "none")
+ write("while writes(reads(f)) ----> ",image(while writes(reads(f))) | "none")
+ write("close(f) ----> ",image(close(f)) | "none")
+ write("f := open(\"gc1.icn\") ----> ",image(f := open("gc1.icn")) | "none")
+ write("while writes(reads(f,10)) ----> ",image(while writes(reads(f,10))) | "none")
+ write("f := open(\"gc1.icn\") ----> ",image(f := open("gc1.icn")) | "none")
+end
+
+procedure q3()
+ write("while write(read(f)) ----> ",image(while write(read(f))) | "none")
+ write("close(f) ----> ",image(close(f)) | "none")
+end
+
+procedure q4()
+ T := table()
+ L := list()
+ every T[1 to 20] := 1
+ every put (L, key(T))
+ every write (!sort(L))
+end
+
+procedure q5()
+ every i := 1 to 25 do {
+ v := 0.25 * i
+ wf (v)
+ if (v <= 1.0) then
+ every wf ((acos | asin) (v))
+ else
+ every wf ("" | "")
+ every wf (atan(v) | atan(v,3))
+ every wf ((cos | sin | tan) (v))
+ every wf ((sqrt | exp | log) (v))
+ wf (log(v,3))
+ write ()
+ }
+ end
+
+procedure wf (v)
+ writes(left(v,5)," ")
+ end
diff --git a/tests/general/fncs1.std b/tests/general/fncs1.std
new file mode 100644
index 0000000..005653c
--- /dev/null
+++ b/tests/general/fncs1.std
@@ -0,0 +1,195 @@
+ ----> &null
+f := open("foo.baz","w") ----> file(foo.baz)
+write(f,"hello world") ----> "hello world"
+close(f) ----> file(foo.baz)
+F := open("gc1.icn") ----> file(gc1.icn)
+)(niam erudecorp
+)"... gnillif"(etirw
+{ od 001 ot 1 yreve
+od 001 ot 1 yreve
+)0001(tsil
+}
+)snoitcelloc&(etirw#
+)"... gnitcelloc"(etirw
+)(tcelloc
+)"... gnillif"(etirw
+{ od )0001 ot 1,"x"(lper =: s yreve
+))esacl&(gnirts(tesc
+)(elbat =: t
+)]s[(tes
+]5 : 2[s
+}
+)"enod"(etirw
+dne
+every write(reverse(!F)) ----> none
+close(F) ----> file(gc1.icn)
+F := open("gc1.icn") ----> file(gc1.icn)
+procedure main()
+ write("filling ...")
+ every 1 to 100 do {
+ every 1 to 100 do
+ list(1000)
+ }
+ #write(&collections)
+ write("collecting ...")
+ collect()
+ write("filling ...")
+ every s := repl("x",1 to 1000) do {
+ cset(string(&lcase))
+ t := table()
+ set([s])
+ s[2 : 5]
+ }
+ write("done")
+end
+every write(map(!F)) ----> none
+close(F) ----> file(gc1.icn)
+F := open("gc1.icn") ----> file(gc1.icn)
+pr-c-d-r- m--n()
+ wr-t-("f-ll-ng ...")
+ -v-ry 1 t- 100 d- {
+ -v-ry 1 t- 100 d-
+ l-st(1000)
+ }
+ #wr-t-(&c-ll-ct--ns)
+ wr-t-("c-ll-ct-ng ...")
+ c-ll-ct()
+ wr-t-("f-ll-ng ...")
+ -v-ry s := r-pl("x",1 t- 1000) d- {
+ cs-t(str-ng(&lc-s-))
+ t := t-bl-()
+ s-t([s])
+ s[2 : 5]
+ }
+ wr-t-("d-n-")
+-nd
+every write(map(!F,&cset || "aeiou",&cset || "-----")) ----> none
+close(F) ----> file(gc1.icn)
+F := open("gc1.icn") ----> file(gc1.icn)
+procedureumain()
+uuuwrite("fillingu...")
+uuueveryu1utou100udou{
+uuuuuueveryu1utou100udo
+uuuuuuuuulist(1000)
+uuuuuu}
+uuu#write(&collections)
+uuuwrite("collectingu...")
+uuucollect()
+uuuwrite("fillingu...")
+uuueveryusu:=urepl("x",1utou1000)udou{
+uuuuuucset(string(&lcase))
+uuuuuutu:=utable()
+uuuuuuset([s])
+uuuuuus[2u:u5]
+uuuuuu}
+uuuwrite("done")
+end
+every write(map(!F,&cset || " ",&cset || "aeiou")) ----> none
+close(F) ----> file(gc1.icn)
+f := open("gc1.icn") ----> file(gc1.icn)
+procedure main()
+ write("filling ...")
+ every 1 to 100 do {
+ every 1 to 100 do
+ list(1000)
+ }
+ #write(&collections)
+ write("collecting ...")
+ collect()
+ write("filling ...")
+ every s := repl("x",1 to 1000) do {
+ cset(string(&lcase))
+ t := table()
+ set([s])
+ s[2 : 5]
+ }
+ write("done")
+end
+while writes(reads(f)) ----> none
+close(f) ----> file(gc1.icn)
+f := open("gc1.icn") ----> file(gc1.icn)
+procedure main()
+ write("filling ...")
+ every 1 to 100 do {
+ every 1 to 100 do
+ list(1000)
+ }
+ #write(&collections)
+ write("collecting ...")
+ collect()
+ write("filling ...")
+ every s := repl("x",1 to 1000) do {
+ cset(string(&lcase))
+ t := table()
+ set([s])
+ s[2 : 5]
+ }
+ write("done")
+end
+while writes(reads(f,10)) ----> none
+f := open("gc1.icn") ----> file(gc1.icn)
+procedure main()
+ write("filling ...")
+ every 1 to 100 do {
+ every 1 to 100 do
+ list(1000)
+ }
+ #write(&collections)
+ write("collecting ...")
+ collect()
+ write("filling ...")
+ every s := repl("x",1 to 1000) do {
+ cset(string(&lcase))
+ t := table()
+ set([s])
+ s[2 : 5]
+ }
+ write("done")
+end
+while write(read(f)) ----> none
+close(f) ----> file(gc1.icn)
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+0.25 1.318 0.252 0.244 0.083 0.968 0.247 0.255 0.5 1.284 -1.38 -1.26
+0.5 1.047 0.523 0.463 0.165 0.877 0.479 0.546 0.707 1.648 -0.69 -0.63
+0.75 0.722 0.848 0.643 0.244 0.731 0.681 0.931 0.866 2.117 -0.28 -0.26
+1.0 0.0 1.570 0.785 0.321 0.540 0.841 1.557 1.0 2.718 0.0 0.0
+1.25 0.896 0.394 0.315 0.948 3.009 1.118 3.490 0.223 0.203
+1.5 0.982 0.463 0.070 0.997 14.10 1.224 4.481 0.405 0.369
+1.75 1.051 0.528 -0.17 0.983 -5.52 1.322 5.754 0.559 0.509
+2.0 1.107 0.588 -0.41 0.909 -2.18 1.414 7.389 0.693 0.630
+2.25 1.152 0.643 -0.62 0.778 -1.23 1.5 9.487 0.810 0.738
+2.5 1.190 0.694 -0.80 0.598 -0.74 1.581 12.18 0.916 0.834
+2.75 1.222 0.741 -0.92 0.381 -0.41 1.658 15.64 1.011 0.920
+3.0 1.249 0.785 -0.98 0.141 -0.14 1.732 20.08 1.098 1.0
+3.25 1.272 0.825 -0.99 -0.10 0.108 1.802 25.79 1.178 1.072
+3.5 1.292 0.862 -0.93 -0.35 0.374 1.870 33.11 1.252 1.140
+3.75 1.310 0.896 -0.82 -0.57 0.696 1.936 42.52 1.321 1.203
+4.0 1.325 0.927 -0.65 -0.75 1.157 2.0 54.59 1.386 1.261
+4.25 1.339 0.956 -0.44 -0.89 2.006 2.061 70.10 1.446 1.317
+4.5 1.352 0.982 -0.21 -0.97 4.637 2.121 90.01 1.504 1.369
+4.75 1.363 1.007 0.037 -0.99 -26.5 2.179 115.5 1.558 1.418
+5.0 1.373 1.030 0.283 -0.95 -3.38 2.236 148.4 1.609 1.464
+5.25 1.382 1.051 0.512 -0.85 -1.67 2.291 190.5 1.658 1.509
+5.5 1.390 1.071 0.708 -0.70 -0.99 2.345 244.6 1.704 1.551
+5.75 1.398 1.089 0.861 -0.50 -0.59 2.397 314.1 1.749 1.592
+6.0 1.405 1.107 0.960 -0.27 -0.29 2.449 403.4 1.791 1.630
+6.25 1.412 1.123 0.999 -0.03 -0.03 2.5 518.0 1.832 1.668
diff --git a/tests/general/gc1.icn b/tests/general/gc1.icn
new file mode 100644
index 0000000..7a63864
--- /dev/null
+++ b/tests/general/gc1.icn
@@ -0,0 +1,18 @@
+procedure main()
+ write("filling ...")
+ every 1 to 100 do {
+ every 1 to 100 do
+ list(1000)
+ }
+ #write(&collections)
+ write("collecting ...")
+ collect()
+ write("filling ...")
+ every s := repl("x",1 to 1000) do {
+ cset(string(&lcase))
+ t := table()
+ set([s])
+ s[2 : 5]
+ }
+ write("done")
+end
diff --git a/tests/general/gc1.std b/tests/general/gc1.std
new file mode 100644
index 0000000..62df702
--- /dev/null
+++ b/tests/general/gc1.std
@@ -0,0 +1,4 @@
+filling ...
+collecting ...
+filling ...
+done
diff --git a/tests/general/gc2.icn b/tests/general/gc2.icn
new file mode 100644
index 0000000..e89902c
--- /dev/null
+++ b/tests/general/gc2.icn
@@ -0,0 +1,222 @@
+global defs, ifile, in, limit, tswitch, prompt
+
+record nonterm(name)
+record charset(chars)
+record query(name)
+
+procedure main(x)
+ local line, plist
+ plist := [define,generate,grammar,source,comment,prompter,error]
+ defs := table()
+ defs["lb"] := [["<"]]
+ defs["rb"] := [[">"]]
+ defs["vb"] := [["|"]]
+ defs["nl"] := [["\n"]]
+ defs[""] := [[""]]
+ defs["&lcase"] := [[charset(&lcase)]]
+ defs["&ucase"] := [[charset(&ucase)]]
+ defs["&digit"] := [[charset('0123456789')]]
+ i := 0
+ while i < *x do {
+ s := x[i +:= 1] | break
+ case s of {
+ "-t": tswitch := 1
+ "-l": limit := integer(x[i +:= 1]) | stop("usage: [-t] [-l n]")
+ default: stop("usage: [-t] [-l n]")
+ }
+ }
+ ifile := [&input]
+ prompt := ""
+ test := ["<a>::=1|2|3","<a>10","->","<b>::=<a>|<a><a>|<b><b>","<b>5",
+ "<c>::=<b><b><b>","<c>100","<b>100"]
+ every line := !test do {
+ (!plist)(line)
+ collect()
+ every write(&collections)
+ write("----------")
+ }
+end
+
+procedure comment(line)
+ if line[1] == "#" then return
+end
+
+procedure define(line)
+ return line ?
+ defs[(="<",tab(find(">::=")))] := (move(4),alts(tab(0)))
+end
+
+procedure defnon(sym)
+ if sym ? {
+ ="'" &
+ chars := cset(tab(-1)) &
+ ="'"
+ }
+ then return charset(chars)
+ else if sym ? {
+ ="?" &
+ name := tab(0)
+ }
+ then return query(name)
+ else return nonterm(sym)
+end
+
+procedure error(line)
+ write("*** erroneous line: ",line)
+ return
+end
+
+procedure gener(goal)
+ local pending, genstr, symbol
+ repeat {
+ pending := [nonterm(goal)]
+ genstr := ""
+ while symbol := get(pending) do {
+ if \tswitch then write(genstr,symimage(symbol),listimage(pending))
+ case type(symbol) of {
+ "string": genstr ||:= symbol
+ "charset": genstr ||:= ?symbol.chars
+ "query": {
+ writes("*** supply string for ",symbol.name," ")
+ genstr ||:= read() | {
+ write("*** no value for query to ",symbol.name)
+ suspend genstr
+ break next
+ }
+ }
+ "nonterm": {
+ pending := ?\defs[symbol.name] ||| pending | {
+ write("*** undefined nonterminal: <",symbol.name,">")
+ suspend genstr
+ break next
+ }
+ if *pending > \limit then {
+ write("*** excessive symbols remaining")
+ suspend genstr
+ break next
+ }
+ }
+ }
+ }
+ suspend genstr
+ }
+end
+
+procedure generate(line)
+ local goal, count
+ if line ? {
+ ="<" &
+ goal := tab(upto('>')) \ 1 &
+ move(1) &
+ count := (pos(0) & 1) | integer(tab(0))
+ }
+ then {
+ every write(gener(goal)) \ count
+ return
+ }
+ else fail
+end
+
+procedure getrhs(a)
+ local rhs
+ rhs := ""
+ every rhs ||:= sform(!a) || "|"
+ return rhs[1:-1]
+end
+
+procedure grammar(line)
+ local file, out
+ if line ? {
+ name := tab(find("->")) &
+ move(2) &
+ file := tab(0) &
+ out := if *file = 0 then &output else {
+ open(file,"w") | {
+ write("*** cannot open ",file)
+ fail
+ }
+ }
+ }
+ then {
+ (*name = 0) | (name[1] == "<" & name[-1] == ">") | fail
+ pwrite(name,out)
+ if *file ~= 0 then close(out)
+ return
+ }
+ else fail
+end
+
+procedure listimage(a)
+ local s, x
+ s := ""
+ every x := !a do
+ s ||:= symimage(x)
+ return s
+end
+
+procedure alts(defn)
+ local alist
+ alist := []
+ defn ? while put(alist,syms(tab(many(~'|')))) do move(1)
+ return alist
+end
+
+procedure prompter(line)
+ if line[1] == "=" then {
+ prompt := line[2:0]
+ return
+ }
+end
+
+procedure pwrite(name,ofile)
+ local nt, a
+ static builtin
+ initial builtin := ["lb","rb","vb","nl","","&lcase","&ucase","&digit"]
+ if *name = 0 then {
+ a := sort(defs)
+ every nt := !a do {
+ if nt[1] == !builtin then next
+ write(ofile,"<",nt[1],">::=",getrhs(nt[2]))
+ }
+ }
+ else write(ofile,name,"::=",getrhs(\defs[name[2:-1]])) |
+ write("*** undefined nonterminal: ",name)
+end
+
+procedure sform(alt)
+ local s, x
+ s := ""
+ every x := !alt do
+ s ||:= case type(x) of {
+ "string": x
+ "nonterm": "<" || x.name || ">"
+ "charset": "<'" || x.chars || "'>"
+ }
+ return s
+end
+
+procedure source(line)
+ return line ? (="@" & push(ifile,in) & {
+ in := open(file := tab(0)) | {
+ write("*** cannot open ",file)
+ fail
+ }
+ })
+end
+
+procedure symimage(x)
+ return case type(x) of {
+ "string": x
+ "nonterm": "<" || x.name || ">"
+ "charset": "<'" || x.chars || "'>"
+ }
+end
+
+procedure syms(alt)
+ local slist
+ slist := []
+ alt ? while put(slist,tab(many(~'<')) |
+ defnon(2(="<",tab(upto('>')),move(1))))
+ return slist
+end
+
diff --git a/tests/general/gc2.std b/tests/general/gc2.std
new file mode 100644
index 0000000..06f9397
--- /dev/null
+++ b/tests/general/gc2.std
@@ -0,0 +1,256 @@
+1
+0
+0
+0
+----------
+1
+2
+1
+2
+2
+1
+1
+3
+1
+3
+2
+0
+0
+0
+----------
+<a>::=1|2|3
+3
+0
+0
+0
+----------
+4
+0
+0
+0
+----------
+2
+22
+32322221321
+232
+323221323
+5
+0
+0
+0
+----------
+6
+0
+0
+0
+----------
+33113
+132211
+331232
+1122323
+22313
+323
+2312113
+23213
+331
+13232
+3231231
+231231
+2312233
+1322
+1313331
+31231213313333222223
+21121212133
+121323323132321311311232211213121123131331333123232321223233
+13112331123321121121222
+133123
+23323332112312
+323323
+2322111
+1311222122
+11111
+221112
+312322123
+2112
+12222
+332233
+32222
+11122
+1111311
+323332
+33322222
+3321
+11222
+312323
+33312123
+21133
+323123
+3223233
+133222
+122123323332323
+22313233
+2322113131333332232313221221223
+32113
+322
+2333131
+1221233231131123
+1221
+3313212131
+322212
+312311331133233323
+132133331
+12113131123121111112111311331
+21333222
+122222
+13332232
+21221321233
+21131332312113212132321
+131112113123
+3113
+11113121231
+1321321
+3311332
+12123122123
+1313
+212321222312333312
+32213
+133
+2131212333232121211
+221221132212
+212321132121223332121122133211113121323323
+11123312212113
+33313332112
+1222122131313323232
+2323111
+2232132311
+123223
+21231
+131112232
+3211112
+313112122112
+3113322
+3212323
+32222
+12211
+11121
+1313323112
+222
+113
+2122
+33332
+32133
+321131211132
+313323
+2123113332213323332
+13112
+33133
+7
+0
+0
+0
+----------
+2133222
+1223
+13
+231331
+3
+32
+12
+3
+11
+1
+22333
+133332211
+3
+333
+11
+1332
+1
+22
+3
+3133
+313
+1
+31
+21221
+113
+2
+33
+313
+3
+31
+31
+3
+1
+12
+13
+2112
+1
+2
+12
+1321
+23
+23
+3
+2
+1
+13123
+212
+21
+1
+13
+3
+1212
+3
+33
+112
+1
+12
+31
+22
+2122
+1
+1
+3
+22
+2133
+2213122231
+12112
+13
+3
+2
+2
+22
+313332311121
+231332
+1
+22
+3
+122
+11
+131
+31
+3322332
+2
+1
+31312132233331111113313211321233
+321
+12
+12332112
+31
+1
+23122
+233
+23
+2
+1
+23
+3
+23321
+2321321
+3233332232332323311133
+8
+0
+0
+0
+----------
diff --git a/tests/general/gener.icn b/tests/general/gener.icn
new file mode 100644
index 0000000..756c936
--- /dev/null
+++ b/tests/general/gener.icn
@@ -0,0 +1,141 @@
+#SRC: V9GEN
+
+## gener.icn -- test generation in parallel with inserts/deletes
+#
+# This is a torture test for the set generation code. Items are inserted
+# in or deleted from the set while the set is being generated. We check
+# every item not inserted or deleted is generated exactly once, and every
+# other item is generated no more than once.
+#
+# If every line of output says '[ok]', the test has passed. "gener -v"
+# gives a little more information; in this case, the output is sensitive
+# to the runtime system's configuration parameters.
+
+
+global verbose
+
+
+procedure main (args)
+ if args[1] == "-v" then
+ verbose := 1
+ every tdel (41 | 619 | 991, 3 | 11 | 23)
+ every tins (40 | 103 | 233, 239 | 419 | 503, 3 | 11 | 23)
+ stale()
+ write ("[done]")
+ end
+
+
+## tins (init, limit, n) -- test insertions
+#
+# The initial set consists of the integers 1 through <init>.
+# Then the set is generated, and <n> more integers are added
+# for each element generated until the set reaches <limit>
+# entries.
+
+procedure tins (init, limit, n)
+ writes ("test insert:",
+ right(init,6), ",", right(limit,5), ",", right(n,3))
+ s := set()
+ every insert (s, 1 to init)
+ s1 := copy (s)
+ l := list()
+ every put (l, e := !s) do
+ if *s < limit then
+ every 1 to n do
+ insert (s, *s + 1)
+ check (s1, s, l)
+ end
+
+
+## tdel (limit, n) -- test deletions
+#
+# The set initially contains the first <limit> integers.
+# Then, for each one generated, n elements are deleted.
+
+procedure tdel (limit, n)
+ writes ("test delete:", right(limit,6), ",", right(n,5))
+ s := set()
+ every insert (s, 1 to limit)
+ s2 := copy(s)
+ l := list()
+ k := 0
+ every put (l, !s) do
+ every 1 to n do
+ delete (s, k +:= 1)
+ check (s, s2, l)
+ end
+
+
+
+## check (s1, s2, l) -- check results of generation
+#
+# s1 small set (before insertion / after deletion)
+# s2 large set (after insertion / before deletion)
+# l generated list
+
+procedure check (s1, s2, l)
+ sg := set(l)
+ if \verbose then
+ writes (" \tsizes ",right(*s1,5)," <=",right(*sg,5)," <=",right(*s2,5))
+ ok := "\t[ok]"
+
+ if *(s := (s1 -- sg)) > 0 then {
+ writes ("\n not generated:")
+ every writes (" ", !sort(s))
+ ok := &null
+ }
+
+ if *(s := (sg -- s2)) > 0 then {
+ writes ("\n unknown values generated:")
+ every writes (" ", !sort(s))
+ ok := &null
+ }
+
+ if *sg < *l then {
+ writes("\n generated twice:")
+ every e := !l do
+ delete(sg,member(sg,e)) | writes (" ", e)
+ ok := &null
+ }
+
+ write (ok)
+ end
+
+
+
+## check for generation of stale (already deleted) elements of sets and tables
+
+procedure stale()
+ local i, N, S, T
+
+ N := 100
+ T := table()
+ S := set()
+
+ write()
+ every i := 1 to N do {
+ T[i] := i
+ insert(S, i)
+ }
+
+ write("checking !S:")
+ every i := !S do {
+ if not member(S, i) then write("S[", i, "] stale")
+ delete(S, ?N)
+ }
+
+ write("checking !T:")
+ every i := !T do {
+ if /T[i] then write("T[", i, "] stale")
+ delete(T, ?N)
+ }
+
+ write("checking key(T):")
+ every i := key(T) do {
+ if /T[i] then write("T[", i, "] stale")
+ delete(T, ?N)
+ }
+
+ write()
+ return
+end
diff --git a/tests/general/gener.std b/tests/general/gener.std
new file mode 100644
index 0000000..2fd530f
--- /dev/null
+++ b/tests/general/gener.std
@@ -0,0 +1,42 @@
+test delete: 41, 3 [ok]
+test delete: 41, 11 [ok]
+test delete: 41, 23 [ok]
+test delete: 619, 3 [ok]
+test delete: 619, 11 [ok]
+test delete: 619, 23 [ok]
+test delete: 991, 3 [ok]
+test delete: 991, 11 [ok]
+test delete: 991, 23 [ok]
+test insert: 40, 239, 3 [ok]
+test insert: 40, 239, 11 [ok]
+test insert: 40, 239, 23 [ok]
+test insert: 40, 419, 3 [ok]
+test insert: 40, 419, 11 [ok]
+test insert: 40, 419, 23 [ok]
+test insert: 40, 503, 3 [ok]
+test insert: 40, 503, 11 [ok]
+test insert: 40, 503, 23 [ok]
+test insert: 103, 239, 3 [ok]
+test insert: 103, 239, 11 [ok]
+test insert: 103, 239, 23 [ok]
+test insert: 103, 419, 3 [ok]
+test insert: 103, 419, 11 [ok]
+test insert: 103, 419, 23 [ok]
+test insert: 103, 503, 3 [ok]
+test insert: 103, 503, 11 [ok]
+test insert: 103, 503, 23 [ok]
+test insert: 233, 239, 3 [ok]
+test insert: 233, 239, 11 [ok]
+test insert: 233, 239, 23 [ok]
+test insert: 233, 419, 3 [ok]
+test insert: 233, 419, 11 [ok]
+test insert: 233, 419, 23 [ok]
+test insert: 233, 503, 3 [ok]
+test insert: 233, 503, 11 [ok]
+test insert: 233, 503, 23 [ok]
+
+checking !S:
+checking !T:
+checking key(T):
+
+[done]
diff --git a/tests/general/genqueen.icn b/tests/general/genqueen.icn
new file mode 100644
index 0000000..5b2ade2
--- /dev/null
+++ b/tests/general/genqueen.icn
@@ -0,0 +1,100 @@
+#SRC: APP
+
+############################################################################
+#
+# File: genqueen.icn
+#
+# Subject: Program to solve arbitrary-size n-queens problem
+#
+# Author: Peter A. Bigot
+#
+# Date: October 25, 1990
+#
+############################################################################
+#
+# This program solve the non-attacking n-queens problem for (square) boards
+# of arbitrary size. The problem consists of placing chess queens on an
+# n-by-n grid such that no queen is in the same row, column, or diagonal as
+# any other queen. The output is each of the solution boards; rotations
+# not considered equal. An example of the output for n:
+#
+# -----------------
+# |Q| | | | | | | |
+# -----------------
+# | | | | | | |Q| |
+# -----------------
+# | | | | |Q| | | |
+# -----------------
+# | | | | | | | |Q|
+# -----------------
+# | |Q| | | | | | |
+# -----------------
+# | | | |Q| | | | |
+# -----------------
+# | | | | | |Q| | |
+# -----------------
+# | | |Q| | | | | |
+# -----------------
+#
+# Usage: genqueen n
+# where n is the number of rows / columns in the board. The default for n
+# is 6.
+#
+############################################################################
+
+global
+ n, # Number of rows/columns
+ rw, # List of queens in each row
+ dd, # List of queens in each down diagonal
+ ud # List of queens in each up diagonal
+
+procedure main (args) # Program arguments
+ n := integer (args [1]) | 6
+ rw := list (n)
+ dd := list (2*n-1)
+ ud := list (2*n-1)
+ solvequeen (1)
+ end # procedure main
+
+# placequeen(c) -- Place a queen in every permissible position in column c.
+# Suspend with each result.
+procedure placequeen (c) # Column at which to place queen
+ local r # Possible placement row
+
+ every r := 1 to n do
+ suspend (/rw [r] <- /dd [r+c-1] <- /ud [n+r-c] <- c)
+ fail
+ end # procedure placequeen
+
+# solvequeen(c) -- Place the c'th and following column queens on the board.
+# Write board if have completed it. Suspends all viable results
+procedure solvequeen (c) # Column for next queen placement
+ if (c > n) then {
+ # Have placed all required queens. Write the board, and resume search.
+ writeboard ()
+ fail
+ }
+ suspend placequeen (c) & solvequeen (c+1)
+ fail
+ end # procedure solvequeen
+
+# writeboard() -- Write an image of the board with the queen positions
+# represented by Qs.
+procedure writeboard ()
+ local
+ r, # Index over rows during print
+ c, # Column of queen in row r
+ row # Depiction of row as its created
+
+ write (repl ("--", n), "-")
+ every r := 1 to n do {
+ c := rw [r]
+ row := repl ("| ", n) || "|"
+ row [2*c] := "Q"
+ write (row)
+ write (repl ("--", n), "-")
+ }
+ write ()
+ end # procedure writeboard
+
+
diff --git a/tests/general/genqueen.std b/tests/general/genqueen.std
new file mode 100644
index 0000000..72d33f9
--- /dev/null
+++ b/tests/general/genqueen.std
@@ -0,0 +1,56 @@
+-------------
+| | | |Q| | |
+-------------
+|Q| | | | | |
+-------------
+| | | | |Q| |
+-------------
+| |Q| | | | |
+-------------
+| | | | | |Q|
+-------------
+| | |Q| | | |
+-------------
+
+-------------
+| | | | |Q| |
+-------------
+| | |Q| | | |
+-------------
+|Q| | | | | |
+-------------
+| | | | | |Q|
+-------------
+| | | |Q| | |
+-------------
+| |Q| | | | |
+-------------
+
+-------------
+| |Q| | | | |
+-------------
+| | | |Q| | |
+-------------
+| | | | | |Q|
+-------------
+|Q| | | | | |
+-------------
+| | |Q| | | |
+-------------
+| | | | |Q| |
+-------------
+
+-------------
+| | |Q| | | |
+-------------
+| | | | | |Q|
+-------------
+| |Q| | | | |
+-------------
+| | | | |Q| |
+-------------
+|Q| | | | | |
+-------------
+| | | |Q| | |
+-------------
+
diff --git a/tests/general/hello.icn b/tests/general/hello.icn
new file mode 100644
index 0000000..29dc5ac
--- /dev/null
+++ b/tests/general/hello.icn
@@ -0,0 +1,5 @@
+# hello.icn -- used in various ways by the Test-opts script
+
+procedure main(args)
+ write("\t\t\t\t\t\t\tHello, ", get(args) | "there", ".")
+end
diff --git a/tests/general/ilib.icn b/tests/general/ilib.icn
new file mode 100644
index 0000000..eb019a0
--- /dev/null
+++ b/tests/general/ilib.icn
@@ -0,0 +1,396 @@
+# a simple test of many of the core library procedures
+
+link core
+link options
+link rational
+
+$define LSIZE 16
+$define GENLIMIT 25
+
+procedure main()
+ local L, LR, T, r1, r2, r3, argv, SL
+
+ L := [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]
+ LR := lreverse(L)
+ T := table("0")
+ T["one"] := 101
+ T["two"] := 22
+ T["three"] := 333
+
+ write()
+ write("convert:") # convert
+ gen(exbase10, 11213, 8)
+ gen(inbase10, 11213, 8)
+ gen(radcon, 11213, 4, 7)
+
+ write()
+ write("datetime:") # datetime
+ HoursFromGmt := 7
+ gen(ClockToSec, "14:27:43")
+ gen(DateLineToSec, "Friday, September 7, 1984 1:07 pm")
+ gen(DateToSec, "1984/09/07")
+ gen(SecToClock, 14 * 3600 + 27 * 60 + 43)
+ gen(SecToDate, 463338000)
+ gen(SecToDateLine, 463385237)
+ gen(SecToUnixDate, 463385237)
+ gen(IsLeapYear, 2004)
+ gen(dayoweek, 7, 9, 1984)
+ gen(julian, 9, 7, 1984)
+ gen(saytime, "15:00:47")
+ # several procedures that return records omitted
+
+ write()
+ write("factors:") # factors
+ gen(divisors, 360)
+ lst(divisorl, 576)
+ gen(factorial, 0)
+ gen(factorial, 6)
+ lst(factors, 360)
+ gen(genfactors, 360)
+ gen(gfactorial, 5, 2)
+ gen(ispower, 81, 4)
+ gen(isprime, 97)
+ gen(nxtprime, 97)
+ lst(pfactors, 360)
+ lst(prdecomp, 360)
+ lst(prdecomp, 504)
+ gen(prime)
+# gen(primel) # not testable without data file
+# gen(primeorial, 12) # not testable without data file
+ gen(sfactors, 360)
+ every gen(squarefree, 23 to 30)
+
+ write("[testing factorizations]")
+ every tfact(1 to 100)
+ write("[testing prime numbers]")
+ tprimes(100)
+
+ write()
+ write("io:") # io
+ gen(exists, "/foo/bar/baz/not/very/likely")
+ gen(directory, "/tmp")
+ # several others omitted
+
+ write()
+ write("lists:") # lists
+ lst(lcollate, L, LR)
+ lst(lcompact, L)
+ lst(lclose, [3, 1, 4, 1])
+ lst(ldelete, copy(L), 3)
+ lst(ldupl, L, 2)
+ lst(lequiv, L, copy(L))
+ lst(lextend, L, 20)
+ lst(lfliph, L)
+ lst(lflipv, L)
+ lst(limage, L)
+ gen(lindex, L, 5)
+ lst(linterl, L, LR)
+ lst(llayer, L, L)
+ lst(llpad, L, 14, 0)
+ lst(lltrim, L, set([3]))
+ lst(lpalin, L)
+ lst(lpermute, L)
+ lst(lreflect, L)
+ lst(lremvals, L, 1, 5)
+ lst(lrepl, L, 2)
+ lst(lresidue, L, 3)
+ lst(lreverse, L)
+ lst(lrotate, L, 4)
+ lst(lrpad, L, 14, 0)
+ lst(lrtrim, L, set([3, 5]))
+ lst(lrundown, L, LR)
+ lst(lrunup, L, LR)
+ lst(lshift, L, 3)
+ lst(lswap, L)
+ lst(lunique, L)
+ lst(lmaxlen, L, integer)
+ lst(lminlen, L, integer)
+ lst(sortkeys, L)
+ lst(sortvalues, L)
+ lst(str2lst, "Once upon a midnight dreary", 5)
+ # several others omitted
+
+ write()
+ write("math:") # math
+ gen(binocoef, 16, 5)
+ gen(cosh, &pi / 3)
+ gen(sinh, &pi / 3)
+ gen(tanh, &pi / 3)
+
+ write()
+ write("numbers:") # numbers
+ gen(adp, 2147483647)
+ gen(adr, 2147483647)
+ gen(amean, 1, 1, 2, 3, 5, 8, 13, 21, 42)
+ gen(ceil, &pi)
+ gen(commas, 2147483647)
+ every gen(decimal, 1, 1 to 20)
+ gen(decipos, &pi, 6, 10)
+ gen(digprod, 2147483647)
+ gen(digred, 2147483647)
+ gen(digroot, 2147483647)
+ gen(digsum, 2147483647)
+ gen(distseq, 1, GENLIMIT)
+ gen(div, 355, 113)
+ gen(fix, 355, 113, 10, 4)
+ gen(floor, &phi)
+ gen(frn, &pi, 10, 4)
+ gen(gcd, 42, 120)
+ gen(gcdl, 42, 120, 81)
+ gen(gmean, 1, 1, 2, 3, 5, 8, 13, 21, 42)
+ gen(hmean, 1, 1, 2, 3, 5, 8, 13, 21, 42)
+ gen(large, 214748364721474836472147483647)
+ gen(lcm, 20, 24)
+ gen(lcm, 20, 24, 16)
+ gen(mantissa, &e)
+ gen(max, &e, &pi, &phi)
+ gen(mdp, 2147483647)
+ gen(mdr, 2147483647)
+ gen(min, &e, &pi, &phi)
+ gen(mod1, 21, 7)
+ gen(npalins, 2)
+ gen(residue, 21, 7, 14)
+ gen(roman, 1989)
+ gen(round, &e)
+ gen(sign, -47)
+ gen(spell, 47193) # result is not strictly correct
+ gen(sum, 1, 1, 2, 3, 5, 8, 13, 21, 42)
+ gen(trunc, &phi)
+ gen(unroman, "MCMLXXIV")
+
+ write()
+ write("options:") # options (not part of core)
+ argv := ["-abc","-","-s","-v","-i","42","-r","98.6","--","-b","x","y"]
+ tbl(options, copy(argv))
+ tbl(options, copy(argv), "scrivab")
+ tbl(options, copy(argv), "a:s:i:r:b:")
+ tbl(options, copy(argv), "a:s!v!i+r.b!")
+ tbl(options, copy(argv), "-abc: -s: irvb")
+ tbl(options, argv, "a:svi:r")
+ every writes(" ", " argv " | !argv | "\n")
+
+ write()
+ write("random:") # random
+ gen(rand_num)
+ gen(rand_int, 20)
+ gen(randomize)
+ gen(randrange, 30, 50)
+ gen(randrangeseq, 52, 99)
+ gen(randseq, 1903)
+ gen(rng)
+ gen(shuffle, "A23456789TJQK")
+
+ write()
+ write("rational:") # rational (not part of core)
+ rat(str2rat, "(355/113)")
+ r1 := rat(real2rat, 355. / 113.)
+ gen(rat2str, r1)
+ gen(rat2real, r1)
+ r2 := rat(negrat, r1)
+ r3 := rat(reciprat, r1)
+ rat(addrat, r1, r3)
+ rat(subrat, r1, r3)
+ rat(mpyrat, r1, r2)
+ rat(divrat, r1, r3)
+ rat(medrat, rational(2,5,1), rational(11,7,1))
+ rat(medrat, rational(5,13,1), rational(4,5,1))
+ trat()
+
+ write()
+ write("records:") # records
+ gen(field, DateRec(), 7)
+ gen(fieldnum, DateRec(), "weekday")
+ lst(movecorr, date1(10,30,1952), date2(09,1956,0.97))
+
+ write()
+ write("scan:") # scan
+
+ write()
+ write("sets:") # sets
+ stt(cset2set, &digits)
+ stt(domain, T)
+ tbl(inverse, T)
+ # pairset, T returns list of lists
+ stt(range, T)
+ stt(seteq, set([4, 7, 1]), set([7, 1, 4]))
+ stt(setlt, set([4, 7, 1]), set([7, 3, 1, 4]))
+ gen(simage, set(L))
+
+ write()
+ write("sort:") # sort
+ lst(isort, "Quoth The Raven: Nevermore", map)
+ writes("sortff ")
+ every writes(" ", !!(sortff([[1,6],[3,9],[3,8],[1,5],[2,7]],1,2)) | "\n")
+
+ write()
+ write("strings:") # strings
+ SL := ["abc", "ab", "bc"]
+ gen(cat, "abc", "def", "ghi")
+ gen(charcnt, "deinstitutionalization", 'aeiou')
+ gen(collate, "abcde", "12345")
+ gen(comb, "abcde", 3)
+ gen(compress,
+ "Mississippi bookkeeper unsuccessfully lobbies heedless committee")
+ every gen(coprefix, !SL, !SL)
+ every gen(cosuffix, !SL, !SL)
+ gen(csort, "sphinx of black quartz judge my vow")
+ gen(decollate,"saturday in the park")
+ gen(deletec, "deinstitutionalization", 'aeiou')
+ gen(deletep, "deinstitutionalization", [3, 4])
+ gen(deletes, "deinstitutionalization", "ti")
+ gen(diffcnt, "deinstitutionalization")
+ gen(extend, "choco", 60)
+ gen(fchars, "deinstitutionalization")
+ gen(interleave,"abcde", "123")
+ gen(ispal, "abcdcba")
+ gen(maxlen, ["quick", "brown", "fox", "jumped"])
+ gen(meander, "abcd", 3)
+ gen(multicoll,["quick", "brown", "fox"])
+ gen(ochars, "deinstitutionalization")
+ gen(odd_even, "31415926535")
+ gen(palins, "abcd", 3)
+ gen(permutes, "abc")
+ gen(pretrim, " And in conclusion...")
+ gen(reflect, "abc", , "*")
+ gen(reflect, "abc", 1, "*")
+ gen(reflect, "abc", 2, "*")
+ gen(reflect, "abc", 3, "*")
+ gen(replace, "deinstitutionalization", "ti", "le")
+ gen(replacem, "deinstitutionalization", "ti", "le", "eon", "ine")
+ gen(replc, "abc", [3, 1, 2])
+ gen(rotate, "housecat", -3)
+ gen(schars, "deinstitutionalization")
+ gen(scramble, "deinstitutionalization")
+ gen(selectp, "deinstitutionalization", [3, 4, 6, 9, 11, 19])
+ gen(slugs, "fly.me.to.the.moon.and.let.me.play.among.the.stars", 11, '.')
+ gen(starseq, "ab")
+ gen(strcnt, "ti", "deinstitutionalization")
+ gen(substrings, "deinstitutionalization", 3, 3)
+ gen(transpose, "housecat", "12345678", "61785234")
+ gen(words, "fly.me.to.the.moon.and.let.me.play.among.the.stars", '.')
+
+ write()
+ write("tables:") # tables
+ lst(keylist, T)
+ lst(kvallist, T)
+ tbl(tbleq, T, copy(T))
+ tbl(tblunion, T, copy(T))
+ tbl(tblinter, T, copy(T))
+ tbl(tbldiff, T, copy(T))
+ tbl(tblinvrt, T)
+ lst(tbldflt, T)
+ tbl(twt, T)
+ lst(vallist, T)
+
+end
+
+procedure gen(p, a[]) #: test a simple procedure or generator
+ &random := 4747
+ writes(left(image(p)[11:0], LSIZE - 1))
+ every writes(" ", ((p ! a) \ GENLIMIT) | "\n")
+ return
+end
+
+procedure lst(p, a[]) #: test a procedure that returns a list
+ local L
+
+ L := (p ! a) | ["[FAILED]"]
+ writes(left(image(p)[11:0], LSIZE - 1))
+ every writes(" ", (!L \ GENLIMIT) | "\n")
+ return
+end
+
+procedure stt(p, a[]) #: test a procedure that returns a set
+ local L
+
+ L := sort(p ! a) | ["[FAILED]"]
+ writes(left(image(p)[11:0], LSIZE - 1), " {")
+ every writes(" ", (!L \ GENLIMIT) | "}\n")
+ return
+end
+
+procedure tbl(p, a[]) #: test a procedure that returns a table
+ local k, T, L
+
+ writes(left(image(p)[11:0] | "", LSIZE - 1))
+ if T := (p ! a) then {
+ L := sort(T, 3)
+ while writes(" ", get(L), ":", get(L))
+ write()
+ }
+ else
+ write("[FAILED]")
+ return \T
+end
+
+procedure rat(p, a[]) #: test a procedure that rets a rational
+ local v
+ v := p ! a
+ write(left(image(p)[11:0], LSIZE), rat2str(\v) | ["[FAILED]"])
+ return \v
+end
+
+procedure tfact(n) #: test factorization of n
+ local D, F, P, i, v
+
+ F := factors(n)
+ # every writes(" ", (n || ":") | !F | "\n") # uncomment to show factors
+ v := 1
+ every v *:= !F
+ if v ~= n then
+ write(" ", n, ": PRODUCT OF FACTORS = ", v)
+
+ F := set(F)
+ P := pfactors(n)
+ if *P ~= *F then
+ write(" ", n, ": PRIME FACTOR COUNT = ", *P)
+ every i := !P do
+ if not member(F, i) then
+ write(" ", n, ": MISSING PRIME FACTOR ", i)
+
+ D := set()
+ every insert(D, divisors(n))
+ every i := 1 to n do
+ if member(D, i) then {
+ if n % i ~= 0 then write (" ", n, ": BOGUS DIVISOR ", i)
+ }
+ else {
+ if n % i == 0 then write (" ", n, ": MISSING DIVISOR ", i)
+ }
+end
+
+procedure tprimes(n) #: test the first n primes
+ local i, L1, L2, L3
+
+ L1 := []
+ every i := seq() do {
+ if isprime(i) then {
+ put(L1, i)
+ if *L1 = n then break
+ }
+ }
+
+ every put(L2 := [], prime() \ n)
+
+ L3 := []
+ i := 1
+ while *L3 < n do
+ put(L3, i := nxtprime(i))
+
+ every i := 1 to n do
+ if not (L1[i] = L2[i] = L3[i]) then
+ write(" PRIME ENTRY ", i, ": ", L1[i], ", ", L2[i], ", ", L3[i])
+end
+
+procedure trat() #: test rational arithmetic
+ local r1, r2, L, n, d, r, g
+
+ write("[testing conversions]")
+ L := [2, 3, 5, 7, 9, 17, 19, 27, 45, 63, 75, 81, 98, 99, 121, 175, 225]
+ every (n := !L) & (d := !L) do {
+ r := real2rat(n * (1. / d))
+ g := gcd(n, d)
+ if r.numer ~= n / g | r.denom ~= d / g then
+ write(" REAL2RAT: ", n, " / ", d, " => ", r.numer, " / ", r.denom)
+ }
+end
diff --git a/tests/general/ilib.std b/tests/general/ilib.std
new file mode 100644
index 0000000..83d82f1
--- /dev/null
+++ b/tests/general/ilib.std
@@ -0,0 +1,277 @@
+
+convert:
+exbase10 25715
+inbase10 4747
+radcon 1022
+
+datetime:
+ClockToSec 52063
+DateLineToSec 463385220
+DateToSec 463338000
+SecToClock 14:27:43
+SecToDate 1984/09/07
+SecToDateLine Friday, September 7, 1984 1:07 pm
+SecToUnixDate Sep 7 13:07 1984
+IsLeapYear
+dayoweek Friday
+julian 2445951
+saytime just gone three o'clock
+
+factors:
+divisors 1 2 3 4 5 6 8 9 10 12 15 18 20 24 30 36 40 45 60 72 90 120 180 360
+divisorl 1 2 3 4 6 8 9 12 16 18 24 32 36 48 64 72 96 144 192 288 576
+factorial 1
+factorial 720
+factors 2 2 2 3 3 5
+genfactors 2 2 2 3 3 5
+gfactorial 15
+ispower 3
+isprime 97
+nxtprime 101
+pfactors 2 3 5
+prdecomp 3 2 1
+prdecomp 3 2 0 1
+prime 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
+sfactors 2^3 3^2 5
+squarefree 23
+squarefree
+squarefree
+squarefree 26
+squarefree
+squarefree
+squarefree 29
+squarefree 30
+[testing factorizations]
+[testing prime numbers]
+
+io:
+exists
+directory /tmp
+
+lists:
+lcollate 3 5 1 3 4 5 1 6 5 2 9 9 2 5 6 1 5 4 3 1 5 3
+lcompact 3 1 4 1 5 7 2 6 5 3 5
+lclose 3 1 4 1 3
+ldelete 3 1 1 5 9 2 6 5 3 5
+ldupl 3 3 1 1 4 4 1 1 5 5 9 9 2 2 6 6 5 5 3 3 5 5
+lequiv 3 1 4 1 5 9 2 6 5 3 5
+lextend 3 1 4 1 5 9 2 6 5 3 5 3 1 4 1 5 9 2 6 5
+lfliph 5 3 5 6 2 9 5 1 4 1 3
+lflipv 7 9 6 9 5 1 8 4 5 7 5
+limage [ 3 , 1 , 4 , 1 , 5 , 9 , 2 , 6 , 5 , 3 , 5 ]
+lindex 5 9 11
+linterl 3 5 1 3 4 5 1 6 5 2 9 9 2 5 6 1 5 4 3 1 5 3
+llayer 3 10 1 8 4 11 1 8 5 12 7 14 2 9 6 13 5 12 3 10 5 12
+llpad 0 0 0 3 1 4 1 5 9 2 6 5 3 5
+lltrim 1 4 1 5 9 2 6 5 3 5
+lpalin 3 1 4 1 5 9 2 6 5 3 5 5 3 5 6 2 9 5 1 4 1
+lpermute 3 1 4 1 5 9 2 6 5 3 5
+lreflect 3 1 4 1 5 9 2 6 5 3 5 3 5 6 2 9 5 1 4 1
+lremvals 3 4 9 2 6 3
+lrepl 3 1 4 1 5 9 2 6 5 3 5 3 1 4 1 5 9 2 6 5 3 5
+lresidue 0 1 1 1 2 0 2 0 2 0 2
+lreverse 5 3 5 6 2 9 5 1 4 1 3
+lrotate 5 9 2 6 5 3 5 3 1 4 1
+lrpad 3 1 4 1 5 9 2 6 5 3 5 0 0 0
+lrtrim 3 1 4 1 5 9 2 6
+lrundown 3 3 2 3 2 1 3 2 1 3 1 1 4 3 4 3 2 4 3 2 1 4 4 3 2
+lrunup 3 4 5 3 3 4 5 3 4 5 6 3 4 5 6 7 8 9 3 4 5 3 4 3 1
+lshift 6 4 7 4 8 12 5 9 8 6 8
+lswap 1 3 1 4 9 5 6 2 3 5 5
+lunique 3 1 4 5 9 2 6
+lmaxlen 9
+lminlen 1
+sortkeys 3 4 5 2 5 5
+sortvalues 1 1 9 6 3
+str2lst Once upon a mid night drea ry
+
+math:
+binocoef 4368
+cosh 1.600286858
+sinh 1.249367051
+tanh 0.7807144354
+
+numbers:
+adp 3
+adr 1
+amean 10.66666667
+ceil 4
+commas 2,147,483,647
+decimal 1.
+decimal 0.5
+decimal 0.[3]
+decimal 0.25
+decimal 0.2
+decimal 0.1[6]
+decimal 0.[142857]
+decimal 0.125
+decimal 0.[1]
+decimal 0.1
+decimal 0.[09]
+decimal 0.08[3]
+decimal 0.[076923]
+decimal 0.0[714285]
+decimal 0.0[6]
+decimal 0.0625
+decimal 0.[0588235294117647]
+decimal 0.0[5]
+decimal 0.[052631578947368421]
+decimal 0.05
+decipos 3.1415
+digprod 903168
+digred 1
+digroot 1
+digsum 46 10 1
+distseq 13 24 10 21 7 18 4 15 1 12 23 9 20 6 17 3 14 25 11 22 8 19 5 16 2
+div 3.14159292
+fix 3.1415
+floor 1
+frn 3.1416
+gcd 6
+gcdl 3
+gmean 5.194140423
+hmean 2.721759118
+large 214748364721474836472147483647
+lcm 120
+lcm 120
+mantissa .7182818285
+max 3.141592654
+mdp 2
+mdr 0
+min 1.618033989
+mod1 7
+npalins 11 22 33 44 55 66 77 88 99
+residue 7
+roman MCMLXXXIX
+round 3
+sign -1
+spell forty-seven thousand and seven thousand and one hundred and ninety-three
+sum 96
+trunc 1
+unroman 1974
+
+options:
+options a:1 b:1 c:1 i:1 r:1 s:1 v:1
+options a:1 b:1 c:1 i:1 r:1 s:1 v:1
+options a:bc i:42 r:98.6 s:-v
+options a:bc i:42 r:98.6 s:1 v:1
+options abc:- i:1 r:1 s:-v
+options a:bc i:42 r:1 s:1 v:1
+ argv - 98.6 -b x y
+
+random:
+rand_num 453816694
+rand_int 9
+randomize
+randrange 41
+randrangeseq 59 65 71 77 83 89 95 54 60 66 72 78 84 90 96 55 61 67 73 79 85 91 97 56 62
+randseq 1903 204320185 193201979 1327087509 597731815 1239640785 169007731 1268039277 280296415 1247011177 1336387883 1564267205 1602778455 875637121 694594403 898487453 1839599183 53926681 2122291483 501816309 844119751 255987249 627419731 1349353677 1652096703
+rng 0 453816694 885666996 678165018 1096161928 905669982 656467580 170957890 1583830416 108920774 1539632324 295778538 721762584 1144737966 1333202828 1237514258 1519504672 1583400982 507287252 1824883130 679975336 764038654 1931954844 1814756834 25274032
+shuffle J4K2Q5A39T687
+
+rational:
+str2rat (355/113)
+real2rat (355/113)
+rat2str (355/113)
+rat2real 3.14159292
+negrat (-355/113)
+reciprat (113/355)
+addrat (138794/40115)
+subrat (113256/40115)
+mpyrat (-126025/12769)
+divrat (126025/12769)
+medrat (13/12)
+medrat (1/2)
+[testing conversions]
+
+records:
+field weekday
+fieldnum 7
+movecorr 10 1952 0.97
+
+scan:
+
+sets:
+cset2set { 0 1 2 3 4 5 6 7 8 9 }
+domain { one three two }
+inverse 22:two 101:one 333:three
+range { 22 101 333 }
+seteq { 1 4 7 }
+setlt { 1 3 4 7 }
+simage { 5, 4, 9, 3, 2, 1, 6 }
+
+sort:
+isort : a e e e e e h h m n N o o Q R r r t T u v
+sortff 1 5 1 6 2 7 3 8 3 9
+
+strings:
+cat abcdefghi
+charcnt 11
+collate a1b2c3d4e5
+comb abc abd abe acd ace ade bcd bce bde cde
+compress Misisipi bokeper unsucesfuly lobies hedles comite
+coprefix abc
+coprefix ab
+coprefix
+coprefix ab
+coprefix ab
+coprefix
+coprefix
+coprefix
+coprefix bc
+cosuffix abc
+cosuffix
+cosuffix bc
+cosuffix
+cosuffix ab
+cosuffix
+cosuffix bc
+cosuffix
+cosuffix bc
+csort aabcdefghijklmnoopqrstuuvwxyz
+decollate stra ntepr
+deletec dnstttnlztn
+deletep destitutionalization
+deletes deinstuonalizaon
+diffcnt 11
+extend chocochocochocochocochocochocochocochocochocochocochocochoco
+fchars itnaodelsuz
+interleave a1b2c3d1e2
+ispal abcdcba
+maxlen 6
+meander dddcddbddadccdcbdcadbcdbbdbadacdabdaacccbccacbbcbacabcaabbbabaaa
+multicoll qbfuroioxcwkn
+ochars deinstuoalz
+odd_even 34141256923656345
+palins aaa aba aca ada bab bbb bcb bdb cac cbc ccc cdc dad dbd dcd ddd
+permutes abc acb bac bca cab cba
+pretrim And in conclusion...
+reflect abc*b
+reflect abc*cb
+reflect abc*ba
+reflect abc*cba
+replace deinsletuleonalizaleon
+replacem deinsletulinealizaline
+replc aaabcc
+rotate cathouse
+schars adeilnostuz
+scramble ontinutdnzlistieitaiao
+selectp intuit
+slugs fly.me.to the.moon and.let.me play.among the.stars
+starseq a b aa ab ba bb aaa aab aba abb baa bab bba bbb aaaa aaab aaba aabb abaa abab abba abbb baaa baab
+strcnt 3
+substrings dei ein ins nst sti tit itu tut uti tio ion ona nal ali liz iza zat ati tio ion
+transpose chateous
+words fly me to the moon and let me play among the stars
+
+tables:
+keylist one three two
+kvallist 101 333 22
+tbleq one:101 three:333 two:22
+tblunion one:101 three:333 two:22
+tblinter one:101 three:333 two:22
+tbldiff
+tblinvrt 22:two 101:one 333:three
+tbldflt 0
+twt 22:two 101:one 333:three one:101 three:333 two:22
+vallist 22 101 333
diff --git a/tests/general/image.icn b/tests/general/image.icn
new file mode 100644
index 0000000..79e1d05
--- /dev/null
+++ b/tests/general/image.icn
@@ -0,0 +1,83 @@
+#SRC: JCON
+
+# test image(), serial(), *x, and explicit conversion functions
+
+record point(x,y)
+record circle(x, y, r)
+
+procedure main(args)
+ local c1, c2, c3, c4, s
+
+ dump()
+ dump(047)
+ dump(3.14159)
+ dump('7121')
+ dump("asparagus")
+ dump(main)
+ dump(write)
+ dump(args)
+ dump([])
+ dump([1,2,3,4,5])
+ dump(set())
+ dump(insert(insert(insert(set(),1),2),3))
+ dump(table())
+ dump(insert(table(), 3, 4))
+ dump(point)
+ dump(circle)
+ dump(point(0))
+ dump(circle(0))
+ dump(point(1,2))
+ dump(point(3,4,5))
+ dump(circle(6,7))
+ dump(circle(4,5,6))
+
+ c1 := create 10 to 19
+ c2 := create 20 to 29
+ c3 := create 30 to 39
+ every 1 to 7 do @c2 & @c3
+ c4 := ^c3
+ every 1 to 7 do @c2 & @c3
+ dump(c1)
+ dump(c2)
+ dump(c3)
+ dump(c4)
+
+ write()
+ write(" x integer(x) real(x) numeric(x)",
+ " string(x) cset(x)")
+ every convert(0 | 0.0 | "0" | '0' | 7 | 7.315 | "7.315" | '7.315' |
+ "25e-2" | "25e-1" | " 4e+3 " | " 3.8e3 " |
+ "" | " " | " -3 " | " 9 " | " +77" | " 4.7 ")
+
+ s := &cset[1:140] || &cset[250:256]
+ write()
+ write(image(s))
+ write()
+ write(image(cset(s)))
+ write()
+
+end
+
+
+procedure dump(x)
+ local n
+
+ if n := serial(x) then
+ writes("#", n, " ", "*", *x)
+ else if type(x) === ("string" | "cset" | "real" | "integer") then
+ writes(" *", *x)
+ write("\t", type(x), " : ", image(x))
+ return
+end
+
+
+procedure convert(x)
+ write(pad(x), pad(integer(x) | &null), pad(real(x) | &null),
+ pad(numeric(x) | &null), pad(string(x) | &null), pad(cset(x) | &null))
+ return
+end
+
+
+procedure pad(x)
+ return right(image(\x) | "---", 13)
+end
diff --git a/tests/general/image.std b/tests/general/image.std
new file mode 100644
index 0000000..777d7bb
--- /dev/null
+++ b/tests/general/image.std
@@ -0,0 +1,51 @@
+ null : &null
+ *2 integer : 47
+ *7 real : 3.14159
+ *3 cset : '127'
+ *9 string : "asparagus"
+ procedure : procedure main
+ procedure : function write
+#1 *0 list : list_1(0)
+#2 *0 list : list_2(0)
+#3 *5 list : list_3(5)
+#1 *0 set : set_1(0)
+#2 *3 set : set_2(3)
+#1 *0 table : table_1(0)
+#2 *1 table : table_2(1)
+ procedure : record constructor point
+ procedure : record constructor circle
+#1 *2 point : record point_1(2)
+#1 *3 circle : record circle_1(3)
+#2 *2 point : record point_2(2)
+#3 *2 point : record point_3(2)
+#2 *3 circle : record circle_2(3)
+#3 *3 circle : record circle_3(3)
+#2 *0 co-expression : co-expression_2(0)
+#3 *10 co-expression : co-expression_3(10)
+#4 *10 co-expression : co-expression_4(10)
+#5 *0 co-expression : co-expression_5(0)
+
+ x integer(x) real(x) numeric(x) string(x) cset(x)
+ 0 0 0.0 0 "0" '0'
+ 0.0 0 0.0 0.0 "0.0" '.0'
+ "0" 0 0.0 0 "0" '0'
+ '0' 0 0.0 0 "0" '0'
+ 7 7 7.0 7 "7" '7'
+ 7.315 7 7.315 7.315 "7.315" '.1357'
+ "7.315" 7 7.315 7.315 "7.315" '.1357'
+ '.1357' 0 0.1357 0.1357 ".1357" '.1357'
+ "25e-2" 0 0.25 0.25 "25e-2" '-25e'
+ "25e-1" 2 2.5 2.5 "25e-1" '-125e'
+ " 4e+3 " 4000 4000.0 4000.0 " 4e+3 " ' +34e'
+ " 3.8e3 " 3800 3800.0 3800.0 " 3.8e3 " ' .38e'
+ "" --- --- --- "" ''
+ " " --- --- --- " " ' '
+ " -3 " -3 -3.0 -3 " -3 " ' -3'
+ " 9 " 9 9.0 9 " 9 " ' 9'
+ " +77" 77 77.0 77 " +77" ' +7'
+ " 4.7 " 4 4.7 4.7 " 4.7 " ' .47'
+
+"\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\xf9\xfa\xfb\xfc\xfd\xfe"
+
+'\x00\x01\x02\x03\x04\x05\x06\x07\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\e\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\d\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\xf9\xfa\xfb\xfc\xfd\xfe'
+
diff --git a/tests/general/io.dat b/tests/general/io.dat
new file mode 100644
index 0000000..b1e70d3
--- /dev/null
+++ b/tests/general/io.dat
@@ -0,0 +1,13 @@
+aaa
+bbbb
+ccccc
+dddddd
+eeeeeee
+ffffffff
+ggggggggg
+hhhhhhhhhh
+iiiiiiiiiii
+jjjjjjjjjjjj
+kkkkkkkkkkkkk
+llllllllllllll
+mmmmmmmmmmmmmmm
diff --git a/tests/general/io.icn b/tests/general/io.icn
new file mode 100644
index 0000000..fec8522
--- /dev/null
+++ b/tests/general/io.icn
@@ -0,0 +1,214 @@
+#SRC: JCON
+
+# I/O test -- writes ./tmp1 and ./tmp2 as well as stdout
+
+procedure main()
+ local L, f, m, n, t1, t2
+
+ L := [&input, &output, &errout,
+ m := open("/etc/motd") | stop("no /etc/motd"),
+ n := open("/dev/null", "w") | stop("no /dev/null")]
+ L := sort(L)
+ every f := !L do
+ write(type(f), ": ", image(f))
+
+ write()
+ write(read())
+ write(read(&input))
+ while write(read()) do break
+ write(!&input)
+ every write(!&input \ 2)
+ every write(!&input) \ 2
+
+ write()
+ write("flush /etc/motd: ", image(flush(m)) | "FAILED")
+ write("close /etc/motd: ", image(close(m)) | "FAILED")
+ write("close /etc/motd: ", image(close(m)) | "FAILED")
+ write("flush /etc/motd: ", image(flush(m)) | "FAILED")
+
+ write()
+ write("flush /dev/null: ", image(flush(n)) | "FAILED")
+ write("close /dev/null: ", image(close(n)) | "FAILED")
+ write("close /dev/null: ", image(close(n)) | "FAILED")
+ write("flush /dev/null: ", image(flush(n)) | "FAILED")
+
+ every remove("tmp1" | "tmp2")
+ every remove("tmp1" | "tmp2")
+ write(image(open("tmp1"))) # should fail
+
+ write()
+ rfile("/dev/null")
+ wfile("tmp1", "w", "follow the yellow brick road")
+ rfile("tmp1")
+ wfile("tmp1", "w", "shorter file")
+ rfile("tmp1")
+ wfile("tmp1", "a", "gets extended")
+ rfile("tmp1")
+ wfile("tmp1", "rw", "changed")
+ rfile("tmp1")
+ wfile("tmp1", "b", "mode b ")
+ rfile("tmp1")
+ wfile("tmp1", "crw", "cleared anew")
+ rfile("tmp1")
+ rename("tmp1", "tmp2")
+ rfile("tmp2")
+
+ write()
+ write(image(t1 := open("tmp1", "w")) | "can't open tmp1")
+ write(image(t2 := open("tmp2", "w")) | "can't open tmp2")
+ writes(">stdout", t1, ">1a", t2, ">2a", &output)
+ writes(">stdout", t2, ">2b", t1, ">1b", &output)
+ write(">stdout", t1, ">1c", t2, t2, ">2c", &output)
+ write(">stdout", t2, ">2d", t1, t1, ">1d", &output)
+ every write(t1 | t2)
+ writes(t1, ">1e")
+ writes(t2, ">2e")
+ write(t1, ">1f")
+ write(t2, ">2f")
+ every close(t1 | t2)
+ rfile("tmp1")
+ rfile("tmp2")
+
+ every remove("tmp1" | "tmp2")
+ every remove("tmp1" | "tmp2")
+
+ write()
+ writes("abc")
+ writes("def\nghi")
+ writes("\njklmno\n")
+ write("pqr\nstu")
+ writes("vwxyz")
+ writes()
+ writes("")
+ writes("\n")
+
+ write()
+ tsys("echo hello world") # simple echo
+ tsys("ls io.[ids][tca][dnt]") # check wildcarding
+
+ tpipe()
+
+end
+
+
+
+# wfile(name, mode, s) -- break apart string and write file
+
+procedure wfile(name, mode, s)
+ local f
+
+ write()
+ writes("write ", name, ",", mode, ":\t ")
+ if f := open(name, mode) then s ? {
+ writes(s)
+ tab(many(' '))
+ while not pos(0) do {
+ write(f, tab(upto(' ') | 0))
+ tab(many(' '))
+ }
+ write(" : ", where(f))
+ flush(f)
+ close(f)
+ }
+ else {
+ write("can't open")
+ }
+ return
+end
+
+
+
+# rfile(name) -- read and echo file contents (several different ways)
+
+procedure rfile(name)
+ local f, i
+
+ writes("read ", name, ":\t")
+ if not (f := open(name, "r")) then {
+ write(" can't open")
+ fail
+ }
+
+ # read()
+ while writes(" ", read(f))
+ write()
+
+ # bang
+ seek(f, 1)
+ every writes(" ", " !f:\t\t" | !f | "\n")
+
+ # both, mixed
+ seek(f, 1)
+ writes(" read/!f:\t")
+ while writes(" ", read(f)) do writes(" ", !f)
+ write()
+
+ # reads()
+ seek(f, 1)
+ writes(" reads():\t")
+ while writes(" ", map(reads(f, 5), "\n", "."))
+ write()
+
+#%#% # nonsequential (disabled because it's inconsistently buggy...)
+#%#% writes(" nonseq:\t ")
+#%#% every i := 30 to -30 by -1 do
+#%#% if seek(f, i) then
+#%#% writes(map(reads(f), "\n", ".") | "?")
+#%#% else
+#%#% writes("-")
+#%#% write()
+
+ close(f)
+ return
+end
+
+
+# tsys(s) -- test system call
+
+procedure tsys(s)
+ write("$ ", s)
+ system(s)
+ return
+end
+
+
+# tpipe() -- test pipes
+
+procedure tpipe()
+ local f, p
+
+ # very simple case
+ write()
+ p := open("echo hello world", "rp") | stop("can't open echo pipe")
+ write(image(p))
+ while write("> ", read(p))
+ close(p)
+
+ # check unclosed pipe
+ write()
+ p := open("sed 's/^/=()= /' io.icn", "p") | stop("can't open sed pipe")
+ write(image(p))
+ every 1 to 10 do write("> ", read(p))
+ # p is deliberately left unclosed
+
+ # check wildcarding, and also !pipe
+ write()
+ p := open("ls io.i?n io.d?t io.s?d", "p") | stop("can't open ls pipe")
+ write(image(p))
+ every write("> ", !p)
+ close(p)
+
+ # check output pipe
+ write()
+ p := open("tr aeiou oaeui", "wp") | stop("can't open tr pipe")
+ write(image(p))
+ write(p, "once upon a midnight dreary")
+ write(p, "two roads diverged in a yellow wood")
+ write(p, "and the mome raths outgrabe")
+ write("--- closing output pipe")
+ close(p)
+ write("--- done closing output pipe")
+ remove("tmp1")
+
+ return
+end
diff --git a/tests/general/io.std b/tests/general/io.std
new file mode 100644
index 0000000..b512c97
--- /dev/null
+++ b/tests/general/io.std
@@ -0,0 +1,125 @@
+file: &errout
+file: &input
+file: &output
+file: file(/dev/null)
+file: file(/etc/motd)
+
+aaa
+bbbb
+ccccc
+dddddd
+eeeeeee
+ffffffff
+ggggggggg
+hhhhhhhhhh
+
+flush /etc/motd: file(/etc/motd)
+close /etc/motd: file(/etc/motd)
+close /etc/motd: file(/etc/motd)
+flush /etc/motd: file(/etc/motd)
+
+flush /dev/null: file(/dev/null)
+close /dev/null: file(/dev/null)
+close /dev/null: file(/dev/null)
+flush /dev/null: file(/dev/null)
+
+read /dev/null:
+ !f:
+ read/!f:
+ reads():
+
+write tmp1,w: follow the yellow brick road : 30
+read tmp1: follow the yellow brick road
+ !f: follow the yellow brick road
+ read/!f: follow the yellow brick road
+ reads(): follo w.the .yell ow.br ick.r oad.
+
+write tmp1,w: shorter file : 14
+read tmp1: shorter file
+ !f: shorter file
+ read/!f: shorter file
+ reads(): short er.fi le.
+
+write tmp1,a: gets extended : 28
+read tmp1: shorter file gets extended
+ !f: shorter file gets extended
+ read/!f: shorter file gets extended
+ reads(): short er.fi le.ge ts.ex tende d.
+
+write tmp1,rw: changed : 9
+read tmp1: changed file gets extended
+ !f: changed file gets extended
+ read/!f: changed file gets extended
+ reads(): chang ed.fi le.ge ts.ex tende d.
+
+write tmp1,b: mode b : 8
+read tmp1: mode b file gets extended
+ !f: mode b file gets extended
+ read/!f: mode b file gets extended
+ reads(): mode. b..fi le.ge ts.ex tende d.
+
+write tmp1,crw: cleared anew : 14
+read tmp1: cleared anew
+ !f: cleared anew
+ read/!f: cleared anew
+ reads(): clear ed.an ew.
+read tmp2: cleared anew
+ !f: cleared anew
+ read/!f: cleared anew
+ reads(): clear ed.an ew.
+
+file(tmp1)
+file(tmp2)
+>stdout>stdout>stdout
+
+>stdout
+
+read tmp1: >1a>1b>1c >1d >1e>1f
+ !f: >1a>1b>1c >1d >1e>1f
+ read/!f: >1a>1b>1c >1d >1e>1f
+ reads(): >1a>1 b>1c. .>1d. .>1e> 1f.
+read tmp2: >2a>2b >2c >2d >2e>2f
+ !f: >2a>2b >2c >2d >2e>2f
+ read/!f: >2a>2b >2c >2d >2e>2f
+ reads(): >2a>2 b.>2c .>2d. .>2e> 2f.
+
+abcdef
+ghi
+jklmno
+pqr
+stu
+vwxyz
+
+$ echo hello world
+hello world
+$ ls io.[ids][tca][dnt]
+io.dat
+io.icn
+io.std
+
+file(echo hello world)
+> hello world
+
+file(sed 's/^/=()= /' io.icn)
+> =()= #SRC: JCON
+> =()=
+> =()= # I/O test -- writes ./tmp1 and ./tmp2 as well as stdout
+> =()=
+> =()= procedure main()
+> =()= local L, f, m, n, t1, t2
+> =()=
+> =()= L := [&input, &output, &errout,
+> =()= m := open("/etc/motd") | stop("no /etc/motd"),
+> =()= n := open("/dev/null", "w") | stop("no /dev/null")]
+
+file(ls io.i?n io.d?t io.s?d)
+> io.dat
+> io.icn
+> io.std
+
+file(tr aeiou oaeui)
+--- closing output pipe
+unca ipun o medneght draory
+twu ruods devargad en o yalluw wuud
+ond tha muma roths uitgroba
+--- done closing output pipe
diff --git a/tests/general/kross.dat b/tests/general/kross.dat
new file mode 100644
index 0000000..7372e75
--- /dev/null
+++ b/tests/general/kross.dat
@@ -0,0 +1,3 @@
+elephants:peanuts
+encroachment:roaches
+gaggle:geese
diff --git a/tests/general/kross.icn b/tests/general/kross.icn
new file mode 100644
index 0000000..8090f38
--- /dev/null
+++ b/tests/general/kross.icn
@@ -0,0 +1,30 @@
+#
+# W O R D I N T E R S E C T I O N S
+#
+
+# This program procedure accepts string pairs from standard input, with
+# the strings separated by semicolons. It then diagrams all the
+# intersections of the two strings in a common character.
+
+procedure main()
+ local line, j
+ while line := read() do $(
+ write()
+ j := upto(':',line)
+ cross(line$<1:j$>,line$<j+1:0$>)
+ $)
+end
+
+procedure cross(s1,s2)
+ local j, k
+ every j := upto(s2,s1) do
+ every k := upto(s1$<j$>,s2) do
+ xprint(s1,s2,j,k)
+end
+
+procedure xprint(s1,s2,j,k)
+ write()
+ every write(right(s2$<1 to k-1$>,j))
+ write(s1)
+ every write(right(s2$<k+1 to *s2$>,j))
+end
diff --git a/tests/general/kross.std b/tests/general/kross.std
new file mode 100644
index 0000000..b63196b
--- /dev/null
+++ b/tests/general/kross.std
@@ -0,0 +1,159 @@
+
+
+p
+elephants
+a
+n
+u
+t
+s
+
+ p
+elephants
+ a
+ n
+ u
+ t
+ s
+
+elephants
+ e
+ a
+ n
+ u
+ t
+ s
+
+ p
+ e
+elephants
+ n
+ u
+ t
+ s
+
+ p
+ e
+ a
+elephants
+ u
+ t
+ s
+
+ p
+ e
+ a
+ n
+ u
+elephants
+ s
+
+ p
+ e
+ a
+ n
+ u
+ t
+elephants
+
+
+r
+o
+a
+c
+h
+encroachment
+s
+
+ r
+ o
+ a
+encroachment
+ h
+ e
+ s
+
+encroachment
+ o
+ a
+ c
+ h
+ e
+ s
+
+ r
+encroachment
+ a
+ c
+ h
+ e
+ s
+
+ r
+ o
+encroachment
+ c
+ h
+ e
+ s
+
+ r
+ o
+ a
+encroachment
+ h
+ e
+ s
+
+ r
+ o
+ a
+ c
+encroachment
+ e
+ s
+
+ r
+ o
+ a
+ c
+ h
+encroachment
+ s
+
+
+gaggle
+e
+e
+s
+e
+
+gaggle
+ e
+ e
+ s
+ e
+
+gaggle
+ e
+ e
+ s
+ e
+
+ g
+gaggle
+ e
+ s
+ e
+
+ g
+ e
+gaggle
+ s
+ e
+
+ g
+ e
+ e
+ s
+gaggle
diff --git a/tests/general/kwds.icn b/tests/general/kwds.icn
new file mode 100644
index 0000000..3db341f
--- /dev/null
+++ b/tests/general/kwds.icn
@@ -0,0 +1,91 @@
+#SRC: JCON
+
+# kwds.icn -- check keywords, as best can do reproducibly
+
+procedure main()
+ local f
+
+ &error := 747
+ # every kw("allocated", &allocated | "[failed]")
+ every kw("ascii", &ascii | "[failed]")
+ every kw("clock", nmap(&clock) | "[failed]")
+ # every kw("col", &col | "[failed]")
+ every kw("collections", &collections | "[failed]")
+ # every kw("control", &control | "[failed]")
+ every kw("cset", &cset | "[failed]")
+ every kw("current", &current | "[failed]")
+ every kw("date", nmap(&date) | "[failed]")
+ every kw("dateline", (&dateline ** 'kwfxday, EIRL:m') | "[failed]")
+ every kw("digits", &digits | "[failed]")
+ every kw("dump", &dump | "[failed]")
+ every kw("e", &e | "[failed]")
+ every kw("error", &error | "[failed]")
+ every kw("errornumber", &errornumber | "[failed]")
+ every kw("errortext", &errortext | "[failed]")
+ every kw("errorvalue", &errorvalue | "[failed]")
+ every kw("errout", &errout | "[failed]")
+ every kw("fail", &fail | "[failed]")
+
+ every insert(f := set(), &features)
+ every delete(f, "UNIX" | "MS Windows" | "Cygwin") # platform ID
+ every delete(f, "dynamic loading" | "graphics" | "X Windows") # may be absent
+ every kw("features", member(f, &features))
+
+ every kw("input", &input | "[failed]")
+ every kw("interval", &interval | "[failed]")
+ every kw("lcase", &lcase | "[failed]")
+ every kw("ldrag", &ldrag | "[failed]")
+ every kw("letters", &letters | "[failed]")
+ every kw("level", &level | "[failed]")
+ every kw("lpress", &lpress | "[failed]")
+ every kw("lrelease", &lrelease | "[failed]")
+ every kw("main", &main | "[failed]")
+ every kw("mdrag", &mdrag | "[failed]")
+ # every kw("meta", &meta | "[failed]")
+ every kw("mpress", &mpress | "[failed]")
+ every kw("mrelease", &mrelease | "[failed]")
+ every kw("null", &null | "[failed]")
+ every kw("output", &output | "[failed]")
+ every kw("phi", &phi | "[failed]")
+ every kw("pi", &pi | "[failed]")
+ every kw("pos", &pos | "[failed]")
+ every kw("progname", &progname | "[failed]")
+ every kw("random", &random | "[failed]")
+ every kw("rdrag", &rdrag | "[failed]")
+ every kw("regions", &regions | "[failed]")
+ every kw("resize", &resize | "[failed]")
+ # every kw("row", &row | "[failed]")
+ every kw("rpress", &rpress | "[failed]")
+ every kw("rrelease", &rrelease | "[failed]")
+ # every kw("shift", &shift | "[failed]")
+ every kw("source", &source | "[failed]")
+ # every kw("storage", &storage | "[failed]")
+ every kw("subject", &subject | "[failed]")
+ every kw("time", nmap(right(&time,4,0)) | "[failed]")
+ every kw("trace", &trace | "[failed]")
+ every kw("ucase", &ucase | "[failed]")
+ # every kw("version", left(&version,16) | "[failed]")
+ # every kw("window", &window | "[failed]")
+ # every kw("x", &x | "[failed]")
+ # every kw("y", &y | "[failed]")
+end
+
+procedure kw(label, value)
+ local s
+ static prev
+
+ if \prev == label & value == "[failed]" then
+ return
+ case type(value) of {
+ "string": s := value
+ "cset": s := image(value) || " [size " || *value || "]"
+ default: s := image(value)
+ }
+ write(right("&" || label, 12), ": ", s)
+ prev := label
+ return
+end
+
+procedure nmap(s)
+ return map(s, "0123456789", "nnnnnnnnnn")
+end
diff --git a/tests/general/kwds.std b/tests/general/kwds.std
new file mode 100644
index 0000000..fba6078
--- /dev/null
+++ b/tests/general/kwds.std
@@ -0,0 +1,57 @@
+ &ascii: &ascii [size 128]
+ &clock: nn:nn:nn
+&collections: 0
+&collections: 0
+&collections: 0
+&collections: 0
+ &cset: &cset [size 256]
+ &current: co-expression_1(1)
+ &date: nnnn/nn/nn
+ &dateline: ' ,:admy' [size 7]
+ &digits: &digits [size 10]
+ &dump: 0
+ &e: 2.718281828
+ &error: 747
+&errornumber: [failed]
+ &errortext: [failed]
+ &errorvalue: [failed]
+ &errout: &errout
+ &fail: [failed]
+ &features: ASCII
+ &features: co-expressions
+ &features: environment variables
+ &features: keyboard functions
+ &features: large integers
+ &features: pipes
+ &features: system function
+ &input: &input
+ &interval: [failed]
+ &lcase: &lcase [size 26]
+ &ldrag: -7
+ &letters: &letters [size 52]
+ &level: 1
+ &lpress: -1
+ &lrelease: -4
+ &main: co-expression_1(1)
+ &mdrag: -8
+ &mpress: -2
+ &mrelease: -5
+ &null: &null
+ &output: &output
+ &phi: 1.618033989
+ &pi: 3.141592654
+ &pos: 1
+ &progname: ./kwds
+ &random: 0
+ &rdrag: -9
+ &regions: 0
+ &regions: 500000
+ &regions: 500000
+ &resize: -10
+ &rpress: -3
+ &rrelease: -6
+ &source: co-expression_1(1)
+ &subject:
+ &time: nnnn
+ &trace: 0
+ &ucase: &ucase [size 26]
diff --git a/tests/general/large.icn b/tests/general/large.icn
new file mode 100644
index 0000000..ed14206
--- /dev/null
+++ b/tests/general/large.icn
@@ -0,0 +1,37 @@
+invocable "+", "-", "*", "/", "%", "iand", "ior", "ixor", "<", "=" , "^"
+invocable "ishift"
+
+procedure main ()
+ if not(&features == "large integers") then
+ stop("large integers not supported")
+
+ big := 111111111111111111111
+ med1 := "2222222222"
+ med2 := "3333333333"
+ small := 4
+
+ every optest ("+" | "-" | "*" | "/" | "%" |"iand"|"ior"|"ixor"|"<"|"=",
+ big | -big | small | -small,
+ big | -big | small | -small)
+ every optest ("+" | "-" | "*" | "/" | "%" |"iand"|"ior"|"ixor"|"<"|"=",
+ big | med1 | -med1,
+ med1 | med2 | -med2)
+
+ every optest ("^", big | -big | small | -small, 2 | 5)
+ every optest ("^", 2 | 3, 10 | 30 )
+ every optest ("ishift", big |-big | med1 | -med1 | small, 1 | 8 | -1 | -39)
+
+ &trace := -1
+ every i := 10 | 30 | 70 | 100 do {
+ write(2 ^ i)
+ write(2 ^ i || ":" || image(2 ^ i))
+ foo(2 ^ i)
+ }
+end
+
+procedure optest (op, a, b)
+ write (a, " ", op, " ", b, " = ", op(a,b)|"none")
+end
+
+procedure foo(x)
+end
diff --git a/tests/general/large.std b/tests/general/large.std
new file mode 100644
index 0000000..c410cd5
--- /dev/null
+++ b/tests/general/large.std
@@ -0,0 +1,299 @@
+111111111111111111111 + 111111111111111111111 = 222222222222222222222
+111111111111111111111 + -111111111111111111111 = 0
+111111111111111111111 + 4 = 111111111111111111115
+111111111111111111111 + -4 = 111111111111111111107
+-111111111111111111111 + 111111111111111111111 = 0
+-111111111111111111111 + -111111111111111111111 = -222222222222222222222
+-111111111111111111111 + 4 = -111111111111111111107
+-111111111111111111111 + -4 = -111111111111111111115
+4 + 111111111111111111111 = 111111111111111111115
+4 + -111111111111111111111 = -111111111111111111107
+4 + 4 = 8
+4 + -4 = 0
+-4 + 111111111111111111111 = 111111111111111111107
+-4 + -111111111111111111111 = -111111111111111111115
+-4 + 4 = 0
+-4 + -4 = -8
+111111111111111111111 - 111111111111111111111 = 0
+111111111111111111111 - -111111111111111111111 = 222222222222222222222
+111111111111111111111 - 4 = 111111111111111111107
+111111111111111111111 - -4 = 111111111111111111115
+-111111111111111111111 - 111111111111111111111 = -222222222222222222222
+-111111111111111111111 - -111111111111111111111 = 0
+-111111111111111111111 - 4 = -111111111111111111115
+-111111111111111111111 - -4 = -111111111111111111107
+4 - 111111111111111111111 = -111111111111111111107
+4 - -111111111111111111111 = 111111111111111111115
+4 - 4 = 0
+4 - -4 = 8
+-4 - 111111111111111111111 = -111111111111111111115
+-4 - -111111111111111111111 = 111111111111111111107
+-4 - 4 = -8
+-4 - -4 = 0
+111111111111111111111 * 111111111111111111111 = 12345679012345679012320987654320987654321
+111111111111111111111 * -111111111111111111111 = -12345679012345679012320987654320987654321
+111111111111111111111 * 4 = 444444444444444444444
+111111111111111111111 * -4 = -444444444444444444444
+-111111111111111111111 * 111111111111111111111 = -12345679012345679012320987654320987654321
+-111111111111111111111 * -111111111111111111111 = 12345679012345679012320987654320987654321
+-111111111111111111111 * 4 = -444444444444444444444
+-111111111111111111111 * -4 = 444444444444444444444
+4 * 111111111111111111111 = 444444444444444444444
+4 * -111111111111111111111 = -444444444444444444444
+4 * 4 = 16
+4 * -4 = -16
+-4 * 111111111111111111111 = -444444444444444444444
+-4 * -111111111111111111111 = 444444444444444444444
+-4 * 4 = -16
+-4 * -4 = 16
+111111111111111111111 / 111111111111111111111 = 1
+111111111111111111111 / -111111111111111111111 = -1
+111111111111111111111 / 4 = 27777777777777777777
+111111111111111111111 / -4 = -27777777777777777777
+-111111111111111111111 / 111111111111111111111 = -1
+-111111111111111111111 / -111111111111111111111 = 1
+-111111111111111111111 / 4 = -27777777777777777777
+-111111111111111111111 / -4 = 27777777777777777777
+4 / 111111111111111111111 = 0
+4 / -111111111111111111111 = 0
+4 / 4 = 1
+4 / -4 = -1
+-4 / 111111111111111111111 = 0
+-4 / -111111111111111111111 = 0
+-4 / 4 = -1
+-4 / -4 = 1
+111111111111111111111 % 111111111111111111111 = 0
+111111111111111111111 % -111111111111111111111 = 0
+111111111111111111111 % 4 = 3
+111111111111111111111 % -4 = 3
+-111111111111111111111 % 111111111111111111111 = 0
+-111111111111111111111 % -111111111111111111111 = 0
+-111111111111111111111 % 4 = -3
+-111111111111111111111 % -4 = -3
+4 % 111111111111111111111 = 4
+4 % -111111111111111111111 = 4
+4 % 4 = 0
+4 % -4 = 0
+-4 % 111111111111111111111 = -4
+-4 % -111111111111111111111 = -4
+-4 % 4 = 0
+-4 % -4 = 0
+111111111111111111111 iand 111111111111111111111 = 111111111111111111111
+111111111111111111111 iand -111111111111111111111 = 1
+111111111111111111111 iand 4 = 4
+111111111111111111111 iand -4 = 111111111111111111108
+-111111111111111111111 iand 111111111111111111111 = 1
+-111111111111111111111 iand -111111111111111111111 = -111111111111111111111
+-111111111111111111111 iand 4 = 0
+-111111111111111111111 iand -4 = -111111111111111111112
+4 iand 111111111111111111111 = 4
+4 iand -111111111111111111111 = 0
+4 iand 4 = 4
+4 iand -4 = 4
+-4 iand 111111111111111111111 = 111111111111111111108
+-4 iand -111111111111111111111 = -111111111111111111112
+-4 iand 4 = 4
+-4 iand -4 = -4
+111111111111111111111 ior 111111111111111111111 = 111111111111111111111
+111111111111111111111 ior -111111111111111111111 = -1
+111111111111111111111 ior 4 = 111111111111111111111
+111111111111111111111 ior -4 = -1
+-111111111111111111111 ior 111111111111111111111 = -1
+-111111111111111111111 ior -111111111111111111111 = -111111111111111111111
+-111111111111111111111 ior 4 = -111111111111111111107
+-111111111111111111111 ior -4 = -3
+4 ior 111111111111111111111 = 111111111111111111111
+4 ior -111111111111111111111 = -111111111111111111107
+4 ior 4 = 4
+4 ior -4 = -4
+-4 ior 111111111111111111111 = -1
+-4 ior -111111111111111111111 = -3
+-4 ior 4 = -4
+-4 ior -4 = -4
+111111111111111111111 ixor 111111111111111111111 = 0
+111111111111111111111 ixor -111111111111111111111 = -2
+111111111111111111111 ixor 4 = 111111111111111111107
+111111111111111111111 ixor -4 = -111111111111111111109
+-111111111111111111111 ixor 111111111111111111111 = -2
+-111111111111111111111 ixor -111111111111111111111 = 0
+-111111111111111111111 ixor 4 = -111111111111111111107
+-111111111111111111111 ixor -4 = 111111111111111111109
+4 ixor 111111111111111111111 = 111111111111111111107
+4 ixor -111111111111111111111 = -111111111111111111107
+4 ixor 4 = 0
+4 ixor -4 = -8
+-4 ixor 111111111111111111111 = -111111111111111111109
+-4 ixor -111111111111111111111 = 111111111111111111109
+-4 ixor 4 = -8
+-4 ixor -4 = 0
+111111111111111111111 < 111111111111111111111 = none
+111111111111111111111 < -111111111111111111111 = none
+111111111111111111111 < 4 = none
+111111111111111111111 < -4 = none
+-111111111111111111111 < 111111111111111111111 = 111111111111111111111
+-111111111111111111111 < -111111111111111111111 = none
+-111111111111111111111 < 4 = 4
+-111111111111111111111 < -4 = -4
+4 < 111111111111111111111 = 111111111111111111111
+4 < -111111111111111111111 = none
+4 < 4 = none
+4 < -4 = none
+-4 < 111111111111111111111 = 111111111111111111111
+-4 < -111111111111111111111 = none
+-4 < 4 = 4
+-4 < -4 = none
+111111111111111111111 = 111111111111111111111 = 111111111111111111111
+111111111111111111111 = -111111111111111111111 = none
+111111111111111111111 = 4 = none
+111111111111111111111 = -4 = none
+-111111111111111111111 = 111111111111111111111 = none
+-111111111111111111111 = -111111111111111111111 = -111111111111111111111
+-111111111111111111111 = 4 = none
+-111111111111111111111 = -4 = none
+4 = 111111111111111111111 = none
+4 = -111111111111111111111 = none
+4 = 4 = 4
+4 = -4 = none
+-4 = 111111111111111111111 = none
+-4 = -111111111111111111111 = none
+-4 = 4 = none
+-4 = -4 = -4
+111111111111111111111 + 2222222222 = 111111111113333333333
+111111111111111111111 + 3333333333 = 111111111114444444444
+111111111111111111111 + -3333333333 = 111111111107777777778
+2222222222 + 2222222222 = 4444444444
+2222222222 + 3333333333 = 5555555555
+2222222222 + -3333333333 = -1111111111
+-2222222222 + 2222222222 = 0
+-2222222222 + 3333333333 = 1111111111
+-2222222222 + -3333333333 = -5555555555
+111111111111111111111 - 2222222222 = 111111111108888888889
+111111111111111111111 - 3333333333 = 111111111107777777778
+111111111111111111111 - -3333333333 = 111111111114444444444
+2222222222 - 2222222222 = 0
+2222222222 - 3333333333 = -1111111111
+2222222222 - -3333333333 = 5555555555
+-2222222222 - 2222222222 = -4444444444
+-2222222222 - 3333333333 = -5555555555
+-2222222222 - -3333333333 = 1111111111
+111111111111111111111 * 2222222222 = 246913580222222222221975308642
+111111111111111111111 * 3333333333 = 370370370333333333332962962963
+111111111111111111111 * -3333333333 = -370370370333333333332962962963
+2222222222 * 2222222222 = 4938271603950617284
+2222222222 * 3333333333 = 7407407405925925926
+2222222222 * -3333333333 = -7407407405925925926
+-2222222222 * 2222222222 = -4938271603950617284
+-2222222222 * 3333333333 = -7407407405925925926
+-2222222222 * -3333333333 = 7407407405925925926
+111111111111111111111 / 2222222222 = 50000000005
+111111111111111111111 / 3333333333 = 33333333336
+111111111111111111111 / -3333333333 = -33333333336
+2222222222 / 2222222222 = 1
+2222222222 / 3333333333 = 0
+2222222222 / -3333333333 = 0
+-2222222222 / 2222222222 = -1
+-2222222222 / 3333333333 = 0
+-2222222222 / -3333333333 = 0
+111111111111111111111 % 2222222222 = 1
+111111111111111111111 % 3333333333 = 2222222223
+111111111111111111111 % -3333333333 = 2222222223
+2222222222 % 2222222222 = 0
+2222222222 % 3333333333 = 2222222222
+2222222222 % -3333333333 = 2222222222
+-2222222222 % 2222222222 = 0
+-2222222222 % 3333333333 = -2222222222
+-2222222222 % -3333333333 = -2222222222
+111111111111111111111 iand 2222222222 = 3432838
+111111111111111111111 iand 3333333333 = 11280709
+111111111111111111111 iand -3333333333 = 111111111111099830403
+2222222222 iand 2222222222 = 2222222222
+2222222222 iand 3333333333 = 2216960260
+2222222222 iand -3333333333 = 5261962
+-2222222222 iand 2222222222 = 2
+-2222222222 iand 3333333333 = 1116373072
+-2222222222 iand -3333333333 = -3338595294
+111111111111111111111 ior 2222222222 = 111111111113329900495
+111111111111111111111 ior 3333333333 = 111111111114433163735
+111111111111111111111 ior -3333333333 = -3322052625
+2222222222 ior 2222222222 = 2222222222
+2222222222 ior 3333333333 = 3338595295
+2222222222 ior -3333333333 = -1116373073
+-2222222222 ior 2222222222 = -2
+-2222222222 ior 3333333333 = -5261961
+-2222222222 ior -3333333333 = -2216960261
+111111111111111111111 ixor 2222222222 = 111111111113326467657
+111111111111111111111 ixor 3333333333 = 111111111114421883026
+111111111111111111111 ixor -3333333333 = -111111111114421883028
+2222222222 ixor 2222222222 = 0
+2222222222 ixor 3333333333 = 1121635035
+2222222222 ixor -3333333333 = -1121635035
+-2222222222 ixor 2222222222 = -4
+-2222222222 ixor 3333333333 = -1121635033
+-2222222222 ixor -3333333333 = 1121635033
+111111111111111111111 < 2222222222 = none
+111111111111111111111 < 3333333333 = none
+111111111111111111111 < -3333333333 = none
+2222222222 < 2222222222 = none
+2222222222 < 3333333333 = 3333333333
+2222222222 < -3333333333 = none
+-2222222222 < 2222222222 = 2222222222
+-2222222222 < 3333333333 = 3333333333
+-2222222222 < -3333333333 = none
+111111111111111111111 = 2222222222 = none
+111111111111111111111 = 3333333333 = none
+111111111111111111111 = -3333333333 = none
+2222222222 = 2222222222 = 2222222222
+2222222222 = 3333333333 = none
+2222222222 = -3333333333 = none
+-2222222222 = 2222222222 = none
+-2222222222 = 3333333333 = none
+-2222222222 = -3333333333 = none
+111111111111111111111 ^ 2 = 12345679012345679012320987654320987654321
+111111111111111111111 ^ 5 = 16935087808430286710951921285711866416027536452776507646192145336923571948720554116157767278023336551
+-111111111111111111111 ^ 2 = 12345679012345679012320987654320987654321
+-111111111111111111111 ^ 5 = -16935087808430286710951921285711866416027536452776507646192145336923571948720554116157767278023336551
+4 ^ 2 = 16
+4 ^ 5 = 1024
+-4 ^ 2 = 16
+-4 ^ 5 = -1024
+2 ^ 10 = 1024
+2 ^ 30 = 1073741824
+3 ^ 10 = 59049
+3 ^ 30 = 205891132094649
+111111111111111111111 ishift 1 = 222222222222222222222
+111111111111111111111 ishift 8 = 28444444444444444444416
+111111111111111111111 ishift -1 = 55555555555555555555
+111111111111111111111 ishift -39 = 202109933
+-111111111111111111111 ishift 1 = -222222222222222222222
+-111111111111111111111 ishift 8 = -28444444444444444444416
+-111111111111111111111 ishift -1 = -55555555555555555556
+-111111111111111111111 ishift -39 = -202109934
+2222222222 ishift 1 = 4444444444
+2222222222 ishift 8 = 568888888832
+2222222222 ishift -1 = 1111111111
+2222222222 ishift -39 = 0
+-2222222222 ishift 1 = -4444444444
+-2222222222 ishift 8 = -568888888832
+-2222222222 ishift -1 = -1111111111
+-2222222222 ishift -39 = -1
+4 ishift 1 = 8
+4 ishift 8 = 1024
+4 ishift -1 = 2
+4 ishift -39 = 0
+1024
+1024:1024
+large.icn : 28 | foo(1024)
+large.icn : 37 | foo failed
+1073741824
+1073741824:1073741824
+large.icn : 28 | foo(1073741824)
+large.icn : 37 | foo failed
+1180591620717411303424
+1180591620717411303424:1180591620717411303424
+large.icn : 28 | foo(1180591620717411303424)
+large.icn : 37 | foo failed
+1267650600228229401496703205376
+1267650600228229401496703205376:integer(~10^30)
+large.icn : 28 | foo(integer(~10^30))
+large.icn : 37 | foo failed
+large.icn : 30 main failed
diff --git a/tests/general/left.icn b/tests/general/left.icn
new file mode 100644
index 0000000..94fa2ad
--- /dev/null
+++ b/tests/general/left.icn
@@ -0,0 +1,31 @@
+#SRC: JCON
+
+procedure main()
+
+ write(left("abc"))
+ write(left("def", ))
+ write(left("ghi", &null))
+ write(left("jkl", 2))
+ write(left("mno", 3))
+ write(left(237, 4))
+ write(left("stu", 5))
+ write(left("vwx", 6))
+
+ write(left("abc", 3, ))
+ write(left("def", , "."))
+ write(left("ghi", &null, "."))
+ write(left("jkl", 2, "."))
+ write(left("mno", 3, "."))
+ write(left(237, 4, "."))
+ write(left("stu", 5, "."))
+ write(left("vwx", 6, "."))
+
+ write(left("abc", 3, ))
+ write(left("def", , "<>"))
+ write(left("ghi", &null, "<>"))
+ write(left("jkl", 2, "<>"))
+ write(left("mno", 3, "<>"))
+ write(left(237, 4, "<>"))
+ write(left("stu", 5, "<>"))
+ write(left("vwx", 6, "<>"))
+end
diff --git a/tests/general/left.std b/tests/general/left.std
new file mode 100644
index 0000000..f3feed7
--- /dev/null
+++ b/tests/general/left.std
@@ -0,0 +1,24 @@
+a
+d
+g
+jk
+mno
+237
+stu
+vwx
+abc
+d
+g
+jk
+mno
+237.
+stu..
+vwx...
+abc
+d
+g
+jk
+mno
+237>
+stu<>
+vwx><>
diff --git a/tests/general/level.icn b/tests/general/level.icn
new file mode 100644
index 0000000..7af1e38
--- /dev/null
+++ b/tests/general/level.icn
@@ -0,0 +1,21 @@
+#SRC: JCON
+
+procedure main()
+ write(&level);
+ foo(3);
+ write(&level);
+ every bar(3)
+ write(&level);
+end
+
+procedure foo(n)
+ write(&level);
+ if n ~= 0 then foo(n-1)
+ write(&level);
+end
+
+procedure bar(n)
+ write(&level);
+ suspend 1 to n do write(&level)
+ write(&level);
+end
diff --git a/tests/general/level.std b/tests/general/level.std
new file mode 100644
index 0000000..c674bc2
--- /dev/null
+++ b/tests/general/level.std
@@ -0,0 +1,16 @@
+1
+2
+3
+4
+5
+5
+4
+3
+2
+1
+2
+2
+2
+2
+2
+1
diff --git a/tests/general/lexcmp.icn b/tests/general/lexcmp.icn
new file mode 100644
index 0000000..facf92a
--- /dev/null
+++ b/tests/general/lexcmp.icn
@@ -0,0 +1,27 @@
+#SRC: JCON
+
+# lexical comparison test
+
+procedure main()
+ local s, t
+
+ write(" s1 s2 << <<= == ~== >>= >>")
+
+ every (s := "" | "a" | "b" | 'c' | "x" | 2 | '') &
+ (t := "" | "a" | "c" | 'x' | '2') do {
+ wr(s)
+ wr(t)
+ wr(s << t | &null)
+ wr(s <<= t | &null)
+ wr(s == t | &null)
+ wr(s ~== t | &null)
+ wr(s >>= t | &null)
+ wr(s >> t | &null)
+ write()
+ }
+ end
+
+procedure wr(s)
+ writes(right(image(\s) | "---", 6))
+ return
+end
diff --git a/tests/general/lexcmp.std b/tests/general/lexcmp.std
new file mode 100644
index 0000000..e81fdec
--- /dev/null
+++ b/tests/general/lexcmp.std
@@ -0,0 +1,36 @@
+ s1 s2 << <<= == ~== >>= >>
+ "" "" --- "" "" --- "" ---
+ "" "a" "a" "a" --- "a" --- ---
+ "" "c" "c" "c" --- "c" --- ---
+ "" 'x' "x" "x" --- "x" --- ---
+ "" '2' "2" "2" --- "2" --- ---
+ "a" "" --- --- --- "" "" ""
+ "a" "a" --- "a" "a" --- "a" ---
+ "a" "c" "c" "c" --- "c" --- ---
+ "a" 'x' "x" "x" --- "x" --- ---
+ "a" '2' --- --- --- "2" "2" "2"
+ "b" "" --- --- --- "" "" ""
+ "b" "a" --- --- --- "a" "a" "a"
+ "b" "c" "c" "c" --- "c" --- ---
+ "b" 'x' "x" "x" --- "x" --- ---
+ "b" '2' --- --- --- "2" "2" "2"
+ 'c' "" --- --- --- "" "" ""
+ 'c' "a" --- --- --- "a" "a" "a"
+ 'c' "c" --- "c" "c" --- "c" ---
+ 'c' 'x' "x" "x" --- "x" --- ---
+ 'c' '2' --- --- --- "2" "2" "2"
+ "x" "" --- --- --- "" "" ""
+ "x" "a" --- --- --- "a" "a" "a"
+ "x" "c" --- --- --- "c" "c" "c"
+ "x" 'x' --- "x" "x" --- "x" ---
+ "x" '2' --- --- --- "2" "2" "2"
+ 2 "" --- --- --- "" "" ""
+ 2 "a" "a" "a" --- "a" --- ---
+ 2 "c" "c" "c" --- "c" --- ---
+ 2 'x' "x" "x" --- "x" --- ---
+ 2 '2' --- "2" "2" --- "2" ---
+ '' "" --- "" "" --- "" ---
+ '' "a" "a" "a" --- "a" --- ---
+ '' "c" "c" "c" --- "c" --- ---
+ '' 'x' "x" "x" --- "x" --- ---
+ '' '2' "2" "2" --- "2" --- ---
diff --git a/tests/general/lgint.icn b/tests/general/lgint.icn
new file mode 100644
index 0000000..99fd360
--- /dev/null
+++ b/tests/general/lgint.icn
@@ -0,0 +1,218 @@
+#SRC: JCON
+#OPT: -fe
+
+# test large integer calculations
+
+procedure main()
+ local a, b, primes
+ primes := [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37,
+ 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
+
+ write(); compiler()
+ write(); boundaries()
+ write(); every fact(1 to 55 by 11)
+ write(); every fib(35 to 341 by 34)
+ write(); every mersenne(61 | 89 | 107 | 127)
+ write(); every perfect(31 | 61 | 89 | 107)
+ write(); every power(11213, 2 to 16)
+ write(); every impower(3, 60 to 75)
+ write(); every minpower(!primes)
+ write(); every bigexp(3 | 6 | -7)
+ write(); every tmul(2 | 3 | 5 | 7 | 10 | 17 | 51 | -3 | -11 | -43)
+ write(); every tmul(3 ^ (2 to 50))
+ write(); every conv(787 ^ (1 to 24) | -5781 ^ (1 to 18))
+ write(); radix()
+ write(); over()
+
+ # test unary and binary operations, including mixed-mode operations
+ a := [37, 5.0, 2 ^ 63, 11 ^ 19, 5 ^ 28]
+ b := [73, 9.0, -7 ^ 23, -(3 ^ 40), 17 ^ 16]
+ write(); every unops(!a | !b)
+ write(); every binops(!a, !b)
+end
+
+procedure compiler() # test compiler handling of lg constants
+ local a, b, c
+ a := 1618033988749894848204586834365638117720309
+ b := -2718281828459045235360287471352662497757247
+ c := +3141592653589793238462643383279502884197169
+ write(" a = ", a)
+ write(" b = ", b)
+ write(" c = ", c)
+ write("a + b = ", a + b)
+ write("b + c = ", b + c)
+ write("c + a = ", c + a)
+ return
+end
+
+procedure boundaries() # test boundary cases
+ local minint, maxint
+ write("minint = ", minint := -(2^64))
+ write("maxint = ", maxint := 2^64 - 1)
+ write("-minint = ", -minint)
+ write("abs(min) = ", abs(minint))
+ write("minint * -1 = ", minint * -1)
+ write("minint / -1 = ", minint / -1)
+ write("(2^32)^2 = ", (2 ^ 32) ^ 2)
+ return
+end
+
+procedure fact(n) # factorial
+ local f
+ f := 1
+ every f *:= 2 to n
+ write(n, "! = ", f)
+ return
+end
+
+procedure fib(n) # fibonacci
+ local a, b, i, t
+ a := b := t := 1
+ every i := 3 to n do {
+ t := a + b
+ a := b
+ b := t
+ }
+ write("F(", n, ") = ", t)
+ return
+end
+
+procedure power(b, n) # simple power calculation
+ write(b, " ^ ", n, " = ", b ^ n)
+ return
+end
+
+procedure impower(b, n) # power calculation with image() test
+ write(b, " ^ ", n, " = ", image(b ^ n))
+ return
+end
+
+procedure minpower(b) # find minimum power that is a large int
+ local e
+ 2 ^ 63 <= b ^ (e := seq(1))
+ write(right(b,2), " ^", right(e, 3), " =", right(b ^ e, 22))
+end
+
+procedure bigexp(v)
+ local x
+ &error := -1
+ write(" v = ", v)
+ every x := (-2 to 2) | (-3 to 3) / 2.0 do
+ write(right(x, 4), " ^ v = ", (x ^ v) | ("error " || &errornumber))
+ &error := 0
+ return
+end
+
+procedure mersenne(m) # Mersenne numbers
+ write("M(", m, ") = ", 2 ^ m - 1)
+ return
+end
+
+procedure perfect(m) # Mersenne perfect numbers
+ write("P(", m, ") = ", (2 ^ m - 1) * (2 ^ (m - 1)))
+ return
+end
+
+procedure tmul(x) # test multiply, divide, real(I)
+ local n, p, q, d, e
+
+ p := 1
+ n := 0
+ while p < 1e25 do {
+ n +:= 1
+ q := p
+ p *:= x
+ d := p / q
+ e := real(p) / real(q)
+ err := abs(e / x - 1)
+ if not (d = x & err < 1.0e-14) then # 1e-15 for most, 1e-14 for IBM
+ write(x, " ^ ", n, " = ", p, "\td=", d, "\te=", e, "\terr=", err)
+ }
+ write(x, " ^ ", n, " = ", p)
+ return
+end
+
+procedure conv(n) # test conversion to/from real & string
+ local sn, rn, in, d, r
+
+ sn := string(n)
+ in := integer(sn)
+ if in ~= n then {
+ write("str conv err: n=", n, " sn=", sn, " in=", in)
+ return
+ }
+ rn := real(n)
+ in := integer(rn)
+ d := n - in
+ r := d / rn
+ if abs(r) > 1.0e-14 then # 1e-15 works for most, need -14 for IBM
+ write("real conv err: n=", n, " rn=", rn, " in=", in, " d=", d, " r=", r)
+ else
+ write("conv ok: ", n)
+ return
+end
+
+procedure unops(n) # show results of unary ops and compares with 0
+ write("u: ", n, " ", -n, " ", icom(n), compares(n, 0))
+ if abs(n) ~= (if n > 0 then n else -n) then write(" abs failure")
+ return
+end
+
+procedure binops(m, n) # show results of binary operations
+ write("b: ", m, " ", n, compares(m, n))
+ write(" +- ", m + n, " ", m - n)
+ write(" */% ", m * n, " ", m / n, " ", m % n)
+ write(" &|! ", iand(m, n), " ", ior(m, n), " ", ixor(m, n))
+ return
+end
+
+procedure compares(m, n) # return string indicating successful compares
+ local s
+ # == n validates value of comparison expr
+ s := " "
+ if (m < n) == n then s ||:= " <"
+ if (m <= n) == n then s ||:= " <="
+ if (m = n) == n then s ||:= " ="
+ if (m ~= n) == n then s ||:= " ~="
+ if (m > n) == n then s ||:= " >"
+ if (m >= n) == n then s ||:= " >="
+ return s
+end
+
+procedure radix() # radix conversions
+ local b, s, d, min, n
+ min := 2 ^ 63
+ d := &digits || &lcase
+ every b := 2 to 35 do {
+ n := (min < integer(s := b || "R" || repl(d[b], 1 to 100)))
+ write(s, " = ", n)
+ }
+ every s := "36r" || repl("Z", 10 to 20) do
+ write(s, " = ", integer(s))
+ return
+end
+
+procedure over() # old "over.icn" test from Icon v9
+ local i
+
+ if not(&features == "large integers") then
+ stop("large integers not supported")
+ i := 100000 + 10000
+ write(i)
+ i +:= 2 ^ 30
+ write(i)
+ i +:= i
+ write(i)
+ i := 100000 * 10000
+ write(i)
+ i +:= 2 ^ 30
+ write(i)
+ i *:= i
+ write(i)
+ i := -100000 - 10000
+ write(i)
+ i +:= -(2 ^ 30)
+ write(i)
+ i -:= 2 ^ 30
+ write(i)
+end
diff --git a/tests/general/lgint.std b/tests/general/lgint.std
new file mode 100644
index 0000000..ac712fc
--- /dev/null
+++ b/tests/general/lgint.std
@@ -0,0 +1,413 @@
+
+ a = 1618033988749894848204586834365638117720309
+ b = -2718281828459045235360287471352662497757247
+ c = 3141592653589793238462643383279502884197169
+a + b = -1100247839709150387155700636987024380036938
+b + c = 423310825130748003102355911926840386439922
+c + a = 4759626642339688086667230217645141001917478
+
+minint = -18446744073709551616
+maxint = 18446744073709551615
+-minint = 18446744073709551616
+abs(min) = 18446744073709551616
+minint * -1 = 18446744073709551616
+minint / -1 = 18446744073709551616
+(2^32)^2 = 18446744073709551616
+
+1! = 1
+12! = 479001600
+23! = 25852016738884976640000
+34! = 295232799039604140847618609643520000000
+45! = 119622220865480194561963161495657715064383733760000000000
+
+F(35) = 9227465
+F(69) = 117669030460994
+F(103) = 1500520536206896083277
+F(137) = 19134702400093278081449423917
+F(171) = 244006547798191185585064349218729154
+F(205) = 3111581989804070186099320645726169127737705
+F(239) = 39679027332006820581608740953902289877834488152161
+F(273) = 505988662735923140767969869749836918999964413630219877218
+F(307) = 6452389184720949856740872794933738025334109298792472139250504213
+F(341) = 82281144336295989585340713815384441479925901307982452831610787275979941
+
+M(61) = 2305843009213693951
+M(89) = 618970019642690137449562111
+M(107) = 162259276829213363391578010288127
+M(127) = 170141183460469231731687303715884105727
+
+P(31) = 2305843008139952128
+P(61) = 2658455991569831744654692615953842176
+P(89) = 191561942608236107294793378084303638130997321548169216
+P(107) = 13164036458569648337239753460458722910223472318386943117783728128
+
+11213 ^ 2 = 125731369
+11213 ^ 3 = 1409825840597
+11213 ^ 4 = 15808377150614161
+11213 ^ 5 = 177259332989836587293
+11213 ^ 6 = 1987608900815037653316409
+11213 ^ 7 = 22287058604839017206636894117
+11213 ^ 8 = 249904788136059899938019493733921
+11213 ^ 9 = 2802182389369639658005012583238456173
+11213 ^ 10 = 31420871132001769485210206095852809067849
+11213 ^ 11 = 352322228003135841237662040952797548077790837
+11213 ^ 12 = 3950589142599162187797904465203718906596268655281
+11213 ^ 13 = 44297956055964405611777902768329300099663960431665853
+11213 ^ 14 = 496712981255528880124865623741276442017531988320269209689
+11213 ^ 15 = 5569642658818245332840118239010932744342586185035178648242757
+11213 ^ 16 = 62452403133328984917136245814029588862313418892799458182746034241
+
+3 ^ 60 = 42391158275216203514294433201
+3 ^ 61 = 127173474825648610542883299603
+3 ^ 62 = integer(~10^30)
+3 ^ 63 = integer(~10^30)
+3 ^ 64 = integer(~10^31)
+3 ^ 65 = integer(~10^31)
+3 ^ 66 = integer(~10^31)
+3 ^ 67 = integer(~10^32)
+3 ^ 68 = integer(~10^32)
+3 ^ 69 = integer(~10^33)
+3 ^ 70 = integer(~10^33)
+3 ^ 71 = integer(~10^34)
+3 ^ 72 = integer(~10^34)
+3 ^ 73 = integer(~10^35)
+3 ^ 74 = integer(~10^35)
+3 ^ 75 = integer(~10^36)
+
+ 2 ^ 63 = 9223372036854775808
+ 3 ^ 40 = 12157665459056928801
+ 5 ^ 28 = 37252902984619140625
+ 7 ^ 23 = 27368747340080916343
+11 ^ 19 = 61159090448414546291
+13 ^ 18 = 112455406951957393129
+17 ^ 16 = 48661191875666868481
+19 ^ 15 = 15181127029874798299
+23 ^ 14 = 11592836324538749809
+29 ^ 13 = 10260628712958602189
+31 ^ 13 = 24417546297445042591
+37 ^ 13 = 243569224216081305397
+41 ^ 12 = 22563490300366186081
+43 ^ 12 = 39959630797262576401
+47 ^ 12 = 116191483108948578241
+53 ^ 11 = 9269035929372191597
+59 ^ 11 = 30155888444737842659
+61 ^ 11 = 43513917611435838661
+67 ^ 11 = 122130132904968017083
+71 ^ 11 = 231122292121701565271
+73 ^ 11 = 313726685568359708377
+79 ^ 10 = 9468276082626847201
+83 ^ 10 = 15516041187205853449
+89 ^ 10 = 31181719929966183601
+97 ^ 10 = 73742412689492826049
+
+ v = 3
+ -2 ^ v = -8
+ -1 ^ v = -1
+ 0 ^ v = 0
+ 1 ^ v = 1
+ 2 ^ v = 8
+-1.5 ^ v = -3.375
+-1.0 ^ v = -1.0
+-0.5 ^ v = -0.125
+ 0.0 ^ v = 0.0
+ 0.5 ^ v = 0.125
+ 1.0 ^ v = 1.0
+ 1.5 ^ v = 3.375
+ v = 6
+ -2 ^ v = 64
+ -1 ^ v = 1
+ 0 ^ v = 0
+ 1 ^ v = 1
+ 2 ^ v = 64
+-1.5 ^ v = 11.390625
+-1.0 ^ v = 1.0
+-0.5 ^ v = 0.015625
+ 0.0 ^ v = 0.0
+ 0.5 ^ v = 0.015625
+ 1.0 ^ v = 1.0
+ 1.5 ^ v = 11.390625
+ v = -7
+ -2 ^ v = 0
+ -1 ^ v = -1
+ 0 ^ v = error 204
+ 1 ^ v = 1
+ 2 ^ v = 0
+-1.5 ^ v = -0.05852766347
+-1.0 ^ v = -1.0
+-0.5 ^ v = -128.0
+ 0.0 ^ v = error 204
+ 0.5 ^ v = 128.0
+ 1.0 ^ v = 1.0
+ 1.5 ^ v = 0.05852766347
+
+2 ^ 84 = 19342813113834066795298816
+3 ^ 53 = 19383245667680019896796723
+5 ^ 36 = 14551915228366851806640625
+7 ^ 30 = 22539340290692258087863249
+10 ^ 25 = 10000000000000000000000000
+17 ^ 21 = 69091933913008732880827217
+51 ^ 15 = 41072642160770556400888251
+-3 ^ 54 = 58149737003040059690390169
+-11 ^ 26 = 1191817653772720942460132761
+-43 ^ 16 = 136614025729312093462315201
+
+9 ^ 27 = 58149737003040059690390169
+27 ^ 18 = 58149737003040059690390169
+81 ^ 14 = 523347633027360537213511521
+243 ^ 11 = 174449211009120179071170507
+729 ^ 9 = 58149737003040059690390169
+2187 ^ 8 = 523347633027360537213511521
+6561 ^ 7 = 523347633027360537213511521
+19683 ^ 6 = 58149737003040059690390169
+59049 ^ 6 = 42391158275216203514294433201
+177147 ^ 5 = 174449211009120179071170507
+531441 ^ 5 = 42391158275216203514294433201
+1594323 ^ 5 = 10301051460877537453973547267843
+4782969 ^ 4 = 523347633027360537213511521
+14348907 ^ 4 = 42391158275216203514294433201
+43046721 ^ 4 = 3433683820292512484657849089281
+129140163 ^ 4 = 278128389443693511257285776231761
+387420489 ^ 3 = 58149737003040059690390169
+1162261467 ^ 3 = 1570042899082081611640534563
+3486784401 ^ 3 = 42391158275216203514294433201
+10460353203 ^ 3 = 1144561273430837494885949696427
+31381059609 ^ 3 = 30903154382632612361920641803529
+94143178827 ^ 3 = 834385168331080533771857328695283
+282429536481 ^ 3 = 22528399544939174411840147874772641
+847288609443 ^ 3 = 608266787713357709119683992618861307
+2541865828329 ^ 3 = 16423203268260658146231467800709255289
+7625597484987 ^ 2 = 58149737003040059690390169
+22876792454961 ^ 2 = 523347633027360537213511521
+68630377364883 ^ 2 = 4710128697246244834921603689
+205891132094649 ^ 2 = 42391158275216203514294433201
+617673396283947 ^ 2 = 381520424476945831628649898809
+1853020188851841 ^ 2 = 3433683820292512484657849089281
+5559060566555523 ^ 2 = 30903154382632612361920641803529
+16677181699666569 ^ 2 = 278128389443693511257285776231761
+50031545098999707 ^ 2 = 2503155504993241601315571986085849
+150094635296999121 ^ 2 = 22528399544939174411840147874772641
+450283905890997363 ^ 2 = 202755595904452569706561330872953769
+1350851717672992089 ^ 2 = 1824800363140073127359051977856583921
+4052555153018976267 ^ 2 = 16423203268260658146231467800709255289
+12157665459056928801 ^ 2 = 147808829414345923316083210206383297601
+36472996377170786403 ^ 2 = 1330279464729113309844748891857449678409
+109418989131512359209 ^ 2 = 11972515182562019788602740026717047105681
+328256967394537077627 ^ 2 = 107752636643058178097424660240453423951129
+984770902183611232881 ^ 2 = 969773729787523602876821942164080815560161
+2954312706550833698643 ^ 2 = 8727963568087712425891397479476727340041449
+8862938119652501095929 ^ 2 = 78551672112789411833022577315290546060373041
+26588814358957503287787 ^ 2 = 706965049015104706497203195837614914543357369
+79766443076872509863361 ^ 2 = 6362685441135942358474828762538534230890216321
+239299329230617529590083 ^ 2 = 57264168970223481226273458862846808078011946889
+717897987691852588770249 ^ 2 = 515377520732011331036461129765621272702107522001
+
+conv ok: 787
+conv ok: 619369
+conv ok: 487443403
+conv ok: 383617958161
+conv ok: 301907333072707
+conv ok: 237601071128220409
+conv ok: 186992042977909461883
+conv ok: 147162737823614746501921
+conv ok: 115817074667184805497011827
+conv ok: 91148037763074441926148307849
+conv ok: 71733505719539585795878718277163
+conv ok: 56454269001277654021356551284127281
+conv ok: 44429509704005513714807605860608170147
+conv ok: 34966024137052339293553585812298629905689
+conv ok: 27518260995860191024026672034279021735777243
+conv ok: 21656871403741970335908990890977590106056690241
+conv ok: 17043957794744930654360375831199363413466615219667
+conv ok: 13413594784464260424981615779153899006398226177877929
+conv ok: 10556499095373372954460531618194118518035404001989930123
+conv ok: 8307964788058844515160438383518771273693862949566075006801
+conv ok: 6538368288202310633431265007829272992397070141308501030352387
+conv ok: 5145695842815218468510405561161637845016494201209790310887328569
+conv ok: 4049662628295576934717689176634208984027980936352104974668327583803
+conv ok: 3187084488468619047622821382011122470430020996909106615063973808452961
+conv ok: -5781
+conv ok: 33419961
+conv ok: -193200794541
+conv ok: 1116893793241521
+conv ok: -6456763018729232901
+conv ok: 37326547011273695400681
+conv ok: -215784768272173233111336861
+conv ok: 1247451745381433460616638393441
+conv ok: -7211518540050066835824786552482421
+conv ok: 41689788680029436377903091059900875801
+conv ok: -241008668359250171700657769417286963005581
+conv ok: 1393271111784825242601502565001335933135263761
+conv ok: -8054500297228074727479286328272723029454959802341
+conv ok: 46563066218275499999557754263744611833279122617333321
+conv ok: -269181085807850665497443377398707601008186607850803928701
+conv ok: 1556135857055184697240720164741928641428326779985497511820481
+conv ok: -8996021389636022734748603272373089476097157115096161115834200661
+conv ok: 52005999653485847429581675517588830261317665282370907410637514021241
+
+2R1111111111111111111111111111111111111111111111111111111111111111 = 18446744073709551615
+3R2222222222222222222222222222222222222222 = 12157665459056928800
+4R33333333333333333333333333333333 = 18446744073709551615
+5R4444444444444444444444444444 = 37252902984619140624
+6R5555555555555555555555555 = 28430288029929701375
+7R66666666666666666666666 = 27368747340080916342
+8R7777777777777777777777 = 73786976294838206463
+9R88888888888888888888 = 12157665459056928800
+10R9999999999999999999 = 9999999999999999999
+11Raaaaaaaaaaaaaaaaaaa = 61159090448414546290
+12Rbbbbbbbbbbbbbbbbbb = 26623333280885243903
+13Rcccccccccccccccccc = 112455406951957393128
+14Rddddddddddddddddd = 30491346729331195903
+15Reeeeeeeeeeeeeeeee = 98526125335693359374
+16Rffffffffffffffff = 18446744073709551615
+17Rgggggggggggggggg = 48661191875666868480
+18Rhhhhhhhhhhhhhhhh = 121439531096594251775
+19Riiiiiiiiiiiiiii = 15181127029874798298
+20Rjjjjjjjjjjjjjjj = 32767999999999999999
+21Rkkkkkkkkkkkkkkk = 68122318582951682300
+22Rlllllllllllllll = 136880068015412051967
+23Rmmmmmmmmmmmmmm = 11592836324538749808
+24Rnnnnnnnnnnnnnn = 21035720123168587775
+25Roooooooooooooo = 37252902984619140624
+26Rpppppppppppppp = 64509974703297150975
+27Rqqqqqqqqqqqqqq = 109418989131512359208
+28Rrrrrrrrrrrrrrr = 182059119829942534143
+29Rsssssssssssss = 10260628712958602188
+30Rttttttttttttt = 15943229999999999999
+31Ruuuuuuuuuuuuu = 24417546297445042590
+32Rvvvvvvvvvvvvv = 36893488147419103231
+33Rwwwwwwwwwwwww = 55040353993448503712
+34Rxxxxxxxxxxxxx = 81138303245565435903
+35Ryyyyyyyyyyyyy = 118272717781982421874
+36rZZZZZZZZZZ = 3656158440062975
+36rZZZZZZZZZZZ = 131621703842267135
+36rZZZZZZZZZZZZ = 4738381338321616895
+36rZZZZZZZZZZZZZ = 170581728179578208255
+36rZZZZZZZZZZZZZZ = 6140942214464815497215
+36rZZZZZZZZZZZZZZZ = 221073919720733357899775
+36rZZZZZZZZZZZZZZZZ = 7958661109946400884391935
+36rZZZZZZZZZZZZZZZZZ = 286511799958070431838109695
+36rZZZZZZZZZZZZZZZZZZ = 10314424798490535546171949055
+36rZZZZZZZZZZZZZZZZZZZ = 371319292745659279662190166015
+36rZZZZZZZZZZZZZZZZZZZZ = 13367494538843734067838845976575
+
+110000
+1073851824
+2147703648
+1000000000
+2073741824
+4300405152606846976
+-110000
+-1073851824
+-2147593648
+
+u: 37 -37 -38 ~= > >=
+u: 5.0 -5.0 -6
+u: 9223372036854775808 -9223372036854775808 -9223372036854775809 ~= > >=
+u: 61159090448414546291 -61159090448414546291 -61159090448414546292 ~= > >=
+u: 37252902984619140625 -37252902984619140625 -37252902984619140626 ~= > >=
+u: 73 -73 -74 ~= > >=
+u: 9.0 -9.0 -10
+u: -27368747340080916343 27368747340080916343 27368747340080916342 < <= ~=
+u: -12157665459056928801 12157665459056928801 12157665459056928800 < <= ~=
+u: 48661191875666868481 -48661191875666868481 -48661191875666868482 ~= > >=
+
+b: 37 73 < <= ~=
+ +- 110 -36
+ */% 2701 0 37
+ &|! 1 109 108
+b: 37 9.0 ~= > >=
+ +- 46.0 28.0
+ */% 333.0 4.111111111 1.0
+ &|! 1 45 44
+b: 37 -27368747340080916343 ~= > >=
+ +- -27368747340080916306 27368747340080916380
+ */% -1012643651582993904691 0 37
+ &|! 1 -27368747340080916307 -27368747340080916308
+b: 37 -12157665459056928801 ~= > >=
+ +- -12157665459056928764 12157665459056928838
+ */% -449833621985106365637 0 37
+ &|! 5 -12157665459056928769 -12157665459056928774
+b: 37 48661191875666868481 < <= ~=
+ +- 48661191875666868518 -48661191875666868444
+ */% 1800464099399674133797 0 37
+ &|! 1 48661191875666868517 48661191875666868516
+b: 5.0 73
+ +- 78.0 -68.0
+ */% 365.0 0.06849315068 5.0
+ &|! 1 77 76
+b: 5.0 9.0 < <= ~=
+ +- 14.0 -4.0
+ */% 45.0 0.5555555556 5.0
+ &|! 1 13 12
+b: 5.0 -27368747340080916343
+ +- -2.736874734e+19 2.736874734e+19
+ */% -1.368437367e+20 -1.826901297e-19 5.0
+ &|! 1 -27368747340080916339 -27368747340080916340
+b: 5.0 -12157665459056928801
+ +- -1.215766546e+19 1.215766546e+19
+ */% -6.07883273e+19 -4.11263167e-19 5.0
+ &|! 5 -12157665459056928801 -12157665459056928806
+b: 5.0 48661191875666868481
+ +- 4.866119188e+19 -4.866119188e+19
+ */% 2.433059594e+20 1.027512851e-19 5.0
+ &|! 1 48661191875666868485 48661191875666868484
+b: 9223372036854775808 73 ~= > >=
+ +- 9223372036854775881 9223372036854775735
+ */% 673306158690398633984 126347562148695559 1
+ &|! 0 9223372036854775881 9223372036854775881
+b: 9223372036854775808 9.0 ~= > >=
+ +- 9.223372037e+18 9.223372037e+18
+ */% 8.301034833e+19 1.024819115e+18 8.0
+ &|! 0 9223372036854775817 9223372036854775817
+b: 9223372036854775808 -27368747340080916343 ~= > >=
+ +- -18145375303226140535 36592119376935692151
+ */% -252432138900245848896847100400468230144 0 9223372036854775808
+ &|! 9223372036854775808 -27368747340080916343 -36592119376935692151
+b: 9223372036854775808 -12157665459056928801 ~= > >=
+ +- -2934293422202152993 21381037495911704609
+ */% -112134671628500858351345486069873246208 0 9223372036854775808
+ &|! 0 -2934293422202152993 -2934293422202152993
+b: 9223372036854775808 48661191875666868481 < <= ~=
+ +- 57884563912521644289 -39437819838812092673
+ */% 448820276426050593203111380360676507648 0 9223372036854775808
+ &|! 9223372036854775808 48661191875666868481 39437819838812092673
+b: 61159090448414546291 73 ~= > >=
+ +- 61159090448414546364 61159090448414546218
+ */% 4464613602734261879243 837795759567322551 68
+ &|! 65 61159090448414546299 61159090448414546234
+b: 61159090448414546291 9.0 ~= > >=
+ +- 6.115909045e+19 6.115909045e+19
+ */% 5.50431814e+20 6.795454494e+18 5.0
+ &|! 1 61159090448414546299 61159090448414546298
+b: 61159090448414546291 -27368747340080916343 ~= > >=
+ +- 33790343108333629948 88527837788495462634
+ */% -1673847694031813790959405051173871933813 -2 6421595768252713605
+ &|! 36893677298903685121 -3103334190570055173 -39997011489473740294
+b: 61159090448414546291 -12157665459056928801 ~= > >=
+ +- 49001424989357617490 73316755907471475092
+ */% -743551761452028064444726055040305627091 -5 370763153129902286
+ &|! 61122863661437686099 -12121438672080068609 -73244302333517754708
+b: 61159090448414546291 48661191875666868481 ~= > >=
+ +- 109820282324081414772 12497898572747677810
+ */% 2976074235251565096354096402968383353971 1 12497898572747677810
+ &|! 36911511549794588929 72908770774286825843 35997259224492236914
+b: 37252902984619140625 73 ~= > >=
+ +- 37252902984619140698 37252902984619140552
+ */% 2719461917877197265625 510313739515330693 36
+ &|! 1 37252902984619140697 37252902984619140696
+b: 37252902984619140625 9.0 ~= > >=
+ +- 3.725290298e+19 3.725290298e+19
+ */% 3.352761269e+20 4.139211443e+18 8.0
+ &|! 1 37252902984619140633 37252902984619140632
+b: 37252902984619140625 -27368747340080916343 ~= > >=
+ +- 9884155644538224282 64621650324700056968
+ */% -1019565289470587534569203853607177734375 -1 9884155644538224282
+ &|! 37194285120097353729 -27310129475559129447 -64504414595656483176
+b: 37252902984619140625 -12157665459056928801 ~= > >=
+ +- 25095237525562211824 49410568443676069426
+ */% -452908331865702897347509860992431640625 -3 779906607448354222
+ &|! 37200930984991655441 -12105693459429443617 -49306624444421099058
+b: 37252902984619140625 48661191875666868481 < <= ~=
+ +- 85914094860286009106 -11408288891047727856
+ */% 1812770660060154962576925754547119140625 0 37252902984619140625
+ &|! 36914950757738881025 48999144102547128081 12084193344808247056
diff --git a/tests/general/lists.icn b/tests/general/lists.icn
new file mode 100644
index 0000000..d3c64ed
--- /dev/null
+++ b/tests/general/lists.icn
@@ -0,0 +1,89 @@
+#SRC: JCON
+
+procedure main()
+ local i, x, y, z
+
+ write(args(push))
+ write(args(put))
+
+ limage("a", list())
+ limage("b", list(2))
+ limage("c", list(,3))
+ limage("d", list(4,5))
+ limage("d", list(6,7,8))
+ limage("e", [])
+ limage("f", [&null])
+ limage("g", [1])
+ limage("h", [2,3,4,5])
+ limage("i", [1,2,3] ||| [4,5,6,7,8])
+
+ x := [1,2,3]
+ push(x); limage("A", x)
+ put(x); limage("B", x)
+ write("\t", image(pop(x))); limage("C", x)
+ write("\t", image(get(x))); limage("D", x)
+ write("\t", image(pull(x))); limage("E", x)
+ push(x,4); limage("F", x)
+ push(x,5,6,7); limage("G", x)
+ push(push(x,8,9),10,11); limage("H", x)
+ put(x,12); limage("I", x)
+ put(x,13,14,15); limage("J", x)
+ put(put(x,16,17),18,19); limage("K", x)
+ put(push(x,20,21),22,23); limage("L", x)
+ every !x := 7; limage("M", x)
+
+ x := [1,2,3,4,5]
+
+ every i := 0 to *x+3 do
+ x[i] := i;
+ limage("N", x)
+
+ every i := -*x-3 to 0 do
+ x[i] := i;
+ limage("O", x)
+
+ x := [1]
+ write("\t", ?x)
+ ?x := 2
+ limage("P", x)
+ write(x[0] | "ok failure 0")
+ write(x[2] | "ok failure 2")
+ write(x[-2] | "ok failure -2")
+ get(x)
+ write(get(x) | "ok failure on get")
+ write(pop(x) | "ok failure on pop")
+ write(pull(x) | "ok failure on pull")
+
+ x := [1,2,3,4,5,6,7,8,9]
+ limage("p", x)
+ limage("q", x[1:0])
+ limage("r", x[2:5])
+ limage("s", x[-3:5])
+ limage("t", x[-5:-1])
+ limage("u", x[-3+:6]) | write("u. wraparound failed") # should fail (v9 bug)
+ limage("v", x[3-:6]) | write("v. wraparound failed") # should fail (v9 bug)
+
+ write()
+ y := copy(x) # ensure that copies are distinct
+ every !x +:= 10
+ every !y +:= 20
+ limage("x", x)
+ limage("y", y)
+
+ z := x ||| y
+ limage("z", z)
+ every !x +:= 10
+ every !y +:= 20
+ every !z +:= 50
+ limage("x", x)
+ limage("y", y)
+ limage("z", z)
+
+end
+
+procedure limage(label, lst)
+ writes(label, ". [", *lst, "]")
+ every writes(" ", image(!lst))
+ write()
+ return
+end
diff --git a/tests/general/lists.std b/tests/general/lists.std
new file mode 100644
index 0000000..8c3ab88
--- /dev/null
+++ b/tests/general/lists.std
@@ -0,0 +1,52 @@
+-2
+-2
+a. [0]
+b. [2] &null &null
+c. [0]
+d. [4] 5 5 5 5
+d. [6] 7 7 7 7 7 7
+e. [0]
+f. [1] &null
+g. [1] 1
+h. [4] 2 3 4 5
+i. [8] 1 2 3 4 5 6 7 8
+A. [4] &null 1 2 3
+B. [5] &null 1 2 3 &null
+ &null
+C. [4] 1 2 3 &null
+ 1
+D. [3] 2 3 &null
+ &null
+E. [2] 2 3
+F. [3] 4 2 3
+G. [6] 7 6 5 4 2 3
+H. [10] 11 10 9 8 7 6 5 4 2 3
+I. [11] 11 10 9 8 7 6 5 4 2 3 12
+J. [14] 11 10 9 8 7 6 5 4 2 3 12 13 14 15
+K. [18] 11 10 9 8 7 6 5 4 2 3 12 13 14 15 16 17 18 19
+L. [22] 21 20 11 10 9 8 7 6 5 4 2 3 12 13 14 15 16 17 18 19 22 23
+M. [22] 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
+N. [5] 1 2 3 4 5
+O. [5] -5 -4 -3 -2 -1
+ 1
+P. [1] 2
+ok failure 0
+ok failure 2
+ok failure -2
+ok failure on get
+ok failure on pop
+ok failure on pull
+p. [9] 1 2 3 4 5 6 7 8 9
+q. [9] 1 2 3 4 5 6 7 8 9
+r. [3] 2 3 4
+s. [2] 5 6
+t. [4] 5 6 7 8
+u. [4] 3 4 5 6
+v. [4] 3 4 5 6
+
+x. [9] 11 12 13 14 15 16 17 18 19
+y. [9] 21 22 23 24 25 26 27 28 29
+z. [18] 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 29
+x. [9] 21 22 23 24 25 26 27 28 29
+y. [9] 41 42 43 44 45 46 47 48 49
+z. [18] 61 62 63 64 65 66 67 68 69 71 72 73 74 75 76 77 78 79
diff --git a/tests/general/map.icn b/tests/general/map.icn
new file mode 100644
index 0000000..73bb760
--- /dev/null
+++ b/tests/general/map.icn
@@ -0,0 +1,14 @@
+#SRC: JCON
+
+procedure main()
+ write(map("aBcDeF"))
+ write(map("AbCdEf"))
+ write(map("aBcDeF", "abcdefghijklmnopqrstuvwxyz"))
+ write(map("AbCdEf", "abcdefghijklmnopqrstuvwxyz"))
+ write(map("aBcDeF", , "12345678901234567890123456"))
+ write(map("AbCdEf", , "12345678901234567890123456"))
+ write(map("aBcDeF", "abcdef", "!@#$%^"))
+ write(map("AbCdEf", "abcdef", "!@#$%^"))
+ write(map("", "abcdef", "!@#$%^"))
+ write(map("abcdef", "aa", "bc"))
+end
diff --git a/tests/general/map.std b/tests/general/map.std
new file mode 100644
index 0000000..16ca87f
--- /dev/null
+++ b/tests/general/map.std
@@ -0,0 +1,10 @@
+abcdef
+abcdef
+aBcDeF
+AbCdEf
+a2c4e6
+1b3d5f
+!B#D%F
+A@C$E^
+
+cbcdef
diff --git a/tests/general/mathfunc.icn b/tests/general/mathfunc.icn
new file mode 100644
index 0000000..380d828
--- /dev/null
+++ b/tests/general/mathfunc.icn
@@ -0,0 +1,36 @@
+#SRC: JCON
+
+# test math functions including argument coercion
+
+procedure main()
+ every try(sqrt, 0.0 | 0.25 | 1 | 2.25 | "4" | 256.0)
+ every try(log, 0.1 | 0.25 | 1.0 | &e | "10" | 100 | 1000)
+ every try(log, 0.1 | 0.25 | 1.0 | &e | "10" | 100 | 1000, 10)
+ every try(exp, -3 | -1 | 0 | 1.0 | "2" | '3')
+ write()
+ every try(dtor, -1000 | -360 | -90 | '0' | "45" | 360 | 1000)
+ every try(rtod, -3 * &pi | -2 * &pi | -&pi | '0' | &pi / 3 | &pi / 2 |
+ "3.1415936535" | 2 * &pi)
+ every try(sin | cos | tan, -&pi / 3 | '0' | "3.1415926535")
+ every try(asin | acos, '-1' | -0.5 | "0" | 0.5 | 1.0)
+ every try(atan, "-1000" | -47 | -1 | -.5 | '0' | .5 | 1 | 47 | 1000)
+ every try(atan, -1 | '0' | "1", '-1' | "0" | 1)
+end
+
+
+# try(p, a, b) -- print call to p(a,b) and its results
+
+procedure try(p, a, b)
+ write(image(p,15), "(", r(a), (", "||r(\b)) | &null, ") = ", r(p(a,b)))
+ return
+end
+
+
+# r(v) -- round v to have only 3 digits after the decimal point
+
+procedure r(v)
+ if v >= 0 then
+ return integer(v * 1000 + 0.5) / 1000.0
+ else
+ return integer(v * 1000 - 0.5) / 1000.0
+end
diff --git a/tests/general/mathfunc.std b/tests/general/mathfunc.std
new file mode 100644
index 0000000..7bac40a
--- /dev/null
+++ b/tests/general/mathfunc.std
@@ -0,0 +1,79 @@
+function sqrt(0.0) = 0.0
+function sqrt(0.25) = 0.5
+function sqrt(1.0) = 1.0
+function sqrt(2.25) = 1.5
+function sqrt(4.0) = 2.0
+function sqrt(256.0) = 16.0
+function log(0.1) = -2.303
+function log(0.25) = -1.386
+function log(1.0) = 0.0
+function log(2.718) = 1.0
+function log(10.0) = 2.303
+function log(100.0) = 4.605
+function log(1000.0) = 6.908
+function log(0.1, 10.0) = -1.0
+function log(0.25, 10.0) = -0.602
+function log(1.0, 10.0) = 0.0
+function log(2.718, 10.0) = 0.434
+function log(10.0, 10.0) = 1.0
+function log(100.0, 10.0) = 2.0
+function log(1000.0, 10.0) = 3.0
+function exp(-3.0) = 0.05
+function exp(-1.0) = 0.368
+function exp(0.0) = 1.0
+function exp(1.0) = 2.718
+function exp(2.0) = 7.389
+function exp(3.0) = 20.086
+
+function dtor(-1000.0) = -17.453
+function dtor(-360.0) = -6.283
+function dtor(-90.0) = -1.571
+function dtor(0.0) = 0.0
+function dtor(45.0) = 0.785
+function dtor(360.0) = 6.283
+function dtor(1000.0) = 17.453
+function rtod(-9.425) = -540.0
+function rtod(-6.283) = -360.0
+function rtod(-3.142) = -180.0
+function rtod(0.0) = 0.0
+function rtod(1.047) = 60.0
+function rtod(1.571) = 90.0
+function rtod(3.142) = 180.0
+function rtod(6.283) = 360.0
+function sin(-1.047) = -0.866
+function sin(0.0) = 0.0
+function sin(3.142) = 0.0
+function cos(-1.047) = 0.5
+function cos(0.0) = 1.0
+function cos(3.142) = -1.0
+function tan(-1.047) = -1.732
+function tan(0.0) = 0.0
+function tan(3.142) = 0.0
+function asin(-1.0) = -1.571
+function asin(-0.5) = -0.524
+function asin(0.0) = 0.0
+function asin(0.5) = 0.524
+function asin(1.0) = 1.571
+function acos(-1.0) = 3.142
+function acos(-0.5) = 2.094
+function acos(0.0) = 1.571
+function acos(0.5) = 1.047
+function acos(1.0) = 0.0
+function atan(-1000.0) = -1.57
+function atan(-47.0) = -1.55
+function atan(-1.0) = -0.785
+function atan(-0.5) = -0.464
+function atan(0.0) = 0.0
+function atan(0.5) = 0.464
+function atan(1.0) = 0.785
+function atan(47.0) = 1.55
+function atan(1000.0) = 1.57
+function atan(-1.0, -1.0) = -2.356
+function atan(-1.0, 0.0) = -1.571
+function atan(-1.0, 1.0) = -0.785
+function atan(0.0, -1.0) = 3.142
+function atan(0.0, 0.0) = 0.0
+function atan(0.0, 1.0) = 0.0
+function atan(1.0, -1.0) = 2.356
+function atan(1.0, 0.0) = 1.571
+function atan(1.0, 1.0) = 0.785
diff --git a/tests/general/meander.dat b/tests/general/meander.dat
new file mode 100644
index 0000000..e7ee16e
--- /dev/null
+++ b/tests/general/meander.dat
@@ -0,0 +1,3 @@
+abc:2
+1234:2
+ABC:4
diff --git a/tests/general/meander.icn b/tests/general/meander.icn
new file mode 100644
index 0000000..e1d2df7
--- /dev/null
+++ b/tests/general/meander.icn
@@ -0,0 +1,33 @@
+#
+# M E A N D E R I N G S T R I N G S
+#
+
+# This main procedure accepts specifications for meandering strings
+# from standard input with the alphabet separated from the length by
+# a colon.
+
+procedure main()
+ local line, alpha, n
+ while line := read() do $(
+ line ? if $(
+ alpha := tab(upto(':')) &
+ move(1) &
+ n := integer(tab(0))
+ $)
+ then write(meander(alpha,n))
+ else stop("*** erroneous input ***")
+ $)
+end
+
+procedure meander(alpha,n)
+ local result, t, i, c, k
+ i := k := *alpha
+ t := n-1
+ result := repl(alpha$<1$>,t)
+ while c := alpha$<i$> do $(
+ if find(result$<-t:0$> || c,result)
+ then i -:= 1
+ else $(result ||:= c; i := k$)
+ $)
+ return result
+end
diff --git a/tests/general/meander.std b/tests/general/meander.std
new file mode 100644
index 0000000..635ff2c
--- /dev/null
+++ b/tests/general/meander.std
@@ -0,0 +1,3 @@
+accbcabbaa
+14434241332312211
+AAACCCCBCCCACCBBCCBACCABCCAACBCBCACBBBCBBACBABCBAACACABBCABACAABCAAABBBBABBAABABAAAA
diff --git a/tests/general/mffsol.dat b/tests/general/mffsol.dat
new file mode 100644
index 0000000..7284b3e
--- /dev/null
+++ b/tests/general/mffsol.dat
@@ -0,0 +1,6 @@
+[ constructed by hand ]
+ABCD EFGH IJKL MNOP
+AEIM BFJN CGKO DHLP
+AHKN BGLM CFIP DEJO
+AFLO BEKP CHJM DGIN
+AGJP BHIO CELN DFKM
diff --git a/tests/general/mffsol.icn b/tests/general/mffsol.icn
new file mode 100644
index 0000000..e7f5c93
--- /dev/null
+++ b/tests/general/mffsol.icn
@@ -0,0 +1,114 @@
+## mffsol.icn -- show solution graphically in mff format
+#
+# input is assumed to be one line per round
+# each player is represented by a different ASCII character
+# matches are broken by whitespace
+
+global range # vertical coordinate range
+global red, green, blue # current color
+
+procedure main (args)
+ range := 1000
+ aset := cset(&ascii ? (tab(upto(' ')) & move(1) & move(94)))
+ pset := '' # set of chars in use as players
+ plist := "" # same, in order of appearance
+ rounds := [] # list of rounds (one text line each)
+ nmatches := 0
+
+ if *args > 0 then
+ f := open(args[1]) | stop("can't open ",args[1])
+ else
+ f := &input
+
+ # read input and save in memory
+ # (this first pass just accumulates a list of players)
+ while line := read(f) do
+ if line[1] ~== "[" & upto(aset,line) then {
+ put(rounds,line)
+ line ? while tab(upto(aset)) do {
+ c := move(1)
+ if not any(pset,c) then { # if first appearance of new player
+ pset ++:= c # add to set of players
+ plist ||:= c # add at end of list
+ }
+ }
+ }
+
+ # if all the characters are letters, arrange alphabetically
+ if *(plist -- &ucase -- &lcase) = 0 then
+ plist := string(cset(plist))
+
+ # calculate a position (angle) for each player, and draw the clock face
+ write("1 metafile ", pct(125), " ", pct(100), " 0 0 0 init")
+ angle := table()
+ dtheta := 2 * 3.14159 / *pset
+ theta := 3.14159 / 2 - dtheta / 2
+ every c := !plist do {
+ angle[c] := theta
+ cart(47, theta, -1, -1)
+ write("(",c,") text")
+ theta -:= dtheta
+ }
+
+ # draw each round in a different color
+ n := 1
+ red := 250
+ green := 255
+ blue := 0
+ every r := !rounds do {
+ write(red, " ", green, " ", blue, " color")
+ x := pct(110)
+ y := pct(100 - 4 * n)
+ if y > 0 then
+ write(x, " ", y, " (", n, ") text")
+ r ? while tab(upto(aset)) do {
+ match := tab(many(aset))
+ cart (45, angle[match[1]], 0, 0); writes ("begin ")
+ cart (45, angle[match[2]], 0, 0); writes ("line ")
+ cart (45, angle[match[3]], 0, 0); writes ("line ")
+ cart (45, angle[match[4]], 0, 0); writes ("line ")
+ cart (45, angle[match[1]], 0, 0); write ("line")
+ cart (45, angle[match[3]], 0, 0); writes ("line stroke ")
+ cart (45, angle[match[2]], 0, 0); writes ("begin ")
+ cart (45, angle[match[4]], 0, 0); write ("line stroke")
+ nmatches +:= 1
+ }
+ n +:= 1
+ newcolor()
+ }
+
+ # write some final statistics
+ write ("255 255 255 color")
+ write ("0 0 (",
+ *pset," players, ",*rounds," rounds, ",nmatches," matches) text")
+ end
+
+
+# given polar coordinates (radius,angle,dx,dy), write cartesian equivalents
+# offset by (dx,dy)
+
+procedure cart (r,a,dx,dy)
+ x := pct (50 + r * cos(a) + dy)
+ y := pct (50 + r * sin(a) + dy)
+ writes (x," ",y," ")
+ end
+
+
+# return a string representing a given percentage of the coordinate range
+
+procedure pct (n)
+ return string(integer(n * range / 100))
+ end
+
+
+# set new color coordinates. iterate until acceptable.
+
+procedure newcolor()
+ repeat {
+ red := (red + 103) % 256
+ green := (green + 211) % 256
+ blue := (blue + 71) % 256
+ lum := 0.30 * red + 0.59 * green + 0.11 * blue
+ if lum > 96 then return
+ }
+ end
diff --git a/tests/general/mffsol.std b/tests/general/mffsol.std
new file mode 100644
index 0000000..86a5b97
--- /dev/null
+++ b/tests/general/mffsol.std
@@ -0,0 +1,69 @@
+1 metafile 1250 1000 0 0 0 init
+581 950 (A) text
+751 880 (B) text
+880 751 (C) text
+950 581 (D) text
+950 398 (E) text
+880 228 (F) text
+751 99 (G) text
+581 29 (H) text
+398 29 (I) text
+228 99 (J) text
+99 228 (K) text
+29 398 (L) text
+29 581 (M) text
+99 751 (N) text
+228 880 (O) text
+398 950 (P) text
+250 255 0 color
+1100 960 (1) text
+587 941 begin 750 874 line 874 750 line 941 587 line 587 941 line
+874 750 line stroke 750 874 begin 941 587 line stroke
+941 412 begin 874 249 line 750 125 line 587 58 line 941 412 line
+750 125 line stroke 874 249 begin 587 58 line stroke
+412 58 begin 249 125 line 125 249 line 58 412 line 412 58 line
+125 249 line stroke 249 125 begin 58 412 line stroke
+58 587 begin 125 750 line 249 874 line 412 941 line 58 587 line
+249 874 line stroke 125 750 begin 412 941 line stroke
+97 210 71 color
+1100 920 (2) text
+587 941 begin 941 412 line 412 58 line 58 587 line 587 941 line
+412 58 line stroke 941 412 begin 58 587 line stroke
+750 874 begin 874 249 line 249 125 line 125 750 line 750 874 line
+249 125 line stroke 874 249 begin 125 750 line stroke
+874 750 begin 750 125 line 125 249 line 249 874 line 874 750 line
+125 249 line stroke 750 125 begin 249 874 line stroke
+941 587 begin 587 58 line 58 412 line 412 941 line 941 587 line
+58 412 line stroke 587 58 begin 412 941 line stroke
+200 165 142 color
+1100 880 (3) text
+587 941 begin 587 58 line 125 249 line 125 750 line 587 941 line
+125 249 line stroke 587 58 begin 125 750 line stroke
+750 874 begin 750 125 line 58 412 line 58 587 line 750 874 line
+58 412 line stroke 750 125 begin 58 587 line stroke
+874 750 begin 874 249 line 412 58 line 412 941 line 874 750 line
+412 58 line stroke 874 249 begin 412 941 line stroke
+941 587 begin 941 412 line 249 125 line 249 874 line 941 587 line
+249 125 line stroke 941 412 begin 249 874 line stroke
+47 120 213 color
+1100 840 (4) text
+587 941 begin 874 249 line 58 412 line 249 874 line 587 941 line
+58 412 line stroke 874 249 begin 249 874 line stroke
+750 874 begin 941 412 line 125 249 line 412 941 line 750 874 line
+125 249 line stroke 941 412 begin 412 941 line stroke
+874 750 begin 587 58 line 249 125 line 58 587 line 874 750 line
+249 125 line stroke 587 58 begin 58 587 line stroke
+941 587 begin 750 125 line 412 58 line 125 750 line 941 587 line
+412 58 line stroke 750 125 begin 125 750 line stroke
+253 30 99 color
+1100 800 (5) text
+587 941 begin 750 125 line 249 125 line 412 941 line 587 941 line
+249 125 line stroke 750 125 begin 412 941 line stroke
+750 874 begin 587 58 line 412 58 line 249 874 line 750 874 line
+412 58 line stroke 587 58 begin 249 874 line stroke
+874 750 begin 941 412 line 58 412 line 125 750 line 874 750 line
+58 412 line stroke 941 412 begin 125 750 line stroke
+941 587 begin 874 249 line 125 249 line 58 587 line 941 587 line
+125 249 line stroke 874 249 begin 58 587 line stroke
+255 255 255 color
+0 0 (16 players, 5 rounds, 20 matches) text
diff --git a/tests/general/mindfa.dat b/tests/general/mindfa.dat
new file mode 100644
index 0000000..ac45fce
--- /dev/null
+++ b/tests/general/mindfa.dat
@@ -0,0 +1,20 @@
+abcdefgh
+01
+d
+a
+b
+a
+a
+c
+d
+b
+d
+a
+d
+f
+g
+e
+f
+g
+g
+d
diff --git a/tests/general/mindfa.icn b/tests/general/mindfa.icn
new file mode 100644
index 0000000..f4a0795
--- /dev/null
+++ b/tests/general/mindfa.icn
@@ -0,0 +1,214 @@
+### mindfa -- minimize a DFA
+
+record dfa(Q,S,d,q0,F) # a DFA
+
+procedure main()
+
+ x := getdfa()
+ every 1 to 10 do
+ showdfa("Reduced",minimize(showdfa("Original",x)))
+
+end
+
+## - getdfa() -- accept a dfa from input, return it
+##
+procedure getdfa()
+local Q,S,d,q0,F
+local q,a
+
+ Q := readset("Enter states (1 character names): ")
+ S := readset("Enter input alphabet: ")
+ F := readset("Enter Final states (subset of states): ")
+ writes("What is the start state? ")
+ q0 := read()
+ d := table()
+ every q := !Q & a := !S do {
+ writes("enter delta(",q,",",a,") = ")
+ d[q||":"||a] := read()
+ }
+ return dfa(Q,S,d,q0,F)
+
+end
+
+
+## readset(s) - get a set
+#
+procedure readset(s)
+local t1
+
+ writes(s)
+ t1 := []
+ every put(t1,!cset(read())) # the cset removes duplicates
+ return t1
+
+end
+
+## showdfa(msg,D) -- show a dfa
+#
+procedure showdfa(msg,D)
+local q,a
+
+ every 1 to 3 do write()
+ write(msg," Deterministic Finite Automaton is:")
+ write()
+ write("\t(Q,S,delta,q0,F)")
+ write()
+ write("where:")
+ write()
+ writeset("Q",D.Q)
+ writeset("S",D.S)
+ writeset("F",D.F)
+ write("\tStart state is ",D.q0)
+ write("\tDelta: ")
+ every q := !D.Q do {
+ every writes("\td(",q,",",a := !D.S,") = ",D.d[q||":"||a])
+ write()
+ }
+ return D
+
+end
+
+## writeset(msg,s) -- display a set
+#
+procedure writeset(msg,s)
+local tmp
+ tmp := ""
+ every tmp ||:= !s || ","
+ write("\t",msg," = {",tmp[1:-1],"}")
+ return
+end
+
+## minimize(D) -- minimize a dfa
+#
+global distab, dlists
+
+procedure minimize(D)
+local F,QF
+local p,q,a,cs
+
+ distab := table()
+ dlists := table()
+ F := D.F
+ QF := diff(D.Q,D.F)
+ every p := !F & q := !QF do
+ distab[cset(p||q)] := "X"
+ every ((p := !F & q := !F) |
+ (p := !QF & q := !QF)) & p ~== q do
+ if \distab[cset(D.d[p||":"||(a:=!D.S)]||D.d[q||":"||a])] then {
+ distab[cset(p||q)] := "X"
+ marklists(dlists[cset(p||q)])
+ }
+ else
+ every a := !D.S do
+ if D.d[p||":"||a] ~== D.d[q||":"||a] then {
+ cs := cset(D.d[p||":"||a]||D.d[q||":"||a])
+ if cs == cset(p||q) then next
+ /dlists[cs] := []
+ put(dlists[cs],cset(p||q))
+ }
+
+ return makemdfa(D,distab)
+
+end
+
+## marklists(l) -- recursively mark the pair of nodes
+# on list l.
+procedure marklists(l)
+local e
+
+ if /l then return
+ every e := !l do {
+ distab[e] := "X"
+ marklists(dlists[e])
+ }
+ return
+
+end
+
+## makemdfa(D,DT) -- Use the table from the minimization
+# to construct the minimal dfa
+procedure makemdfa(D,DT)
+local elist, etab, qset, tlist, echeck
+local p, q, Delta, q0
+
+ etab := table() # table of new states
+ qset := ''
+ every p := !D.Q do {
+ qset ++:= p
+ plike := equiv(p,etab) | cset(p)
+ every q := !diff(D.Q,qset) & p ~== q do
+ if /distab[cset(p||q)] then {
+ plike ++:= equiv(q,etab) | q
+ }
+ etab[plike] := plike
+ }
+ tlist := []
+ elist := []
+ Delta := table()
+ q0 := equiv(D.q0,etab) # start state of reduced machine
+ put(tlist,q0)
+ put(elist,q0) # only worry about states reachable
+ # from [q0]
+ echeck := table() # keep track of states
+ echeck[q0] := q0
+ while q := get(tlist) do
+ every a := !D.S do {
+ Delta[q||":"||a] := equivdelta(q,a,D,etab)
+ if /echeck[Delta[q||":"||a]] then {
+ echeck[Delta[q||":"||a]] := Delta[q||":"||a]
+ put(tlist,Delta[q||":"||a])
+ put(elist,Delta[q||":"||a])
+ }
+ }
+
+ return dfa(elist,D.S,Delta,q0,finalstates(D,elist))
+end
+
+## equiv(q,el) -- return the equivalence class in el containing q
+#
+procedure equiv(q,el)
+ every p := !el do
+ if p++q == p then return p
+end
+
+## equivdelta(p,a,D,el) -- apply delta to equiv. classes
+#
+procedure equivdelta(p,a,D,el)
+local q, r
+ q := !p # any state in equiv. class p
+ r := D.d[q||":"||a] # find state in original dfa
+
+ return equiv(r,el) # return its equivalence class
+end
+
+
+## finalstates(D,el) -- build the set of final states
+#
+procedure finalstates(D,el)
+local flist, p, q
+
+ ftab := table()
+ every p := !D.F do
+ ftab[q := equiv(p,el)] := q
+ flist := []
+ every put(flist,(!sort(ftab))[1])
+ return flist
+end
+
+
+## diff(l1,l2) -- return the difference of two sets
+#
+procedure diff(l1,l2)
+local l,t1,t2
+
+ t1 := ''
+ every t1 ++:= !l1
+
+ t2 := ''
+ every t2 ++:= !l2
+
+ l := []
+ every put(l,!(t1--t2))
+ if *l = 0 then fail
+ return l
+end
diff --git a/tests/general/mindfa.std b/tests/general/mindfa.std
new file mode 100644
index 0000000..ad1851c
--- /dev/null
+++ b/tests/general/mindfa.std
@@ -0,0 +1,400 @@
+Enter states (1 character names): Enter input alphabet: Enter Final states (subset of states): What is the start state? enter delta(a,0) = enter delta(a,1) = enter delta(b,0) = enter delta(b,1) = enter delta(c,0) = enter delta(c,1) = enter delta(d,0) = enter delta(d,1) = enter delta(e,0) = enter delta(e,1) = enter delta(f,0) = enter delta(f,1) = enter delta(g,0) = enter delta(g,1) = enter delta(h,0) = enter delta(h,1) =
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
+
+
+
+Original Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {a,b,c,d,e,f,g,h}
+ S = {0,1}
+ F = {d}
+ Start state is a
+ Delta:
+ d(a,0) = b d(a,1) = a
+ d(b,0) = a d(b,1) = c
+ d(c,0) = d d(c,1) = b
+ d(d,0) = d d(d,1) = a
+ d(e,0) = d d(e,1) = f
+ d(f,0) = g d(f,1) = e
+ d(g,0) = f d(g,1) = g
+ d(h,0) = g d(h,1) = d
+
+
+
+Reduced Deterministic Finite Automaton is:
+
+ (Q,S,delta,q0,F)
+
+where:
+
+ Q = {ag,bf,ce,d}
+ S = {0,1}
+ F = {d}
+ Start state is ag
+ Delta:
+ d(ag,0) = bf d(ag,1) = ag
+ d(bf,0) = ag d(bf,1) = ce
+ d(ce,0) = d d(ce,1) = bf
+ d(d,0) = d d(d,1) = ag
diff --git a/tests/general/misc.icn b/tests/general/misc.icn
new file mode 100644
index 0000000..d9fe462
--- /dev/null
+++ b/tests/general/misc.icn
@@ -0,0 +1,128 @@
+#SRC: JCON
+
+record message(who,gap,what)
+record recordAsVariable()
+
+procedure main()
+ local i, x
+
+ x := 1
+ x +:= |1 # tickled optimizer bug.
+ write(x)
+
+ x := table(3)
+ write(x[])
+
+ x := "o"
+ write("a" & "b")
+ write("c" | "d")
+ write(\"e")
+ write(!"f")
+ write(\&null | "g")
+ write(/&null & "h")
+ write("i" || "jk")
+ write(23 || "skidoo")
+ write(x, .x, x := "b")
+
+ every (write|"write")( (1|2)("hello", "mom"), "!")
+ every (write|"write")! [ (1|2) ! ["hello", "mom"], "!"]
+ write ! message("hello")
+ write ! message("hello", " ", "pop")
+ every i := -4 to 4 do
+ write("i=", i, ": ", i("a","b","c") | "failed")
+
+ every write(seq() \ 3)
+ every write(seq(4) \ 3)
+ every write(seq(,4) \ 3)
+ every write(seq(10,20) \ 3)
+
+ pairs { 1 to 100, 11 to 99 by 11 }
+
+ write("repl: ", repl("",5), repl("x",3), repl("foo",0), repl("xyz",4))
+ write("reverse: ", reverse(""), reverse("x"), reverse("ab"), reverse(12345));
+ every i := 0 to 255 do
+ if (ord(char(i)) ~= i) then write("char/ord oops ", i)
+ writes("char: ")
+ every writes(char((64 to 126) | 10))
+
+ write("proc: ")
+ write(" ", image(proc("write")))
+ write(" ", image(proc("write",)))
+ write(" ", image(proc("write",0)))
+ write(" ", image(proc("write",1)))
+ write(" ", image(proc("args")))
+ write(" ", image(proc("args",0)))
+ write(" >", args(main))
+ args := proc("args", 0)
+ write(" >", args(main))
+ write(" ", image(proc("args")))
+ write(" ", image(proc("args",0)))
+
+ # the following should all be harmless, at least
+ every collect(&null | (0 to 3), &null | 0 | 1 | 100 | 1000)
+
+ evaluation("1234567890", "abcdefghi")
+
+ every write(image(nullsuspend()))
+
+ write(image(recordAsVariable))
+ recordAsVariable := 3
+ write(image(recordAsVariable))
+
+ every write(tstreturn())
+
+ write("done")
+ exit()
+ write("oops!")
+ dummy()
+end
+
+procedure tstreturn()
+ return fn()
+end
+
+procedure fn()
+ suspend "OK to get here"
+ write("Should not get here when called from a 'return'")
+end
+
+# test Icon's (odd) two-pass argument evaluation process.
+procedure evaluation(a,b)
+ local x,y
+
+ write("argument evaluation test")
+ write(x, x:=1)
+ write(x:=2, x:=3)
+ write(a, a := 3)
+ write(b[2], b[2] := "q")
+ write(b[2:3], b[1:4] := "qwerty")
+ y := [1,2,3,4]
+ write(y[1], y[1] := 3)
+ x := 7
+ write(x[2], y[2] := 3)
+ y := table(0)
+ write(y[3], y[3] := 7)
+ x := y
+ write(x[5], y[5] := 8)
+end
+
+procedure dummy()
+ image(every 1) | 2 # this triggered a problem once upon a time.
+end
+
+procedure args(x[]) # later replaced by proc("args",0)
+ local s
+ s := ""
+ every s ||:= image(!x) do
+ s ||:= " "
+ return s[1:-1] | ""
+end
+
+procedure pairs(e)
+ while write(@e[1], " ", @e[2])
+end
+
+procedure nullsuspend()
+ suspend
+ suspend
+end
diff --git a/tests/general/misc.std b/tests/general/misc.std
new file mode 100644
index 0000000..2ae1e6e
--- /dev/null
+++ b/tests/general/misc.std
@@ -0,0 +1,80 @@
+2
+3
+b
+c
+e
+f
+g
+h
+ijk
+23skidoo
+bob
+hello!
+mom!
+hello!
+mom!
+hello!
+mom!
+hello!
+mom!
+hello
+hello pop
+i=-4: failed
+i=-3: a
+i=-2: b
+i=-1: c
+i=0: failed
+i=1: a
+i=2: b
+i=3: c
+i=4: failed
+1
+2
+3
+4
+5
+6
+1
+5
+9
+10
+30
+50
+1 11
+2 22
+3 33
+4 44
+5 55
+6 66
+7 77
+8 88
+9 99
+repl: xxxxyzxyzxyzxyz
+reverse: xba54321
+char: @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
+proc:
+ function write
+ function write
+ function write
+ function write
+ procedure args
+ function args
+ >procedure main
+ >0
+ function args
+ function args
+argument evaluation test
+11
+33
+33
+qq
+wqwerty
+33
+77
+88
+&null
+&null
+record constructor recordAsVariable
+3
+OK to get here
+done
diff --git a/tests/general/nargs.icn b/tests/general/nargs.icn
new file mode 100644
index 0000000..c556a36
--- /dev/null
+++ b/tests/general/nargs.icn
@@ -0,0 +1,98 @@
+#SRC: JCON
+
+# check return values from args()
+
+#%#% later: add graphics procedures
+
+procedure main()
+ nargs(abs, "abs")
+ nargs(acos, "acos")
+ nargs(any, "any")
+ nargs(args, "args")
+ nargs(asin, "asin")
+ nargs(atan, "atan")
+ nargs(bal, "bal")
+ nargs(center, "center")
+ nargs(char, "char")
+ nargs(close, "close")
+ nargs(collect, "collect")
+ nargs(copy, "copy")
+ nargs(cos, "cos")
+ nargs(cset, "cset")
+ nargs(delay, "delay")
+ nargs(delete, "delete")
+ nargs(detab, "detab")
+ nargs(display, "display")
+ nargs(dtor, "dtor")
+ nargs(entab, "entab")
+ nargs(errorclear, "errorclear")
+ nargs(exit, "exit")
+ nargs(exp, "exp")
+ nargs(find, "find")
+ nargs(flush, "flush")
+ nargs(function, "function")
+ nargs(get, "get")
+ nargs(getenv, "getenv")
+ nargs(iand, "iand")
+ nargs(icom, "icom")
+ nargs(image, "image")
+ nargs(insert, "insert")
+ nargs(integer, "integer")
+ nargs(ior, "ior")
+ nargs(ishift, "ishift")
+ nargs(ixor, "ixor")
+ nargs(key, "key")
+ nargs(left, "left")
+ nargs(list, "list")
+ nargs(log, "log")
+ nargs(many, "many")
+ nargs(map, "map")
+ nargs(match, "match")
+ nargs(member, "member")
+ nargs(move, "move")
+ nargs(name, "name")
+ nargs(numeric, "numeric")
+# nargs(open, "open") # not checked: varies depending on #ifdef Graphics
+ nargs(ord, "ord")
+ nargs(pop, "pop")
+ nargs(pos, "pos")
+ nargs(proc, "proc")
+ nargs(pull, "pull")
+ nargs(push, "push")
+ nargs(put, "put")
+ nargs(read, "read")
+ nargs(reads, "reads")
+ nargs(real, "real")
+ nargs(remove, "remove")
+ nargs(rename, "rename")
+ nargs(repl, "repl")
+ nargs(reverse, "reverse")
+ nargs(right, "right")
+ nargs(rtod, "rtod")
+ nargs(runerr, "runerr")
+ nargs(seek, "seek")
+ nargs(seq, "seq")
+ nargs(serial, "serial")
+ nargs(set, "set")
+ nargs(sin, "sin")
+ nargs(sort, "sort")
+ nargs(sortf, "sortf")
+ nargs(sqrt, "sqrt")
+ nargs(stop, "stop")
+ nargs(string, "string")
+ nargs(system, "system")
+ nargs(tab, "tab")
+ nargs(table, "table")
+ nargs(tan, "tan")
+ nargs(trim, "trim")
+ nargs(type, "type")
+ nargs(upto, "upto")
+ nargs(variable, "variable")
+ nargs(where, "where")
+ nargs(write, "write")
+ nargs(writes, "writes")
+end
+
+procedure nargs(p, s)
+ write(right(args(p),3), " ", s)
+end
diff --git a/tests/general/nargs.std b/tests/general/nargs.std
new file mode 100644
index 0000000..de4789c
--- /dev/null
+++ b/tests/general/nargs.std
@@ -0,0 +1,85 @@
+ 1 abs
+ 1 acos
+ 4 any
+ 1 args
+ 1 asin
+ 2 atan
+ 6 bal
+ 3 center
+ 1 char
+ 1 close
+ 2 collect
+ 1 copy
+ 1 cos
+ 1 cset
+ 1 delay
+ 2 delete
+ -2 detab
+ 2 display
+ 1 dtor
+ -2 entab
+ 0 errorclear
+ 1 exit
+ 1 exp
+ 4 find
+ 1 flush
+ 0 function
+ 1 get
+ 1 getenv
+ 2 iand
+ 1 icom
+ 1 image
+ 3 insert
+ 1 integer
+ 2 ior
+ 2 ishift
+ 2 ixor
+ 1 key
+ 3 left
+ 2 list
+ 2 log
+ 4 many
+ 3 map
+ 4 match
+ 2 member
+ 1 move
+ 1 name
+ 1 numeric
+ 1 ord
+ 1 pop
+ 1 pos
+ 2 proc
+ 1 pull
+ -2 push
+ -2 put
+ 1 read
+ 2 reads
+ 1 real
+ 1 remove
+ 2 rename
+ 2 repl
+ 1 reverse
+ 3 right
+ 1 rtod
+ -2 runerr
+ 2 seek
+ 2 seq
+ 1 serial
+ 1 set
+ 1 sin
+ 2 sort
+ 2 sortf
+ 1 sqrt
+ -1 stop
+ 1 string
+ 1 system
+ 1 tab
+ 1 table
+ 1 tan
+ 2 trim
+ 1 type
+ 4 upto
+ 1 variable
+ 1 where
+ -1 write
+ -1 writes
diff --git a/tests/general/numeric.icn b/tests/general/numeric.icn
new file mode 100644
index 0000000..cc64f55
--- /dev/null
+++ b/tests/general/numeric.icn
@@ -0,0 +1,192 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write("integer(2) ----> ",image(integer(2)) | "none")
+ write("integer(\"2\") ----> ",image(integer("2")) | "none")
+ write("integer(\" 2\") ----> ",image(integer(" 2")) | "none")
+ write("integer(\"2 \") ----> ",image(integer("2 ")) | "none")
+ write("integer(\"+2\") ----> ",image(integer("+2")) | "none")
+ write("integer(\"-2\") ----> ",image(integer("-2")) | "none")
+ write("integer(\"- 2\") ----> ",image(integer("- 2")) | "none")
+ write("integer(\" - 2 \") ----> ",image(integer(" - 2 ")) | "none")
+ write("integer(\"\") ----> ",image(integer("")) | "none")
+end
+
+procedure p2()
+ write("integer(\"--2\") ----> ",image(integer("--2")) | "none")
+ write("integer(\" \") ----> ",image(integer(" ")) | "none")
+ write("integer(\"-\") ----> ",image(integer("-")) | "none")
+ write("integer(\"+\") ----> ",image(integer("+")) | "none")
+ write("integer(\"7r4\") ----> ",image(integer("7r4")) | "none")
+end
+
+procedure p3()
+ write("integer(\"4r7\") ----> ",image(integer("4r7")) | "none")
+ write("integer(\"4r 7\") ----> ",image(integer("4r 7")) | "none")
+ write("integer(\"7r 4\") ----> ",image(integer("7r 4")) | "none")
+ write("integer(\"16rff\") ----> ",image(integer("16rff")) | "none")
+ write("integer(\"36rcat\") ----> ",image(integer("36rcat")) | "none")
+ write("integer(\"36Rcat\") ----> ",image(integer("36Rcat")) | "none")
+ write("integer(\"36rCAT\") ----> ",image(integer("36rCAT")) | "none")
+ write("integer(\"1r1\") ----> ",image(integer("1r1")) | "none")
+ write("integer(\"2r0\") ----> ",image(integer("2r0")) | "none")
+ write("integer(integer) ----> ",image(integer(integer)) | "none")
+ write("integer := abs ----> ",image(integer := abs) | "none")
+end
+
+procedure p4()
+ write("numeric(2) ----> ",image(numeric(2)) | "none")
+ write("numeric(\"2\") ----> ",image(numeric("2")) | "none")
+ write("numeric(\" 2\") ----> ",image(numeric(" 2")) | "none")
+ write("numeric(\"2 \") ----> ",image(numeric("2 ")) | "none")
+ write("numeric(\"+2\") ----> ",image(numeric("+2")) | "none")
+ write("numeric(\"-2\") ----> ",image(numeric("-2")) | "none")
+ write("numeric(\"- 2\") ----> ",image(numeric("- 2")) | "none")
+ write("numeric(\" - 2 \") ----> ",image(numeric(" - 2 ")) | "none")
+ write("numeric(\"\") ----> ",image(numeric("")) | "none")
+end
+
+procedure p5()
+ write("numeric(\"--2\") ----> ",image(numeric("--2")) | "none")
+ write("numeric(\" \") ----> ",image(numeric(" ")) | "none")
+ write("numeric(\"-\") ----> ",image(numeric("-")) | "none")
+ write("numeric(\"+\") ----> ",image(numeric("+")) | "none")
+ write("numeric(\"7r4\") ----> ",image(numeric("7r4")) | "none")
+end
+
+procedure p6()
+ write("numeric(\"4r7\") ----> ",image(numeric("4r7")) | "none")
+ write("numeric(\"4r 7\") ----> ",image(numeric("4r 7")) | "none")
+ write("numeric(\"7r 4\") ----> ",image(numeric("7r 4")) | "none")
+ write("numeric(\"16rff\") ----> ",image(numeric("16rff")) | "none")
+ write("numeric(\"36rcat\") ----> ",image(numeric("36rcat")) | "none")
+ write("numeric(\"36Rcat\") ----> ",image(numeric("36Rcat")) | "none")
+ write("numeric(\"36rCAT\") ----> ",image(numeric("36rCAT")) | "none")
+ write("numeric(\"1r1\") ----> ",image(numeric("1r1")) | "none")
+ write("numeric(\"2r0\") ----> ",image(numeric("2r0")) | "none")
+end
+
+procedure p9()
+ write("100 - - 4 ----> ",image(100 - - 4) | "none")
+ write("100 --4 ----> ",image(100 --4) | "none")
+ write("100- - 4 ----> ",image(100- - 4) | "none")
+ write("100 -- 4 ----> ",image(100 -- 4) | "none")
+ write("100 - -4 ----> ",image(100 - -4) | "none")
+end
+
+procedure p10()
+ write("abs(1) ----> ",image(abs(1)) | "none")
+ write("abs(-1) ----> ",image(abs(-1)) | "none")
+ write("abs(0) ----> ",image(abs(0)) | "none")
+ write("36 % 7 ----> ",image(36 % 7) | "none")
+ write("-36 % 7 ----> ",image(-36 % 7) | "none")
+ write("36 % -7 ----> ",image(36 % -7) | "none")
+ write("-36 % -7 ----> ",image(-36 % -7) | "none")
+end
+
+procedure p11()
+ write("36 * 9 ----> ",image(36 * 9) | "none")
+ write("-36 * 9 ----> ",image(-36 * 9) | "none")
+ write("36 * -9 ----> ",image(36 * -9) | "none")
+ write("-36 * -9 ----> ",image(-36 * -9) | "none")
+end
+
+procedure p12()
+ write("36 / 9 ----> ",image(36 / 9) | "none")
+ write("-36 / 9 ----> ",image(-36 / 9) | "none")
+ write("36 / -9 ----> ",image(36 / -9) | "none")
+ write("-36 / -9 ----> ",image(-36 / -9) | "none")
+end
+
+procedure p13()
+ write("36 + 9 ----> ",image(36 + 9) | "none")
+ write("-36 + 9 ----> ",image(-36 + 9) | "none")
+ write("36 + -9 ----> ",image(36 + -9) | "none")
+ write("-36 + -9 ----> ",image(-36 + -9) | "none")
+end
+
+procedure p14()
+ write("36 ^ -9 ----> ",image(36 ^ -9) | "none")
+ write("1 < 1 ----> ",image(1 < 1) | "none")
+ write("1 < 2 ----> ",image(1 < 2) | "none")
+ write("1 < 0 ----> ",image(1 < 0) | "none")
+ write("-1 < 0 ----> ",image(-1 < 0) | "none")
+ write("1 < -2 ----> ",image(1 < -2) | "none")
+ write("-1 < -0 ----> ",image(-1 < -0) | "none")
+end
+
+procedure p15()
+ write("1 > 1 ----> ",image(1 > 1) | "none")
+ write("1 > 2 ----> ",image(1 > 2) | "none")
+ write("1 > 0 ----> ",image(1 > 0) | "none")
+ write("-1 > 0 ----> ",image(-1 > 0) | "none")
+ write("1 > -2 ----> ",image(1 > -2) | "none")
+end
+
+procedure p16()
+ write("-1 > -0 ----> ",image(-1 > -0) | "none")
+ write("1 <= 1 ----> ",image(1 <= 1) | "none")
+ write("1 <= 2 ----> ",image(1 <= 2) | "none")
+ write("1 <= 0 ----> ",image(1 <= 0) | "none")
+ write("-1 <= 0 ----> ",image(-1 <= 0) | "none")
+end
+
+procedure p17()
+ write("1 <= -2 ----> ",image(1 <= -2) | "none")
+ write("-1 <= -0 ----> ",image(-1 <= -0) | "none")
+ write("1 >= 1 ----> ",image(1 >= 1) | "none")
+ write("1 >= 2 ----> ",image(1 >= 2) | "none")
+ write("1 >= 0 ----> ",image(1 >= 0) | "none")
+end
+
+procedure p18()
+ write("-1 >= 0 ----> ",image(-1 >= 0) | "none")
+ write("1 >= -2 ----> ",image(1 >= -2) | "none")
+ write("-1 >= -0 ----> ",image(-1 >= -0) | "none")
+ write("1 = 1 ----> ",image(1 = 1) | "none")
+ write("1 = 2 ----> ",image(1 = 2) | "none")
+end
+
+procedure p19()
+ write("1 = 0 ----> ",image(1 = 0) | "none")
+ write("-1 = 0 ----> ",image(-1 = 0) | "none")
+ write("1 = -2 ----> ",image(1 = -2) | "none")
+ write("-1 = -0 ----> ",image(-1 = -0) | "none")
+ write("1 ~= 1 ----> ",image(1 ~= 1) | "none")
+end
+
+procedure p20()
+ write("1 ~= 2 ----> ",image(1 ~= 2) | "none")
+ write("1 ~= 0 ----> ",image(1 ~= 0) | "none")
+ write("-1 ~= 0 ----> ",image(-1 ~= 0) | "none")
+ write("1 ~= -2 ----> ",image(1 ~= -2) | "none")
+ write("-1 ~= -0 ----> ",image(-1 ~= -0) | "none")
+end
+
+procedure p21()
+ write("36 ^ -9 ----> ",image(36 ^ -9) | "none")
+ write("-36 ^ -9 ----> ",image(-36 ^ -9) | "none")
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p9()
+ p10()
+ p11()
+ p12()
+ p13()
+ p14()
+ p15()
+ p16()
+ p17()
+ p18()
+ p19()
+ p20()
+ p21()
+end
+
diff --git a/tests/general/numeric.std b/tests/general/numeric.std
new file mode 100644
index 0000000..9dbce6a
--- /dev/null
+++ b/tests/general/numeric.std
@@ -0,0 +1,111 @@
+integer(2) ----> 2
+integer("2") ----> 2
+integer(" 2") ----> 2
+integer("2 ") ----> 2
+integer("+2") ----> 2
+integer("-2") ----> -2
+integer("- 2") ----> none
+integer(" - 2 ") ----> none
+integer("") ----> none
+integer("--2") ----> none
+integer(" ") ----> none
+integer("-") ----> none
+integer("+") ----> none
+integer("7r4") ----> 4
+integer("4r7") ----> none
+integer("4r 7") ----> none
+integer("7r 4") ----> none
+integer("16rff") ----> 255
+integer("36rcat") ----> 15941
+integer("36Rcat") ----> 15941
+integer("36rCAT") ----> 15941
+integer("1r1") ----> none
+integer("2r0") ----> 0
+integer(integer) ----> none
+integer := abs ----> function abs
+numeric(2) ----> 2
+numeric("2") ----> 2
+numeric(" 2") ----> 2
+numeric("2 ") ----> 2
+numeric("+2") ----> 2
+numeric("-2") ----> -2
+numeric("- 2") ----> none
+numeric(" - 2 ") ----> none
+numeric("") ----> none
+numeric("--2") ----> none
+numeric(" ") ----> none
+numeric("-") ----> none
+numeric("+") ----> none
+numeric("7r4") ----> 4
+numeric("4r7") ----> none
+numeric("4r 7") ----> none
+numeric("7r 4") ----> none
+numeric("16rff") ----> 255
+numeric("36rcat") ----> 15941
+numeric("36Rcat") ----> 15941
+numeric("36rCAT") ----> 15941
+numeric("1r1") ----> none
+numeric("2r0") ----> 0
+100 - - 4 ----> 104
+100 --4 ----> '01'
+100- - 4 ----> 104
+100 -- 4 ----> '01'
+100 - -4 ----> 104
+abs(1) ----> 1
+abs(-1) ----> 1
+abs(0) ----> 0
+36 % 7 ----> 1
+-36 % 7 ----> -1
+36 % -7 ----> 1
+-36 % -7 ----> -1
+36 * 9 ----> 324
+-36 * 9 ----> -324
+36 * -9 ----> -324
+-36 * -9 ----> 324
+36 / 9 ----> 4
+-36 / 9 ----> -4
+36 / -9 ----> -4
+-36 / -9 ----> 4
+36 + 9 ----> 45
+-36 + 9 ----> -27
+36 + -9 ----> 27
+-36 + -9 ----> -45
+36 ^ -9 ----> 0
+1 < 1 ----> none
+1 < 2 ----> 2
+1 < 0 ----> none
+-1 < 0 ----> 0
+1 < -2 ----> none
+-1 < -0 ----> 0
+1 > 1 ----> none
+1 > 2 ----> none
+1 > 0 ----> 0
+-1 > 0 ----> none
+1 > -2 ----> -2
+-1 > -0 ----> none
+1 <= 1 ----> 1
+1 <= 2 ----> 2
+1 <= 0 ----> none
+-1 <= 0 ----> 0
+1 <= -2 ----> none
+-1 <= -0 ----> 0
+1 >= 1 ----> 1
+1 >= 2 ----> none
+1 >= 0 ----> 0
+-1 >= 0 ----> none
+1 >= -2 ----> -2
+-1 >= -0 ----> none
+1 = 1 ----> 1
+1 = 2 ----> none
+1 = 0 ----> none
+-1 = 0 ----> none
+1 = -2 ----> none
+-1 = -0 ----> none
+1 ~= 1 ----> none
+1 ~= 2 ----> 2
+1 ~= 0 ----> 0
+-1 ~= 0 ----> 0
+1 ~= -2 ----> -2
+-1 ~= -0 ----> 0
+36 ^ -9 ----> 0
+-36 ^ -9 ----> 0
diff --git a/tests/general/options.ok b/tests/general/options.ok
new file mode 100644
index 0000000..ddd4b98
--- /dev/null
+++ b/tests/general/options.ok
@@ -0,0 +1,20 @@
+Translating:
+hello.icn:
+ main
+No errors
+Linking:
+Executing:
+ Hello, there.
+ Hello, north.
+ Hello, south.
+ Hello, east.
+ : main(list_1 = ["west"])
+ Hello, west.
+hello.icn : 5 main failed
+ Hello, Tucson.
+ Hello, Pima.
+ Hello, Arizona.
+ Hello, world.
+ Hello, galaxy.
+ Hello, universe.
+HOWDY!
diff --git a/tests/general/others.dat b/tests/general/others.dat
new file mode 100644
index 0000000..da17d7a
--- /dev/null
+++ b/tests/general/others.dat
@@ -0,0 +1,23 @@
+#
+# W O R D T A B U L A T I O N
+#
+
+# This main procedure processes standard input and writes the results
+# with the words in a column 20 characters wide.
+
+procedure main()
+ wordcount(20)
+end
+
+procedure wordcount(n)
+ local t, line, x, y
+ static letters
+ initial letters := &lcase ++ &ucase
+ t := table(,0)
+ every line := !&input do
+ scan line using
+ while tab(upto(letters)) do
+ t[tab(many(letters))] +:= 1
+ x := sort(t)
+ every y := !x do write(left(y[1],n),y[2])
+end
diff --git a/tests/general/others.icn b/tests/general/others.icn
new file mode 100644
index 0000000..a7244ea
--- /dev/null
+++ b/tests/general/others.icn
@@ -0,0 +1,98 @@
+
+procedure spell(n)
+ local m
+ n := integer(n) | stop(image(n)," is not an integer")
+ if n <= 12 then return {
+ "0zero,1one,2two,3three,4four,5five,6six,7seven,8eight,_
+ 9nine,10ten,11eleven,12twelve," ? {
+ tab(find(n))
+ move(*n)
+ tab(upto(","))
+ }
+ }
+ else if n <= 19 then return {
+ spell(n[2] || "0") ?
+ (if ="for" then "four" else tab(find("ty"))) || "teen"
+ }
+ else if n <= 99 then return {
+ "2twen,3thir,4for,5fif,6six,7seven,8eigh,9nine," ? {
+ tab(upto(n[1]))
+ move(1)
+ tab(upto(",")) || "ty" ||
+ if n[2] ~= 0 then "-" || spell(n[2])
+ }
+ }
+ else if n <= 999 then return {
+ spell(n[1]) || " hundred" ||
+ (if (m := n[2:0]) ~= 0 then " and " || spell(m) else "")
+ }
+ else if n <= 999999 then return {
+ spell(n[1:-3]) || " thousand" ||
+ (if (m := n[2:0]) ~= 0 then " and " || spell(m) else "")
+ }
+ else if n <= 999999999 then return {
+ spell(n[1:-6]) || " million" ||
+ (if (m := n[2:0]) ~= 0 then " and " || spell(m) else "")
+ }
+ else fail
+end
+
+procedure spellw(n)
+ write(n, " ", spell(n))
+ return
+end
+
+procedure main()
+ every spellw(1 to 25)
+ every spellw(30 to 110 by 3)
+ spellw(945123342)
+ every spellw(10000000 to 10000500 by 7)
+ sieve()
+ wordcnt()
+end
+
+#
+# S I E V E O F E R A T O S T H E N E S
+#
+
+# This program illustrates the use of sets in implementing the
+# classical sieve algorithm for computing prime numbers.
+
+procedure sieve()
+ local limit, s, i
+ limit := 100
+ s := set()
+ every insert(s,1 to limit)
+ every member(s,i := 2 to limit) do
+ every delete(s,i + i to limit by i)
+ delete(s,1)
+ primes := sort(s)
+ write("There are ",*primes," primes in the first ",limit," integers.")
+ write("The primes are:")
+ every write(right(!primes,*limit + 1))
+end
+
+#
+# W O R D C O U N T I N G
+#
+
+# This program tabulates the words in standard input and writes the
+# results with the words in a column 20 characters wide. The definition
+# of a "word" is naive.
+
+procedure wordcnt()
+ wordcount(20)
+end
+
+procedure wordcount(n)
+ local t, line, x, i
+ static letters
+ initial letters := &lcase ++ &ucase
+ t := table(0)
+ while line := read() do
+ line ? while tab(upto(letters)) do
+ t[tab(many(letters))] +:= 1
+ x := sort(t,3)
+ every i := 1 to *x - 1 by 2 do
+ write(left(x[i],n),x[i + 1])
+end
diff --git a/tests/general/others.std b/tests/general/others.std
new file mode 100644
index 0000000..030def5
--- /dev/null
+++ b/tests/general/others.std
@@ -0,0 +1,183 @@
+1 one
+2 two
+3 three
+4 four
+5 five
+6 six
+7 seven
+8 eight
+9 nine
+10 ten
+11 eleven
+12 twelve
+21 twenty-one
+22 twenty-two
+23 twenty-three
+24 twenty-four
+25 twenty-five
+33 thirty-three
+36 thirty-six
+39 thirty-nine
+42 forty-two
+45 forty-five
+48 forty-eight
+51 fifty-one
+54 fifty-four
+57 fifty-seven
+63 sixty-three
+66 sixty-six
+69 sixty-nine
+72 seventy-two
+75 seventy-five
+78 seventy-eight
+81 eighty-one
+84 eighty-four
+87 eighty-seven
+93 ninety-three
+96 ninety-six
+99 ninety-nine
+102 one hundred and two
+105 one hundred and five
+108 one hundred and eight
+945123342 nine hundred and forty-five million and forty-five million and five million and one hundred and twenty-three thousand and twenty-three thousand and three thousand and three hundred and forty-two
+10000000 ten million
+10000007 ten million and seven
+10000021 ten million and twenty-one
+10000028 ten million and twenty-eight
+10000035 ten million and thirty-five
+10000042 ten million and forty-two
+10000049 ten million and forty-nine
+10000056 ten million and fifty-six
+10000063 ten million and sixty-three
+10000077 ten million and seventy-seven
+10000084 ten million and eighty-four
+10000091 ten million and ninety-one
+10000098 ten million and ninety-eight
+10000105 ten million and one hundred and five
+10000112 ten million and one hundred and twelve
+10000126 ten million and one hundred and twenty-six
+10000133 ten million and one hundred and thirty-three
+10000147 ten million and one hundred and forty-seven
+10000154 ten million and one hundred and fifty-four
+10000161 ten million and one hundred and sixty-one
+10000168 ten million and one hundred and sixty-eight
+10000175 ten million and one hundred and seventy-five
+10000182 ten million and one hundred and eighty-two
+10000189 ten million and one hundred and eighty-nine
+10000196 ten million and one hundred and ninety-six
+10000203 ten million and two hundred and three
+10000210 ten million and two hundred and ten
+10000224 ten million and two hundred and twenty-four
+10000231 ten million and two hundred and thirty-one
+10000238 ten million and two hundred and thirty-eight
+10000245 ten million and two hundred and forty-five
+10000252 ten million and two hundred and fifty-two
+10000259 ten million and two hundred and fifty-nine
+10000266 ten million and two hundred and sixty-six
+10000273 ten million and two hundred and seventy-three
+10000287 ten million and two hundred and eighty-seven
+10000294 ten million and two hundred and ninety-four
+10000301 ten million and three hundred and one
+10000308 ten million and three hundred and eight
+10000322 ten million and three hundred and twenty-two
+10000329 ten million and three hundred and twenty-nine
+10000336 ten million and three hundred and thirty-six
+10000343 ten million and three hundred and forty-three
+10000357 ten million and three hundred and fifty-seven
+10000364 ten million and three hundred and sixty-four
+10000371 ten million and three hundred and seventy-one
+10000378 ten million and three hundred and seventy-eight
+10000385 ten million and three hundred and eighty-five
+10000392 ten million and three hundred and ninety-two
+10000399 ten million and three hundred and ninety-nine
+10000406 ten million and four hundred and six
+10000427 ten million and four hundred and twenty-seven
+10000434 ten million and four hundred and thirty-four
+10000441 ten million and four hundred and forty-one
+10000448 ten million and four hundred and forty-eight
+10000455 ten million and four hundred and fifty-five
+10000462 ten million and four hundred and sixty-two
+10000469 ten million and four hundred and sixty-nine
+10000476 ten million and four hundred and seventy-six
+10000483 ten million and four hundred and eighty-three
+10000497 ten million and four hundred and ninety-seven
+There are 25 primes in the first 100 integers.
+The primes are:
+ 2
+ 3
+ 5
+ 7
+ 11
+ 13
+ 17
+ 19
+ 23
+ 29
+ 31
+ 37
+ 41
+ 43
+ 47
+ 53
+ 59
+ 61
+ 67
+ 71
+ 73
+ 79
+ 83
+ 89
+ 97
+A 2
+B 1
+D 1
+I 1
+L 1
+N 1
+O 2
+R 1
+T 2
+This 1
+U 1
+W 1
+a 1
+and 1
+characters 1
+column 1
+do 3
+end 2
+every 2
+in 1
+initial 1
+input 2
+lcase 1
+left 1
+letters 4
+line 3
+local 1
+main 2
+many 1
+n 2
+procedure 3
+processes 1
+results 1
+scan 1
+sort 1
+standard 1
+static 1
+t 4
+tab 2
+table 1
+the 2
+ucase 1
+upto 1
+using 1
+while 1
+wide 1
+with 1
+wordcount 2
+words 1
+write 1
+writes 1
+x 3
+y 4
diff --git a/tests/general/over.icn b/tests/general/over.icn
new file mode 100644
index 0000000..3f2c8c0
--- /dev/null
+++ b/tests/general/over.icn
@@ -0,0 +1,22 @@
+procedure main()
+ if not(&features == "large integers") then
+ stop("large integers not supported")
+ i := 100000 + 10000
+ write(i)
+ i +:= 2 ^ 30
+ write(i)
+ i +:= i
+ write(i)
+ i := 100000 * 10000
+ write(i)
+ i +:= 2 ^ 30
+ write(i)
+ i *:= i
+ write(i)
+ i := -100000 - 10000
+ write(i)
+ i +:= -(2 ^ 30)
+ write(i)
+ i -:= 2 ^ 30
+ write(i)
+end
diff --git a/tests/general/over.std b/tests/general/over.std
new file mode 100644
index 0000000..e5956c5
--- /dev/null
+++ b/tests/general/over.std
@@ -0,0 +1,9 @@
+110000
+1073851824
+2147703648
+1000000000
+2073741824
+4300405152606846976
+-110000
+-1073851824
+-2147593648
diff --git a/tests/general/parse.icn b/tests/general/parse.icn
new file mode 100644
index 0000000..8ac3b21
--- /dev/null
+++ b/tests/general/parse.icn
@@ -0,0 +1,21 @@
+#SRC: JCON
+
+# test grouping of various operators
+
+procedure main()
+ write(3^3^2)
+ write(8/4/2)
+ write(2-2-2)
+ write(image(f![g]![2]))
+ write((2<3>2)|"fail")
+ every write(1 to 2 to 3)
+ write("x" ? (tab(0)||"y") ? tab(0))
+end
+
+procedure f(x)
+ return x
+end
+
+procedure g(x)
+ return x+2
+end
diff --git a/tests/general/parse.std b/tests/general/parse.std
new file mode 100644
index 0000000..d817d52
--- /dev/null
+++ b/tests/general/parse.std
@@ -0,0 +1,11 @@
+19683
+1
+-2
+4
+2
+1
+2
+3
+2
+3
+xy
diff --git a/tests/general/pdco.icn b/tests/general/pdco.icn
new file mode 100644
index 0000000..26ae2a3
--- /dev/null
+++ b/tests/general/pdco.icn
@@ -0,0 +1,179 @@
+#
+# D E F I N E D C O N T R O L O P E R A T I O N S
+#
+
+# This program illustrates how programmer-control operations can be
+# implemented in Icon using co-expressions and the p{ ... }
+# syntax that facilitates their use.
+
+procedure main()
+ if not(&features == "co-expressions") then
+ stop("co-expressions not supported")
+ write(Seqimage{1 to 10})
+ write(Seqimage{&fail})
+ write(Seqimage{(1 to 10 by 2) | (10 to 1 by -2)})
+ write(Seqimage{!"abc" || !"xy"})
+ write(Seqimage{Seqimage | main})
+ every write(Galt{1 to 10,!"abcd",1 to 10})
+ write(Seqimage{star("abc") \ 10})
+ write(Seqimage{1 to 50,5})
+ write("---")
+ every write(Limit{1 to 100,3})
+ write("---")
+ every write(Ranseq{!"abcd",1 to 10})
+ every Parallel{|write,!"abcd",1 to 10}
+ every Allpar{|write,!"abcd",1 to 10} \ 20
+ every Rotate{|write,!"abcd",1 to 10} \ 20
+end
+
+procedure star(s)
+ suspend "" | (star(s) || !s)
+end
+
+procedure Galt(a)
+ local e
+ every e := !a do suspend |@e
+end
+
+procedure Limit(a)
+ local i, x
+ while i := @a[2] do {
+ a[1] := ^a[1]
+ every 1 to i do
+ if x := @a[1] then suspend x
+ else break
+ }
+end
+
+procedure Ranseq(a)
+ local x
+ while x := @?a do suspend x
+end
+
+procedure Seqimage(L)
+ local s
+ s := ""
+ while s ||:= ", " || image(@L[1])
+ return "{" || s[3:0] || "}" | "{}"
+end
+
+procedure Allpar(a)
+ local i, x, done
+ x := list(*a)
+ done := list(*a,1)
+ every i := 1 to *a do x[i] := @a[i] | fail
+ repeat {
+ suspend Call(x)
+ every i := 1 to *a do
+ if done[i] = 1 then ((x[i] := @a[i]) | (done[i] := 0))
+ if not(!done = 1) then fail
+ }
+end
+
+procedure Call(a)
+ suspend case *a of {
+ 1 : a[1]()
+ 2 : a[1](a[2])
+ 3 : a[1](a[2],a[3])
+ 4 : a[1](a[2],a[3],a[4])
+ 5 : a[1](a[2],a[3],a[4],a[5])
+ 6 : a[1](a[2],a[3],a[4],a[5],a[6])
+ 7 : a[1](a[2],a[3],a[4],a[5],a[6],a[7])
+ 8 : a[1](a[2],a[3],a[4],a[5],a[6],a[7],a[8])
+ 9 : a[1](a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9])
+ 10 : a[1](a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10])
+ default : stop("Call : too many args.")
+ }
+end
+
+procedure Extract(a)
+ local i, j, n, x
+ x := list(*a/2)
+ repeat {
+ i := 1
+ while i < *a do {
+ n := @a[i] | fail
+ every 1 to n do
+ x[(i + 1)/2] := @a[i + 1] | fail
+ a[i + 1] := ^a[i + 1]
+ i +:= 2
+ }
+ suspend Call(x)
+ }
+end
+
+procedure Lifo(a)
+ local i, x, ptr
+ x := list(*a)
+ ptr := 1
+ repeat {
+ repeat
+ if x[ptr] := @a[ptr]
+ then {
+ ptr +:= 1
+ (a[ptr] := ^a[ptr]) |
+ break
+ }
+ else if (ptr -:= 1) = 0
+ then fail
+ suspend Call(x)
+ ptr := *a
+ }
+end
+
+procedure Parallel(a)
+ local i, x
+ x := list(*a)
+ repeat {
+ every i := 1 to *a do
+ x[i] := @a[i] | fail
+ suspend Call(x)
+ }
+end
+
+procedure Reverse(a)
+ local i, x, ptr
+ x := list(*a)
+ ptr := *a
+ repeat {
+ repeat
+ if x[ptr] := @a[ptr]
+ then {
+ ptr -:= 1
+ (a[ptr] := ^a[ptr]) |
+ break
+ }
+ else if (ptr +:= 1) > *a
+ then fail
+ suspend Call(x)
+ ptr := 1
+ }
+end
+
+procedure Rotate(a)
+ local i, x, done
+ x := list(*a)
+ done := list(*a,1)
+ every i := 1 to *a do x[i] := @a[i] | fail
+ repeat {
+ suspend Call(x)
+ every i := 1 to *a do
+ if not(x[i] := @a[i]) then {
+ done[i] := 0
+ if !done = 1 then {
+ a[i] := ^a[i]
+ x[i] := @a[i] | fail
+ }
+ else fail
+ }
+ }
+end
+
+procedure Simple(a)
+ local i, x
+ x := list(*a)
+ every i := 1 to *a do
+ x[i] := @a[i] | fail
+ return Call(x)
+end
+
diff --git a/tests/general/pdco.std b/tests/general/pdco.std
new file mode 100644
index 0000000..8e11e53
--- /dev/null
+++ b/tests/general/pdco.std
@@ -0,0 +1,85 @@
+{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
+{}
+{1, 3, 5, 7, 9, 10, 8, 6, 4, 2}
+{"ax", "ay", "bx", "by", "cx", "cy"}
+{procedure Seqimage, procedure main}
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+a
+b
+c
+d
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+{"", "a", "b", "c", "aa", "ab", "ac", "ba", "bb", "bc"}
+{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50}
+---
+1
+2
+3
+---
+a
+b
+c
+1
+d
+a1
+b2
+c3
+d4
+a1
+b2
+c3
+d4
+d5
+d6
+d7
+d8
+d9
+d10
+d10
+d10
+d10
+d10
+d10
+d10
+d10
+d10
+d10
+d10
+a1
+b2
+c3
+d4
+a5
+b6
+c7
+d8
+a9
+b10
+c1
+d2
+a3
+b4
+c5
+d6
+a7
+b8
+c9
+d10
diff --git a/tests/general/prefix.dat b/tests/general/prefix.dat
new file mode 100644
index 0000000..1eec5ed
--- /dev/null
+++ b/tests/general/prefix.dat
@@ -0,0 +1,8 @@
+x
+(((x)))
+x+1
+x-y-z
+3*delta+1
+((x+1))
+2^2^n
+(x^n)/(z+1)
diff --git a/tests/general/prefix.icn b/tests/general/prefix.icn
new file mode 100644
index 0000000..0f6b0e0
--- /dev/null
+++ b/tests/general/prefix.icn
@@ -0,0 +1,41 @@
+#
+# I N F I X - T O - P R E F I X C O N V E R S I O N
+#
+
+# This program accepts infix expressions from standard input and
+# writes the corresponding prefix expressions to standard output.
+
+procedure main()
+ while write(prefix(read()))
+end
+
+procedure prefix(s)
+ s := strip(s)
+ return lassoc(s,'+-' | '*/') | rassoc(s,'^') | s
+end
+
+procedure strip(s)
+ while s ? (="(" & s <- tab(bal(')')) & pos(-1))
+ return s
+end
+
+procedure lassoc(s,c)
+ local j
+ s ? every j := bal(c)
+ return form(s,\j)
+end
+
+procedure rassoc(s,c)
+ local j
+ return form(s,s ? bal(c))
+end
+
+procedure form(s,k)
+ local a1, a2, op
+ s ? {
+ a1 := tab(k)
+ op := move(1)
+ a2 := tab(0)
+ }
+ return op || "(" || prefix(a1) || "," || prefix(a2) || ")"
+end
diff --git a/tests/general/prefix.std b/tests/general/prefix.std
new file mode 100644
index 0000000..c1f91af
--- /dev/null
+++ b/tests/general/prefix.std
@@ -0,0 +1,8 @@
+x
+x
++(x,1)
+-(-(x,y),z)
++(*(3,delta),1)
++(x,1)
+^(2,^(2,n))
+/(^(x,n),+(z,1))
diff --git a/tests/general/prepro.dat b/tests/general/prepro.dat
new file mode 100644
index 0000000..4195df4
--- /dev/null
+++ b/tests/general/prepro.dat
@@ -0,0 +1,7 @@
+# prepro.dat -- code fragment $included by prepro.icn
+
+write("prepro.dat here")
+
+$undef abc
+$define abc 321
+$define xyzzy 47
diff --git a/tests/general/prepro.icn b/tests/general/prepro.icn
new file mode 100644
index 0000000..0b9972a
--- /dev/null
+++ b/tests/general/prepro.icn
@@ -0,0 +1,102 @@
+# test various preprocessor features
+
+# test $define and various whitespace uses
+$define abc 123
+ $ define def 456
+$define ghi 789
+$ define ghi 789 # duplicate definition should be ok if same
+$undef ghi
+$define ghi 987 # different definition should be ok after $undef
+
+# test (when used later) that substituted text is rescanned
+$define yy (xx+xx)
+$define xx 1
+
+# test undefinition of something that isn't defined
+$undef notdefined
+
+# test ifdef of undefined symbol, and successful skip past bogus directive
+$ifdef notdef
+$BOGUS
+$endif
+
+# test ifdef of defined symbol, and null test body
+$ifdef abc
+$endif
+
+# test ifndef of defined symbol
+$ifndef abc
+$error -- abc not defined
+$endif#comment on if terminator
+
+
+# main test program
+
+procedure main()
+ # write values from definitions; test no substitution in string constant
+ write("abc,def,ghi,xx,yy: ", abc, " ", def, " ", ghi, " ", xx, " ", yy)
+
+ # test $include by including a code fragment from prepro.dat
+ $include "prepro.dat"
+
+ # write values defined in prepro.dat
+ write("xyzzy: ", xyzzy)
+ write("abc,def,ghi,xx,yy: ", abc, " ", def, " ", ghi, " ", xx, " ", yy)
+
+ # test that predefined symbols agree with &features
+ # (if defined, first argument is 1, else it's null)
+ precheck(_AMIGA, "Amiga")
+ precheck(_ACORN, "Acorn Archimedes")
+ precheck(_MACINTOSH, "Macintosh")
+ precheck(_MSDOS_386, "MS-DOS/386")
+ precheck(_MSDOS, "MS-DOS")
+ precheck(_OS2, "OS/2")
+ precheck(_PORT, "PORT")
+ precheck(_UNIX, "UNIX")
+ precheck(_VMS, "VMS")
+ precheck(_COMPILED, "compiled")
+ precheck(_INTERPRETED, "interpreted")
+ precheck(_ASCII, "ASCII", 1)
+ precheck(_EBCDIC, "EBCDIC", 1)
+ precheck(_CALLING, "calling to Icon")
+ precheck(_CO_EXPRESSIONS, "co-expressions")
+ precheck(_DIRECT_EXECUTION, "direct execution")
+ precheck(_EVENT_MONITOR, "event monitoring")
+ precheck(_EXECUTABLE_IMAGES, "executable images")
+ precheck(_EXTERNAL_FUNCTIONS,"external functions")
+ precheck(_KEYBOARD_FUNCTIONS,"keyboard functions")
+ precheck(_LARGE_INTEGERS, "large integers")
+ precheck(_MEMORY_MONITOR, "memory monitoring")
+ precheck(_MULTITASKING, "multiple programs")
+ precheck(_MULTIREGION, "multiple regions")
+ precheck(_PIPES, "pipes")
+ precheck(_RECORD_IO, "record I/O")
+ precheck(_STRING_INVOKE, "string invocation")
+ precheck(_SYSTEM_FUNCTION, "system function")
+ precheck(_VISUALIZATION, "visualization support")
+ precheck(_WINDOW_FUNCTIONS, "window functions")
+ precheck(_X_WINDOW_SYSTEM, "X Windows")
+ precheck(_PRESENTATION_MGR, "Presentation Manager")
+ precheck(_ARM_FUNCTIONS, "Archimedes extensions")
+ precheck(_DOS_FUNCTIONS, "MS-DOS extensions")
+ write("done")
+end
+
+
+# precheck (v, s, p) -- check that s is in &features iff v is non-null;
+# always print presence/absence if p is non-null
+
+procedure precheck (v, s, p)
+ if s == &features then {
+ if /v then
+ write ("error: no predefined symbol for ", s)
+ else if \p then
+ write ("found feature: ", s)
+ }
+ else {
+ if \v then
+ write ("error: unexpected predefined symbol for ", s)
+ else if \p then
+ write ("no feature: ", s)
+ }
+end
diff --git a/tests/general/prepro.std b/tests/general/prepro.std
new file mode 100644
index 0000000..d26cd46
--- /dev/null
+++ b/tests/general/prepro.std
@@ -0,0 +1,7 @@
+abc,def,ghi,xx,yy: 123 456 987 1 2
+prepro.dat here
+xyzzy: 47
+abc,def,ghi,xx,yy: 321 456 987 1 2
+found feature: ASCII
+no feature: EBCDIC
+done
diff --git a/tests/general/primes.icn b/tests/general/primes.icn
new file mode 100644
index 0000000..56f1874
--- /dev/null
+++ b/tests/general/primes.icn
@@ -0,0 +1,12 @@
+#SRC: JCON
+
+# a simple and slow prime number generator
+
+procedure main()
+ local i
+ every i := 2 to 100 do {
+ if i % (2 to i - 1) = 0 then
+ next
+ write(i)
+ }
+end
diff --git a/tests/general/primes.std b/tests/general/primes.std
new file mode 100644
index 0000000..afc67fd
--- /dev/null
+++ b/tests/general/primes.std
@@ -0,0 +1,25 @@
+2
+3
+5
+7
+11
+13
+17
+19
+23
+29
+31
+37
+41
+43
+47
+53
+59
+61
+67
+71
+73
+79
+83
+89
+97
diff --git a/tests/general/proto.icn b/tests/general/proto.icn
new file mode 100644
index 0000000..94c384b
--- /dev/null
+++ b/tests/general/proto.icn
@@ -0,0 +1,156 @@
+# This program contains samples of all the basic syntactic
+# forms in Icon.
+
+record three(x,y,z)
+record zero()
+record one(z)
+
+global line, count
+
+procedure main()
+end
+procedure expr1(a, b)
+ local x,y,z
+ static e1
+ initial e1 := 0
+ ()
+ {}
+ ();()
+ []
+ [,]
+ x.y
+ x[i]
+ x[i:j]
+ x[i+:j]
+ x[i-:j]
+ (,,,)
+ x(,,,)
+ x!y
+ not x
+ |x
+ !x
+ *x
+ +x
+ -x
+end
+
+procedure expr2(a, b[])
+ .x
+ /x
+ =x
+ ?x
+ \x
+ ~x
+ @x
+ ^x
+ x \ i
+ x @ y
+ i ^ j
+ i * j
+ i / j
+ i % j
+ c1 ** c2
+ i + j
+ i - j
+ c1 ++ c2
+ c1 -- c2
+ s1 || s2
+ a1 ||| a2
+ i < j
+ i <= j
+ i = j
+ i >= j
+ i > j
+ i ~= j
+ s1 << s2
+ s1 == s2
+ s1 >>= s2
+ s1 >> s2
+ s1 ~== s2
+ x === y
+ x ~=== y
+ x | y
+ i to j
+ i to j by k
+ x := y
+ x <- y
+ x :=: y
+ x <-> y
+ i +:= j
+ i -:= j
+ i *:= j
+end
+
+procedure expr3()
+ i /:= j
+ i %:= j
+ i ^:= j
+ i <:= j
+ i <=:= j
+ i =:= j
+ i >=:= j
+ i ~=:= j
+ c1 ++:= c2
+ c1 --:= c2
+ c1 **:= c2
+ s1 ||:= s2
+ s1 <<:= s2
+ s1 <<=:= s2
+ s1 ==:= s2
+ s1 >>=:= s2
+ s1 >>:= s2
+ s1 ~==:= s2
+ s1 ?:= s2
+ a1 |||:= a2
+ x ===:= y
+ x ~===:= y
+ x &:= y
+ x @:= y
+ s ? x
+ x & y
+ create x
+ return
+ return x
+ suspend x
+ suspend x do y
+ fail
+end
+
+procedure expr4()
+ while e1 do break
+ while e1 do break e2
+ while e1 do next
+ case e of {
+ x: fail
+ (i > j) | 1 : return
+ }
+ case size(s) of {
+ 1: 1
+ default: fail
+ }
+ if e1 then e2
+ if e1 then e2 else e3
+ repeat e
+ while e1
+ while e1 do e2
+ until e1
+ until e1 do e2
+ every e1
+ every e1 do e2
+ x
+ X_
+ &cset
+ &null
+ "abc"
+ 'abc'
+ "\n"
+ "^a"
+ "\001"
+ "\x01"
+ 1
+ 999999
+ 36ra1
+ 3.5
+ 2.5e4
+ 4e-10
+end
diff --git a/tests/general/proto.std b/tests/general/proto.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/general/proto.std
diff --git a/tests/general/queens.icn b/tests/general/queens.icn
new file mode 100644
index 0000000..cd5b8dd
--- /dev/null
+++ b/tests/general/queens.icn
@@ -0,0 +1,98 @@
+#SRC: IPL
+
+############################################################################
+#
+# File: queens.icn
+#
+# Subject: Program to generate solutions to the n-queens problem
+#
+# Author: Stephen B. Wampler
+#
+# Date: June 10, 1988
+#
+############################################################################
+#
+# This file is in the public domain.
+#
+############################################################################
+#
+# This program displays the solutions to the non-attacking n-
+# queens problem: the ways in which n queens can be placed on an
+# n-by-n chessboard so that no queen can attack another. A positive
+# integer can be given as a command line argument to specify the
+# number of queens. For example,
+#
+# iconx queens -n8
+#
+# displays the solutions for 8 queens on an 8-by-8 chessboard. The
+# default value in the absence of an argument is 6. One solution
+# for six queens is:
+#
+# -------------------------
+# | | Q | | | | |
+# -------------------------
+# | | | | Q | | |
+# -------------------------
+# | | | | | | Q |
+# -------------------------
+# | Q | | | | | |
+# -------------------------
+# | | | Q | | | |
+# -------------------------
+# | | | | | Q | |
+# -------------------------
+#
+# Comments: There are many approaches to programming solutions to
+# the n-queens problem. This program is worth reading for
+# its programming techniques.
+#
+############################################################################
+
+global n, solution
+
+procedure main(args)
+ local i, opts
+
+ n := integer(args[1]) | 6
+ if n <= 0 then stop("-n needs a positive numeric parameter")
+
+ solution := list(n) # ... and a list of column solutions
+ write(n,"-Queens:")
+ every q(1) # start by placing queen in first column
+end
+
+# q(c) - place a queen in column c.
+#
+procedure q(c)
+ local r
+ static up, down, rows
+ initial {
+ up := list(2*n-1,0)
+ down := list(2*n-1,0)
+ rows := list(n,0)
+ }
+ every 0 = rows[r := 1 to n] = up[n+r-c] = down[r+c-1] &
+ rows[r] <- up[n+r-c] <- down[r+c-1] <- 1 do {
+ solution[c] := r # record placement.
+ if c = n then show()
+ else q(c + 1) # try to place next queen.
+ }
+end
+
+# show the solution on a chess board.
+#
+procedure show()
+ static count, line, border
+ initial {
+ count := 0
+ line := repl("| ",n) || "|"
+ border := repl("----",n) || "-"
+ }
+ write("solution: ", count+:=1)
+ write(" ", border)
+ every line[4*(!solution - 1) + 3] <- "Q" do {
+ write(" ", line)
+ write(" ", border)
+ }
+ write()
+end
diff --git a/tests/general/queens.std b/tests/general/queens.std
new file mode 100644
index 0000000..4d0d33b
--- /dev/null
+++ b/tests/general/queens.std
@@ -0,0 +1,61 @@
+6-Queens:
+solution: 1
+ -------------------------
+ | | Q | | | | |
+ -------------------------
+ | | | | Q | | |
+ -------------------------
+ | | | | | | Q |
+ -------------------------
+ | Q | | | | | |
+ -------------------------
+ | | | Q | | | |
+ -------------------------
+ | | | | | Q | |
+ -------------------------
+
+solution: 2
+ -------------------------
+ | | | Q | | | |
+ -------------------------
+ | | | | | | Q |
+ -------------------------
+ | | Q | | | | |
+ -------------------------
+ | | | | | Q | |
+ -------------------------
+ | Q | | | | | |
+ -------------------------
+ | | | | Q | | |
+ -------------------------
+
+solution: 3
+ -------------------------
+ | | | | Q | | |
+ -------------------------
+ | Q | | | | | |
+ -------------------------
+ | | | | | Q | |
+ -------------------------
+ | | Q | | | | |
+ -------------------------
+ | | | | | | Q |
+ -------------------------
+ | | | Q | | | |
+ -------------------------
+
+solution: 4
+ -------------------------
+ | | | | | Q | |
+ -------------------------
+ | | | Q | | | |
+ -------------------------
+ | Q | | | | | |
+ -------------------------
+ | | | | | | Q |
+ -------------------------
+ | | | | Q | | |
+ -------------------------
+ | | Q | | | | |
+ -------------------------
+
diff --git a/tests/general/random.icn b/tests/general/random.icn
new file mode 100644
index 0000000..2d37d1d
--- /dev/null
+++ b/tests/general/random.icn
@@ -0,0 +1,59 @@
+#SRC: JCON
+
+# test of random selection
+# (sets and tables are commented out because
+# v9 and jcon select different elements)
+
+record r10(a,b,c,d,e,f,g,h,i,j)
+
+procedure main()
+ local r
+
+ rtest()
+ r := &random
+
+ rtest()
+
+ &random := 0
+ rtest()
+
+ &random := r
+ rtest()
+
+ &random := 11213
+ rtest()
+end
+
+procedure rtest()
+ local i
+ static L, S, T, R
+ initial {
+ R := r10(1,2,3,4,5,6,7,8,9,10)
+ L := []
+ T := table()
+ every i := 1 to 100 do {
+ put(L, i)
+ T[i] := -i
+ }
+ S := set(L)
+ }
+
+ write()
+ write(right(&random,10), " i ", ?9999)
+ write(right(&random,10), " i ", ?9999)
+ write(right(&random,10), " r ", integer(10000 * ?0))
+ write(right(&random,10), " r ", integer(10000 * ?0))
+ write(right(&random,10), " s ", ?"abcdefghijklmnopqrstuvwxyz")
+ write(right(&random,10), " s ", ?"ABCDEFGHIJKLMNOPQRSTUVWXYZ")
+ write(right(&random,10), " c ", ?&lcase)
+ write(right(&random,10), " c ", ?&ucase)
+ write(right(&random,10), " L ", ?L)
+ write(right(&random,10), " L ", ?L)
+ write(right(&random,10), " R ", ?R)
+ write(right(&random,10), " R ", ?R)
+# write(right(&random,10), " S ", ?S)
+# write(right(&random,10), " S ", ?S)
+# write(right(&random,10), " T ", ?T)
+# write(right(&random,10), " T ", ?T)
+ return
+end
diff --git a/tests/general/random.std b/tests/general/random.std
new file mode 100644
index 0000000..8494dda
--- /dev/null
+++ b/tests/general/random.std
@@ -0,0 +1,65 @@
+
+ 0 i 2114
+ 453816694 i 4124
+ 885666996 r 3157
+ 678165018 r 5104
+1096161928 s k
+ 905669982 s H
+ 656467580 c c
+ 170957890 c T
+1583830416 L 6
+ 108920774 L 72
+1539632324 R 2
+ 295778538 R 4
+
+ 721762584 i 5331
+1144737966 i 6208
+1333202828 r 5762
+1237514258 r 7075
+1519504672 s t
+1583400982 s G
+ 507287252 c w
+1824883130 c I
+ 679975336 L 36
+ 764038654 L 90
+1931954844 R 9
+1814756834 R 1
+
+ 0 i 2114
+ 453816694 i 4124
+ 885666996 r 3157
+ 678165018 r 5104
+1096161928 s k
+ 905669982 s H
+ 656467580 c c
+ 170957890 c T
+1583830416 L 6
+ 108920774 L 72
+1539632324 R 2
+ 295778538 R 4
+
+ 721762584 i 5331
+1144737966 i 6208
+1333202828 r 5762
+1237514258 r 7075
+1519504672 s t
+1583400982 s G
+ 507287252 c w
+1824883130 c I
+ 679975336 L 36
+ 764038654 L 90
+1931954844 R 9
+1814756834 R 1
+
+ 11213 i 1721
+ 369479103 i 7573
+1626308041 r 3422
+ 734952971 r 9053
+1944172069 s z
+2101642551 s Q
+1364863969 c o
+1221979715 c E
+ 395152893 L 65
+1380138031 L 20
+ 425567097 R 2
+ 407906811 R 2
diff --git a/tests/general/recent.icn b/tests/general/recent.icn
new file mode 100644
index 0000000..946da1c
--- /dev/null
+++ b/tests/general/recent.icn
@@ -0,0 +1,291 @@
+procedure main ()
+ sf([])
+
+ write(args(main))
+ write(args(write))
+
+# show results of bitwise operations on various operand combinations
+
+ every i := 1 | '2' | "3" do {
+ write (
+ " i j ~j i & j i | j i ^ j i << j i >> j")
+ every j := 0 | 1 | 2 | 3 | 4 | 100 do {
+ write(right(i,8), right(j,9))
+ word (i)
+ word (j)
+ word (icom (j))
+ word (iand (i, j))
+ word (ior (i, j))
+ word (ixor (i, j))
+ word (ishift (i, j))
+ word (ishift (i, -j))
+ write ()
+ }
+ }
+
+# test remove() and rename(), and print errors in case of malfunction
+
+ name1 := "temp1"
+ name2 := "temp2"
+ data := "Here's the data"
+
+ every remove (name1 | name2) # just in case
+ open (name1) & stop ("can't remove ", name1, " to initialize test")
+ open (name2) & stop ("can't remove ", name2, " to initialize test")
+ remove (name1) & stop ("successfully removed nonexistent file")
+ rename (name1, name2) & stop ("successfully renamed nonexistent file")
+
+ f := open (name1, "w") | stop ("can't open ",name1," for write")
+ write (f, data)
+ close (f)
+
+ f := open (name1) | stop ("can't open ",name1," after write")
+ s := read (f) | ""
+ close(f)
+ s == data | stop ("data lost after write")
+
+ rename (name1, name2) | stop ("can't rename(",name1,",",name2,")")
+ f := open (name2) | stop ("can't open ",name2," after rename")
+ s := read (f) | ""
+ close(f)
+ s == data | stop ("data lost after rename")
+
+ remove (name1) & stop ("remove succeeded on file already renamed")
+ remove (name2) | stop ("can't remove renamed file")
+ open (name1) & stop (name1, " still around at end of test")
+ open (name2) & stop (name2, " still around at end of test")
+
+# test seek() and where()
+
+ f := open("concord.dat")
+ write(image(seek(f,11)))
+ write(where(f))
+ write(image(reads(f,10)))
+ write(where(f))
+ write(where(f))
+ seek(f,-2)
+ write(where(f))
+ write(image(reads(f,1)))
+ write(where(f))
+ close(f)
+
+# test ord() and char(), and print messages if wrong results
+
+ s := string (&cset)
+ every i := 0 to 255 do {
+ c := char (i)
+ n := ord (c)
+ if n ~= i | c ~== s[i+1] then
+ write ("oops -- ord/char failure at ",i)
+ }
+ if char("47") ~== char(47) then
+ write ("oops -- type conversion failed in char()")
+ if ord(9) ~= ord("9") then
+ write ("oops -- type conversion failed in ord()")
+
+ every ferr (char, -65536 | -337 | -1 | 256 | 4713 | 65536 | 123456, 205)
+ every ferr (char, "abc" | &lcase | &errout | [], 101)
+ every ferr (ord, "" | "ab" | "antidisestablishmentarianism" | 47, 205)
+ every ferr (ord, &output | table(), 103)
+
+# test getenv()
+
+ write("getenv $HOME ", if getenv("HOME") then "succeeded" else "failed")
+ write("getenv $FOOBAR ", if getenv("FOOBAR") then "succeeded" else "failed")
+
+# test open(directory)
+
+ f := open(".") | stop("can't open `.'")
+ fset := set()
+ # try three kinds of reading in rotation
+ while insert(fset, read(f)) do {
+ insert(fset, !f) # note just one per loop pass
+ insert(fset, reads(f, 25)) # assumes no name longer than 25
+ }
+ every s := ![".", "..", "Makefile", "recent.icn", "recogn.dat", "nope"] do
+ if member(fset, s) then
+ write("found file: ", s)
+
+# test sorting
+
+ a := list(1) # different sizes to make identification easy
+ b := list(2)
+ c := list(3)
+ d := list(4)
+ e := &lcase ++ &ucase
+ f := &lcase ++ &ucase
+ g := '123456789'
+ h := &digits
+ A := sort([h,g,a,c,b,d,f,e,&lcase,[],&cset,&ascii])
+ every write(image(!A))
+
+# test varargs
+
+ write("p(1):")
+ p(1)
+ write("p(1, 2):")
+ p(1, 2)
+ write("p(1, 2, 3):")
+ p(1, 2, 3)
+ write("p(1, 2, 3, 4, 5):")
+ p(1, 2, 3, 4, 5)
+ write("q(1, 2):")
+ q(1, 2)
+
+# test Version 7 table features
+
+ write("t := table(\"default\") --> ", image(t := table("default")) |
+ "failure")
+ show(t)
+ write("insert(t, 3, 4) --> ", image(insert(t, 3, 4)) | "failure")
+ write("insert(t, \"xyz\", \"abc\") --> ", image(insert(t, "xyz", "abc")) |
+ "failure")
+ write("insert(t, &digits) --> ", image(insert(t, &digits)) | "failure")
+ show(t)
+ write("t[\"xyz\"] := \"new value\" --> ", image(t["xyz"] := "new value") |
+ "failure")
+ show(t)
+ write("insert(t, \"xyz\", \"def\") --> ", image(insert(t, "xyz", "def")) |
+ "failure")
+ show(t)
+ write("delete(t, \"xyz\") -- > ", image(delete(t, "xyz")) | "failure")
+ show(t)
+ write("delete(t, \"xyz\") -- > ", image(delete(t, "xyz")) | "failure")
+ show(t)
+
+# test multiple subscripts
+
+ write("t := table(\"default\") --> ", image(t := table("default")) |
+ "failure")
+ write("t[\"one\"] := 1 --> ", image(t["one"] := 1) | "failure")
+ write("t[] --> ", image(t[]) | "failure")
+ write("x := r1([t, [1, [2, 3]]]) --> ", image(x := r1([t, [1, [2, 3]]])) |
+ "failure")
+ write("x[1, 1, \"one\"] --> ", image(x[1, 1, "one"]) | "failure")
+ write("x[1, 2, 2, 2] --> ", image(x[1, 2, 2, 2]) | "failure")
+ write("x[1, 2] := [\"abcd\", \"defg\"] --> ",
+ image(x[1, 2] := ["abcd", "defg"]) | "failure")
+ write("x[1, 2, 2, 2] --> ", image(x[1, 2, 2, 2]) | "failure")
+
+# test run-time error mechanism
+
+end
+
+# write word in hexadecimal
+procedure word (v)
+ xd (v, 8)
+ writes (" ")
+ return
+ end
+
+# write n low-order hex digits of v
+procedure xd (v, n)
+ xd (ishift (v, -4), 0 < n - 1)
+ writes ("0123456789ABCDEF" [1 + iand (v, 16r0F)])
+ return
+ end
+# ferr(func,val,err) -- call func(val) and verify that error "err" is produced
+
+procedure ferr (func, val, err)
+ write(msg := "oops -- " || image(func) || "(" || image (val) || ") ")
+ return
+end
+
+procedure p(a, b, c[])
+ write(" image(a):", image(a))
+ write(" image(b):", image(b))
+ write(" image(c):", image(c))
+ write(" every write(\"\\t\", !c):")
+ every write("\t", !c)
+end
+
+procedure q(a[])
+ write(" every write(\"\\t\", !a):")
+ every write("\t", !a)
+end
+procedure show(t)
+ local x
+
+ write(" *t --> ", *t)
+ write(" t[\"xyz\"] --> ", image(t["xyz"]) | "failure")
+ write(" member(t, \"xyz\") --> ", image(member(t, "xyz")) | "failure")
+ x := sort(t, 3)
+ write(" contents of t:")
+ while writes("\t", image(get(x)), " : ")
+ do write(image(get(x)))
+ write("")
+end
+
+# test the new sortf(x,n) function
+
+global data
+record r1(a)
+record r3(a,b,c)
+
+procedure sf (args)
+ local n, z
+
+ z := []
+ every put (z, 1 to 100)
+ data := [
+ r3(3,1,4),
+ [1,5,9],
+ r3(2,6,5),
+ r3(3,5),
+ r1(2),
+ 3,
+ r1(4),
+ r1(8),
+ [5,&null,5],
+ [4,4,4,4],
+ [3,3,3],
+ [&null,25],
+ 4,
+ [2,2],
+ [1],
+ [&null,&null],
+ [],
+ r3(7,8,9),
+ z]
+ dump ("sort(L)", sort (data))
+
+ if *args = 0 then
+ every test (&null | 1 | "2" | '3' | 4 | 17 | -4 | -3 | "-2" | -1)
+ else
+ every test (!args)
+ end
+
+procedure test (n)
+ local r1, r2
+ write ()
+ write ("-------------------- testing n = ", \n | "&null")
+ r1 := sortf (data, n)
+ r2 := sortf (set(data), n)
+ dump ("sortf(L,n)", r1)
+ if same (r1, r2) then
+ write ("\nsortf(S,n) [same]")
+ else
+ dump ("sortf(S,n) [********** OOPS -- results differ: **********]", r2)
+ end
+
+procedure dump (s, l)
+ local e
+ write ()
+ write (s, ":")
+ every e := !l do {
+ writes (" ", left(type(e), 8))
+ if (type(e) == ("r1" | "r3" | "list")) then
+ every writes (" ", image(e[(1 to 5) | (95 to 100)]) | "\n")
+ else
+ write (" ", image(e))
+ }
+ return
+ end
+
+procedure same (a, b)
+ local i
+ if *a ~= *b then fail
+ every i := 1 to *a do
+ if a[i] ~=== b[i] then fail
+ return
+ end
diff --git a/tests/general/recent.std b/tests/general/recent.std
new file mode 100644
index 0000000..e4b6a03
--- /dev/null
+++ b/tests/general/recent.std
@@ -0,0 +1,443 @@
+
+sort(L):
+ integer 3
+ integer 4
+ list 1 2 3 4 5 95 96 97 98 99 100
+ list 1 5 9
+ list 5 &null 5
+ list 4 4 4 4
+ list 3 3 3
+ list &null 25
+ list 2 2
+ list 1
+ list &null &null
+ list
+ r1 2
+ r1 4
+ r1 8
+ r3 3 1 4
+ r3 2 6 5
+ r3 3 5 &null
+ r3 7 8 9
+
+-------------------- testing n = &null
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list
+ list &null 25
+ list &null &null
+ list 1 2 3 4 5 95 96 97 98 99 100
+ list 1 5 9
+ list 1
+ list 2 2
+ list 3 3 3
+ list 4 4 4 4
+ list 5 &null 5
+ r1 2
+ r3 2 6 5
+ r3 3 1 4
+ r3 3 5 &null
+ r1 4
+ r3 7 8 9
+ r1 8
+
+sortf(S,n) [same]
+
+-------------------- testing n = 1
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list
+ list &null 25
+ list &null &null
+ list 1 2 3 4 5 95 96 97 98 99 100
+ list 1 5 9
+ list 1
+ list 2 2
+ list 3 3 3
+ list 4 4 4 4
+ list 5 &null 5
+ r1 2
+ r3 2 6 5
+ r3 3 1 4
+ r3 3 5 &null
+ r1 4
+ r3 7 8 9
+ r1 8
+
+sortf(S,n) [same]
+
+-------------------- testing n = 2
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list 1
+ list
+ list 5 &null 5
+ list &null &null
+ list 1 2 3 4 5 95 96 97 98 99 100
+ list 2 2
+ list 3 3 3
+ list 4 4 4 4
+ list 1 5 9
+ list &null 25
+ r1 2
+ r1 4
+ r1 8
+ r3 3 1 4
+ r3 3 5 &null
+ r3 2 6 5
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = 3
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list &null 25
+ list 2 2
+ list 1
+ list &null &null
+ list
+ list 1 2 3 4 5 95 96 97 98 99 100
+ list 3 3 3
+ list 4 4 4 4
+ list 5 &null 5
+ list 1 5 9
+ r1 2
+ r1 4
+ r1 8
+ r3 3 5 &null
+ r3 3 1 4
+ r3 2 6 5
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = 4
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list 1 5 9
+ list 5 &null 5
+ list 3 3 3
+ list &null 25
+ list 2 2
+ list 1
+ list &null &null
+ list
+ list 1 2 3 4 5 95 96 97 98 99 100
+ list 4 4 4 4
+ r1 2
+ r1 4
+ r1 8
+ r3 3 1 4
+ r3 2 6 5
+ r3 3 5 &null
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = 17
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list 1 5 9
+ list 5 &null 5
+ list 4 4 4 4
+ list 3 3 3
+ list &null 25
+ list 2 2
+ list 1
+ list &null &null
+ list
+ list 1 2 3 4 5 95 96 97 98 99 100
+ r1 2
+ r1 4
+ r1 8
+ r3 3 1 4
+ r3 2 6 5
+ r3 3 5 &null
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = -4
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list 1 5 9
+ list 5 &null 5
+ list 3 3 3
+ list &null 25
+ list 2 2
+ list 1
+ list &null &null
+ list
+ list 4 4 4 4
+ list 1 2 3 4 5 95 96 97 98 99 100
+ r1 2
+ r1 4
+ r1 8
+ r3 3 1 4
+ r3 2 6 5
+ r3 3 5 &null
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = -3
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list &null 25
+ list 2 2
+ list 1
+ list &null &null
+ list
+ list 1 5 9
+ list 3 3 3
+ list 4 4 4 4
+ list 5 &null 5
+ list 1 2 3 4 5 95 96 97 98 99 100
+ r1 2
+ r1 4
+ r1 8
+ r3 2 6 5
+ r3 3 1 4
+ r3 3 5 &null
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = -2
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list 1
+ list
+ list 5 &null 5
+ list &null 25
+ list &null &null
+ list 2 2
+ list 3 3 3
+ list 4 4 4 4
+ list 1 5 9
+ list 1 2 3 4 5 95 96 97 98 99 100
+ r1 2
+ r1 4
+ r1 8
+ r3 3 1 4
+ r3 3 5 &null
+ r3 2 6 5
+ r3 7 8 9
+
+sortf(S,n) [same]
+
+-------------------- testing n = -1
+
+sortf(L,n):
+ integer 3
+ integer 4
+ list
+ list &null &null
+ list 1
+ list 2 2
+ list 3 3 3
+ list 4 4 4 4
+ list 5 &null 5
+ list 1 5 9
+ list &null 25
+ list 1 2 3 4 5 95 96 97 98 99 100
+ r3 3 5 &null
+ r1 2
+ r1 4
+ r3 3 1 4
+ r3 2 6 5
+ r1 8
+ r3 7 8 9
+
+sortf(S,n) [same]
+0
+-1
+ i j ~j i & j i | j i ^ j i << j i >> j
+ 1 0
+00000001 00000000 FFFFFFFF 00000000 00000001 00000001 00000001 00000001
+ 1 1
+00000001 00000001 FFFFFFFE 00000001 00000001 00000000 00000002 00000000
+ 1 2
+00000001 00000002 FFFFFFFD 00000000 00000003 00000003 00000004 00000000
+ 1 3
+00000001 00000003 FFFFFFFC 00000001 00000003 00000002 00000008 00000000
+ 1 4
+00000001 00000004 FFFFFFFB 00000000 00000005 00000005 00000010 00000000
+ 1 100
+00000001 00000064 FFFFFF9B 00000000 00000065 00000065 00000000 00000000
+ i j ~j i & j i | j i ^ j i << j i >> j
+ 2 0
+00000002 00000000 FFFFFFFF 00000000 00000002 00000002 00000002 00000002
+ 2 1
+00000002 00000001 FFFFFFFE 00000000 00000003 00000003 00000004 00000001
+ 2 2
+00000002 00000002 FFFFFFFD 00000002 00000002 00000000 00000008 00000000
+ 2 3
+00000002 00000003 FFFFFFFC 00000002 00000003 00000001 00000010 00000000
+ 2 4
+00000002 00000004 FFFFFFFB 00000000 00000006 00000006 00000020 00000000
+ 2 100
+00000002 00000064 FFFFFF9B 00000000 00000066 00000066 00000000 00000000
+ i j ~j i & j i | j i ^ j i << j i >> j
+ 3 0
+00000003 00000000 FFFFFFFF 00000000 00000003 00000003 00000003 00000003
+ 3 1
+00000003 00000001 FFFFFFFE 00000001 00000003 00000002 00000006 00000001
+ 3 2
+00000003 00000002 FFFFFFFD 00000002 00000003 00000001 0000000C 00000000
+ 3 3
+00000003 00000003 FFFFFFFC 00000003 00000003 00000000 00000018 00000000
+ 3 4
+00000003 00000004 FFFFFFFB 00000000 00000007 00000007 00000030 00000000
+ 3 100
+00000003 00000064 FFFFFF9B 00000000 00000067 00000067 00000000 00000000
+file(concord.dat)
+11
+"eoptera, ("
+21
+21
+1212
+"."
+1213
+oops -- function char(-65536)
+oops -- function char(-337)
+oops -- function char(-1)
+oops -- function char(256)
+oops -- function char(4713)
+oops -- function char(65536)
+oops -- function char(123456)
+oops -- function char("abc")
+oops -- function char(&lcase)
+oops -- function char(&errout)
+oops -- function char(list_34(0))
+oops -- function ord("")
+oops -- function ord("ab")
+oops -- function ord("antidisestablishmentarianism")
+oops -- function ord(47)
+oops -- function ord(&output)
+oops -- function ord(table_1(0))
+getenv $HOME succeeded
+getenv $FOOBAR failed
+found file: .
+found file: ..
+found file: Makefile
+found file: recent.icn
+found file: recogn.dat
+&ascii
+&cset
+&digits
+'123456789'
+&letters
+&letters
+&lcase
+list_36(1)
+list_37(2)
+list_38(3)
+list_39(4)
+list_40(0)
+p(1):
+ image(a):1
+ image(b):&null
+ image(c):list_43(0)
+ every write("\t", !c):
+p(1, 2):
+ image(a):1
+ image(b):2
+ image(c):list_44(0)
+ every write("\t", !c):
+p(1, 2, 3):
+ image(a):1
+ image(b):2
+ image(c):list_45(1)
+ every write("\t", !c):
+ 3
+p(1, 2, 3, 4, 5):
+ image(a):1
+ image(b):2
+ image(c):list_46(3)
+ every write("\t", !c):
+ 3
+ 4
+ 5
+q(1, 2):
+ every write("\t", !a):
+ 1
+ 2
+t := table("default") --> table_2(0)
+ *t --> 0
+ t["xyz"] --> "default"
+ member(t, "xyz") --> failure
+ contents of t:
+
+insert(t, 3, 4) --> table_2(1)
+insert(t, "xyz", "abc") --> table_2(2)
+insert(t, &digits) --> table_2(3)
+ *t --> 3
+ t["xyz"] --> "abc"
+ member(t, "xyz") --> "xyz"
+ contents of t:
+ 3 : 4
+ "xyz" : "abc"
+ &digits : &null
+
+t["xyz"] := "new value" --> "new value"
+ *t --> 3
+ t["xyz"] --> "new value"
+ member(t, "xyz") --> "xyz"
+ contents of t:
+ 3 : 4
+ "xyz" : "new value"
+ &digits : &null
+
+insert(t, "xyz", "def") --> table_2(3)
+ *t --> 3
+ t["xyz"] --> "def"
+ member(t, "xyz") --> "xyz"
+ contents of t:
+ 3 : 4
+ "xyz" : "def"
+ &digits : &null
+
+delete(t, "xyz") -- > table_2(2)
+ *t --> 2
+ t["xyz"] --> "default"
+ member(t, "xyz") --> failure
+ contents of t:
+ 3 : 4
+ &digits : &null
+
+delete(t, "xyz") -- > table_2(2)
+ *t --> 2
+ t["xyz"] --> "default"
+ member(t, "xyz") --> failure
+ contents of t:
+ 3 : 4
+ &digits : &null
+
+t := table("default") --> table_3(0)
+t["one"] := 1 --> 1
+t[] --> "default"
+x := r1([t, [1, [2, 3]]]) --> record r1_4(1)
+x[1, 1, "one"] --> 1
+x[1, 2, 2, 2] --> 3
+x[1, 2] := ["abcd", "defg"] --> list_57(2)
+x[1, 2, 2, 2] --> "e"
diff --git a/tests/general/recogn.dat b/tests/general/recogn.dat
new file mode 100644
index 0000000..ff0c0c5
--- /dev/null
+++ b/tests/general/recogn.dat
@@ -0,0 +1,8 @@
+ac
+acx
+c
+eb
+aadcb
+abc
+cse
+f
diff --git a/tests/general/recogn.icn b/tests/general/recogn.icn
new file mode 100644
index 0000000..c55efd0
--- /dev/null
+++ b/tests/general/recogn.icn
@@ -0,0 +1,28 @@
+#
+# C F L R E C O G N I T I O N
+#
+
+# This program takes strings from standard input and determines
+# whether or not they are sentences in the language defined by <s>.
+
+procedure main()
+ local line
+ while line := read() do
+ if recogn(s,line) then write("accepted") else write("rejected")
+end
+
+procedure recogn(goal,text)
+ return text ? (goal() & pos(0))
+end
+
+# <s> ::= a <s> | <t> b | c
+
+procedure s()
+ suspend (="a" || s()) | (t() || ="b") | ="c"
+end
+
+# <t> ::= d <s> d | e | f
+
+procedure t()
+ suspend (="d" || s() || ="d") | ="e" | ="f"
+end
diff --git a/tests/general/recogn.std b/tests/general/recogn.std
new file mode 100644
index 0000000..678e954
--- /dev/null
+++ b/tests/general/recogn.std
@@ -0,0 +1,8 @@
+accepted
+rejected
+accepted
+accepted
+rejected
+rejected
+rejected
+rejected
diff --git a/tests/general/record.icn b/tests/general/record.icn
new file mode 100644
index 0000000..7fa6866
--- /dev/null
+++ b/tests/general/record.icn
@@ -0,0 +1,43 @@
+#SRC: JCON
+
+record simple(f)
+record rec(f1, f2)
+
+procedure main()
+ local a, b
+
+ a := rec()
+ a.f1 := 1
+ a.f2 := 2
+ write(a.f1, " ", a.f2)
+ a := rec(3)
+ a.f2 := 4
+ write(a.f1, " ", a.f2)
+ a := rec(5,6)
+ write(a.f1, " ", a.f2)
+ a.f1 := 7
+ a.f2 := 8
+ write(a.f1, " ", a.f2)
+ a := rec(9,10,11)
+ write(a.f1, " ", a.f2)
+ a := rec(11, 12)
+ every write(!a)
+ every !a := 13
+ write(a.f2)
+
+ b := simple(14)
+ write(?b)
+ ?b := 15
+ write(!b)
+
+ b := rec(3, 7)
+ every write(b[1 to 3])
+ every write(b["f" || (1 to 3)])
+
+ a := rec(1, 2)
+ b := rec(3, 4)
+ a.f1 +:= 10
+ a.f2 +:= 20
+ every !b +:= 70
+ every writes(" ", !a | !b | "\n")
+end
diff --git a/tests/general/record.std b/tests/general/record.std
new file mode 100644
index 0000000..93a1dbe
--- /dev/null
+++ b/tests/general/record.std
@@ -0,0 +1,15 @@
+1 2
+3 4
+5 6
+7 8
+9 10
+11
+12
+13
+14
+15
+3
+7
+3
+7
+ 11 22 73 74
diff --git a/tests/general/right.icn b/tests/general/right.icn
new file mode 100644
index 0000000..59679be
--- /dev/null
+++ b/tests/general/right.icn
@@ -0,0 +1,31 @@
+#SRC: JCON
+
+procedure main()
+
+ write(right("abc"))
+ write(right("def", ))
+ write(right("ghi", &null))
+ write(right("jkl", 2))
+ write(right("mno", 3))
+ write(right(237, 4))
+ write(right("stu", 5))
+ write(right("vwx", 6))
+
+ write(right("abc", 3, ))
+ write(right("def", , "."))
+ write(right("ghi", &null, "."))
+ write(right("jkl", 2, "."))
+ write(right("mno", 3, "."))
+ write(right(237, 4, "."))
+ write(right("stu", 5, "."))
+ write(right("vwx", 6, "."))
+
+ write(right("abc", 3, ))
+ write(right("def", , "<>"))
+ write(right("ghi", &null, "<>"))
+ write(right("jkl", 2, "<>"))
+ write(right("mno", 3, "<>"))
+ write(right(237, 4, "<>"))
+ write(right("stu", 5, "<>"))
+ write(right("vwx", 6, "<>"))
+end
diff --git a/tests/general/right.std b/tests/general/right.std
new file mode 100644
index 0000000..512d02f
--- /dev/null
+++ b/tests/general/right.std
@@ -0,0 +1,24 @@
+c
+f
+i
+kl
+mno
+ 237
+ stu
+ vwx
+abc
+f
+i
+kl
+mno
+.237
+..stu
+...vwx
+abc
+f
+i
+kl
+mno
+<237
+<>stu
+<><vwx
diff --git a/tests/general/roman.dat b/tests/general/roman.dat
new file mode 100644
index 0000000..396b5c9
--- /dev/null
+++ b/tests/general/roman.dat
@@ -0,0 +1,8 @@
+13
+4
+6
+0
+-4
+39
+3999
+4000
diff --git a/tests/general/roman.icn b/tests/general/roman.icn
new file mode 100644
index 0000000..5745b8a
--- /dev/null
+++ b/tests/general/roman.icn
@@ -0,0 +1,23 @@
+#
+# R O M A N N U M E R A L S
+#
+
+# This program takes Arabic numerals from standard input and writes
+# the corresponding Roman numerals to standard outout.
+
+procedure main()
+ local n
+ while n := read() do
+ write(roman(n) | "cannot convert")
+end
+
+procedure roman(n)
+ local arabic, result
+ static equiv
+ initial equiv := $<"","I","II","III","IV","V","VI","VII","VIII","IX"$>
+ integer(n) > 0 | fail
+ result := ""
+ every arabic := !n do
+ result := map(result,"IVXLCDM","XLCDM**") || equiv$<arabic+1$>
+ if find("*",result) then fail else return result
+end
diff --git a/tests/general/roman.std b/tests/general/roman.std
new file mode 100644
index 0000000..649e27b
--- /dev/null
+++ b/tests/general/roman.std
@@ -0,0 +1,8 @@
+XIII
+IV
+VI
+cannot convert
+cannot convert
+XXXIX
+MMMCMXCIX
+cannot convert
diff --git a/tests/general/scan.icn b/tests/general/scan.icn
new file mode 100644
index 0000000..2dfda41
--- /dev/null
+++ b/tests/general/scan.icn
@@ -0,0 +1,59 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write(" ----> ",image() | "none")
+ write("every write((\"badc\" | \"edgf\" | \"x\") ? write(upto(!&lcase))) ----> ",image(every write(("badc" | "edgf" | "x") ? write(upto(!&lcase)))) | "none")
+ write("every write(((\"aeiou\" | \"foobaz\") ? upto('dracula')) ? =(1 to 10)) ----> ",image(every write((("aeiou" | "foobaz") ? upto('dracula')) ? =(1 to 10))) | "none")
+ write("every write((1 to 10) ? move(1)) ----> ",image(every write((1 to 10) ? move(1))) | "none")
+ write("&subject := &pos ----> ",image(&subject := &pos) | "none")
+ write("&pos :=: &subject ----> ",image(&pos :=: &subject) | "none")
+ write("&pos ----> ",image(&pos) | "none")
+ write("&subject ----> ",image(&subject) | "none")
+ write("+1 ----> ",image(+1) | "none")
+ write("-1 ----> ",image(-1) | "none")
+end
+
+procedure p2()
+ write("?10 ----> ",image(?10) | "none")
+ write("?10 ----> ",image(?10) | "none")
+ write("?10 ----> ",image(?10) | "none")
+ write("~&cset ----> ",image(~&cset) | "none")
+ write("~&ascii ----> ",image(~&ascii) | "none")
+ write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
+ write("=\"a\" ----> ",image(="a") | "none")
+ write("=\"b\" ----> ",image(="b") | "none")
+ write("=\"d\" ----> ",image(="d") | "none")
+ write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
+end
+
+procedure p3()
+ write("while write(move(1)) ----> ",image(while write(move(1))) | "none")
+ write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
+ write("every write(tab(1 to 10)) ----> ",image(every write(tab(1 to 10))) | "none")
+ write("pos(0) ----> ",image(pos(0)) | "none")
+ write("pos(15) ----> ",image(pos(15)) | "none")
+ write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
+ write("pos(1) ----> ",image(pos(1)) | "none")
+ write("every write(\"abcdef\" ? tab(1 to 10)) ----> ",image(every write("abcdef" ? tab(1 to 10))) | "none")
+ write("every write(\"abcde\" ? while move(2) ? move(1)) ----> ",image(every write("abcde" ? while move(2) ? move(1))) | "none")
+ write("s := \"abcdef\" ----> ",image(s := "abcdef") | "none")
+ write("s ?:= move(3) ----> ",image(s ?:= move(3)) | "none")
+end
+
+procedure p4()
+ write("s := \"abcdef\" ----> ",image(s := "abcdef") | "none")
+ write("every write(s ?:= upto(&lcase)) ----> ",image(every write(s ?:= upto(&lcase))) | "none")
+ write("s := \"this is the time to work it all out\" ----> ",image(s := "this is the time to work it all out") | "none")
+ write("every write(s ? tab(find(\" \"))) ----> ",image(every write(s ? tab(find(" ")))) | "none")
+ write("s := \"xxxxxx\" ----> ",image(s := "xxxxxx") | "none")
+ write("every s ? write(=(\"a\" | \"x\")) ----> ",image(every s ? write(=("a" | "x"))) | "none")
+ write("\"abcdef\" ? (tab(0) & (while write(move(-1)))) ----> ",image("abcdef" ? (tab(0) & (while write(move(-1))))) | "none")
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+end
+
diff --git a/tests/general/scan.std b/tests/general/scan.std
new file mode 100644
index 0000000..a741545
--- /dev/null
+++ b/tests/general/scan.std
@@ -0,0 +1,133 @@
+ ----> &null
+2
+2
+1
+1
+4
+4
+3
+3
+2
+2
+1
+1
+4
+4
+3
+3
+1
+1
+every write(("badc" | "edgf" | "x") ? write(upto(!&lcase))) ----> none
+1
+5
+5
+every write((("aeiou" | "foobaz") ? upto('dracula')) ? =(1 to 10)) ----> none
+1
+2
+3
+4
+5
+6
+7
+8
+9
+1
+every write((1 to 10) ? move(1)) ----> none
+&subject := &pos ----> "1"
+&pos :=: &subject ----> 1
+&pos ----> 1
+&subject ----> "1"
++1 ----> 1
+-1 ----> -1
+?10 ----> 3
+?10 ----> 5
+?10 ----> 4
+~&cset ----> ''
+~&ascii ----> '\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff'
+&subject := string(&lcase) ----> "abcdefghijklmnopqrstuvwxyz"
+="a" ----> "a"
+="b" ----> "b"
+="d" ----> none
+&subject := string(&lcase) ----> "abcdefghijklmnopqrstuvwxyz"
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+while write(move(1)) ----> none
+&subject := string(&lcase) ----> "abcdefghijklmnopqrstuvwxyz"
+
+a
+ab
+abc
+abcd
+abcde
+abcdef
+abcdefg
+abcdefgh
+abcdefghi
+every write(tab(1 to 10)) ----> none
+pos(0) ----> none
+pos(15) ----> none
+&subject := string(&lcase) ----> "abcdefghijklmnopqrstuvwxyz"
+pos(1) ----> 1
+
+a
+ab
+abc
+abcd
+abcde
+abcdef
+every write("abcdef" ? tab(1 to 10)) ----> none
+every write("abcde" ? while move(2) ? move(1)) ----> none
+s := "abcdef" ----> "abcdef"
+s ?:= move(3) ----> "abc"
+s := "abcdef" ----> "abcdef"
+1
+2
+3
+4
+5
+6
+every write(s ?:= upto(&lcase)) ----> none
+s := "this is the time to work it all out" ----> "this is the time to work it all out"
+this
+this is
+this is the
+this is the time
+this is the time to
+this is the time to work
+this is the time to work it
+this is the time to work it all
+every write(s ? tab(find(" "))) ----> none
+s := "xxxxxx" ----> "xxxxxx"
+x
+every s ? write(=("a" | "x")) ----> none
+f
+e
+d
+c
+b
+a
+"abcdef" ? (tab(0) & (while write(move(-1)))) ----> none
diff --git a/tests/general/scan1.icn b/tests/general/scan1.icn
new file mode 100644
index 0000000..cdc55d5
--- /dev/null
+++ b/tests/general/scan1.icn
@@ -0,0 +1,84 @@
+#SRC: JCON
+
+procedure main()
+ local skips, vowels, uppers
+
+ write(any('ab', "1234ab", 0, 7) | "fail")
+ write(any('ab', "1234ab", 7, 0) | "fail")
+ write(any('ab', "1234ab", 6, 0) | "fail")
+ write(any('ab', "1234ab", 6) | "fail")
+ write(any('ab', "1234ab") | "fail")
+ "1234ab" ? write(any('ab', "1234ab") | "fail")
+ "1234ab" ? write(any('ab') | "fail")
+ "1234ab" ? { &pos := 6 & write(any('ab') | "fail") }
+ write()
+
+ write(many('ab', "ababac") | "fail")
+ write(many('ab', "ababab") | "fail")
+ write(many('ab', "cababab") | "fail")
+ write()
+
+ write(match("ab", "ababab") | "fail")
+ write(match("ab", "bbabab") | "fail")
+ write(match("ab", "ab") | "fail")
+ write(match("ab", "a") | "fail")
+ write()
+
+ every write(find("ab", "ababab"|"ababa"|"ab"|"a"|"") | "done")
+ write()
+
+ every write(upto('ab', "abccab"|"cbabc"|"ab"|"a"|"") | "done")
+ write()
+
+ "123456" ? write(move(1), " ", move(2))
+ "123456" ? { write(move(1)); write(move(2)); write(move(3));
+ write(move(4)); write(move(-4))}
+ write()
+
+ "123456" ? write(tab(1), " ", tab(2))
+ "123456" ? { write(tab(2)); write(tab(4)); write(tab(-1)); write(tab(0)); }
+ "123456" ? { write(tab(4)); write(tab(1)); write(tab(3)); }
+ write()
+
+ every write("-35" ? bal('-'))
+ every write("((2*x)+3)+(5*y)" ? bal('+'))
+ every write("[+,[2,3]],[*,[5,10]]" ? bal(',', '[', ']'))
+ write()
+
+ "12345" ? { write(pos(1)); write(pos(-5)); write(pos(3)|"fail"); }
+ write()
+
+ "12345" ? { write(="123" | "fail") }
+ "12345" ? { tab(2); write(="123" | "fail") }
+ "12345" ? { tab(2); write(="23" | "fail") }
+
+ # test upto, including some chars with 8th bit set
+ write()
+ skips := '\x00\x0f\x1e-<KZix\x87\x96\xa5\xb4\xc3\xd2\xe1\xf0\xff'
+ vowels := 'aeoiuAEIOU'
+ uppers := &cset -- &ascii
+ &ascii ? {
+ every writes(" ", "ascii?skips" | upto(skips) | "\n")
+ every writes(" ", "ascii?vowls" | upto(vowels) | "\n")
+ }
+ &letters ? {
+ every writes(" ", "letts?skips" | upto(skips) | "\n")
+ every writes(" ", "letts?vowls" | upto(vowels) | "\n")
+ }
+ vowels ? {
+ every writes(" ", "vowls?skips" | upto(skips) | "\n")
+ every writes(" ", "vowls?letts" | upto(&letters) | "\n")
+ every writes(" ", "vowls?ascii" | upto(&ascii) | "\n")
+ }
+ skips ? {
+ every writes(" ", "skips?vowls" | upto(vowels) | "\n")
+ every writes(" ", "skips?letts" | upto(&letters) | "\n")
+ every writes(" ", "skips?ascii" | upto(&ascii) | "\n")
+ every writes(" ", "skips?upprs" | upto(uppers) | "\n")
+ every writes(" ", "skips?skips" | upto(skips) | "\n")
+ }
+ uppers ? {
+ every writes(" ", "upprs?ascii" | upto(&ascii) | "\n")
+ every writes(" ", "upprs?skips" | upto(skips) | "\n")
+ }
+end
diff --git a/tests/general/scan1.std b/tests/general/scan1.std
new file mode 100644
index 0000000..e86186b
--- /dev/null
+++ b/tests/general/scan1.std
@@ -0,0 +1,79 @@
+fail
+fail
+7
+7
+fail
+fail
+fail
+7
+
+6
+7
+fail
+
+3
+fail
+3
+fail
+
+1
+3
+5
+1
+3
+1
+done
+
+1
+2
+5
+6
+2
+3
+4
+1
+2
+1
+done
+
+1 23
+1
+23
+456
+3456
+
+ 1
+1
+23
+45
+6
+123
+123
+12
+
+1
+10
+10
+
+1
+1
+fail
+
+123
+fail
+23
+
+ ascii?skips 1 16 31 46 61 76 91 106 121
+ ascii?vowls 66 70 74 80 86 98 102 106 112 118
+ letts?skips 11 26 35 50
+ letts?vowls 1 5 9 15 21 27 31 35 41 47
+ vowls?skips 8
+ vowls?letts 1 2 3 4 5 6 7 8 9 10
+ vowls?ascii 1 2 3 4 5 6 7 8 9 10
+ skips?vowls 8
+ skips?letts 6 7 8 9
+ skips?ascii 1 2 3 4 5 6 7 8 9
+ skips?upprs 10 11 12 13 14 15 16 17 18
+ skips?skips 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
+ upprs?ascii
+ upprs?skips 8 23 38 53 68 83 98 113 128
diff --git a/tests/general/scan2.icn b/tests/general/scan2.icn
new file mode 100644
index 0000000..e9b2750
--- /dev/null
+++ b/tests/general/scan2.icn
@@ -0,0 +1,51 @@
+#SRC: JCON
+
+# test maintenance of scanning environments.
+
+procedure main()
+ write("simple")
+ "fghjkl" ? {
+ write(tab(3))
+ write(&pos)
+ write(tab(5))
+ }
+ write("nested")
+ "123456" ? {
+ write(tab(3))
+ "abcdef" ? {
+ write(tab(3))
+ write(&pos)
+ write(tab(5))
+ }
+ write(&pos)
+ write(tab(5))
+ }
+
+ write("break")
+ every write("98765" ? repeat break upto(&digits))
+
+ write("nested break")
+ every write("12345" ? repeat { "67890" ? { write(move(1)); break upto(&digits)}})
+
+ write("next")
+ every write("98765" ? { every 1 do { "mnbv" ? next }; write(move(2))})
+
+ write("non-local")
+ "qwerty" ? {
+ every write(foo()) do write(move(1))
+ }
+
+ "abcdef" ? {
+ write(&pos)
+ every ="abc" do {
+ write(&pos)
+ }
+ write(&pos)
+ }
+end
+
+procedure foo()
+ suspend move(1)
+ "zxc" ? suspend upto(&lcase)
+ suspend upto(&lcase)
+end
diff --git a/tests/general/scan2.std b/tests/general/scan2.std
new file mode 100644
index 0000000..783eb3f
--- /dev/null
+++ b/tests/general/scan2.std
@@ -0,0 +1,45 @@
+simple
+fg
+3
+hj
+nested
+12
+ab
+3
+cd
+3
+34
+break
+1
+2
+3
+4
+5
+nested break
+6
+1
+2
+3
+4
+5
+next
+98
+98
+non-local
+q
+w
+1
+q
+2
+w
+3
+e
+4
+r
+5
+t
+6
+y
+1
+4
+1
diff --git a/tests/general/sets.icn b/tests/general/sets.icn
new file mode 100644
index 0000000..069b4f9
--- /dev/null
+++ b/tests/general/sets.icn
@@ -0,0 +1,81 @@
+#SRC: JCON
+
+# set test
+
+procedure main()
+ local x, y, z
+
+ wset("empty", x := set())
+ write(type(x))
+ write(image(?x)) # should fail
+ write(image(member(x))) # should fail
+ wset("insert", insert(x))
+ write(image(?x)) # should write &null
+ write(image(member(x))) # should write &null
+ write(image(member(x,3))) # should write &null
+ wset("insert", insert(x))
+ wset("delete", delete(x))
+ wset("delete", delete(x))
+ write()
+
+ wset("x", x := set([1,2,4]))
+ wset("y", y := set([1,2,5]))
+ wset("x ++ y", x ++ y)
+ wset("y ++ x", y ++ x)
+ wset("x -- y", x -- y)
+ wset("y -- x", y -- x)
+ wset("x ** y", x ** y)
+ wset("y ** x", y ** x)
+ write()
+
+ wset("empty", x := set(&null))
+ wset("+ 1", insert(x, 1,4,7)) # only inserts 1
+ wset("+ 2", insert(x, 2))
+ wset("+ c", insert(x, "c"))
+ wset("- 3", delete(x, 3)) # deletes nothing
+ wset("- 1", delete(x, 1, 2)) # only deletes 1
+ wset("- 1", delete(x, 1))
+ wset("+ 2", insert(x, 2))
+ wset("+ 1", insert(x, 1))
+ wset("+ 7.0", insert(x, 7.0))
+ wset("+ 7.0", insert(x, 7.0))
+ wset("+ 'cs'", insert(x, 'cs'))
+ wset("+ 'cs'", insert(x, 'cs'))
+ wset("x =", x)
+ write()
+
+ wset("3,a,4", y := set([3,"a",4]))
+ wset("y ++ x", y ++ x)
+ wset("y ** x", y ** x)
+ wset("y -- x", y -- x)
+ wset("x -- y", x -- y)
+ write()
+
+ every insert(z := set(), !y)
+ wset("z from !y", z)
+
+ write()
+ x := set([3,1,4,1,5,9,2,6,5,3,5])
+ y := copy(x)
+ delete(x, 4)
+ insert(x, 7)
+ insert(y, 0)
+ delete(y, 1)
+ wset("x", x)
+ wset("y", y)
+end
+
+
+
+# dump a set, assuming it contains nothing other than:
+# &null, 0 - 9, 0.0 - 9.0, "", "a" - "e", '', 'cs'
+
+procedure wset(label, S)
+ local x
+
+ writes(right(label, 10), " :", right(*S, 2), " :")
+ every x := &null | (0 to 9) | 0.0+(0 to 9) | "" | !"abcde" | '' | 'cs' do
+ writes(" ", image(member(S, x)))
+ write()
+ return
+end
diff --git a/tests/general/sets.std b/tests/general/sets.std
new file mode 100644
index 0000000..4209e0a
--- /dev/null
+++ b/tests/general/sets.std
@@ -0,0 +1,43 @@
+ empty : 0 :
+set
+ insert : 1 : &null
+&null
+&null
+ insert : 1 : &null
+ delete : 0 :
+ delete : 0 :
+
+ x : 3 : 1 2 4
+ y : 3 : 1 2 5
+ x ++ y : 4 : 1 2 4 5
+ y ++ x : 4 : 1 2 4 5
+ x -- y : 1 : 4
+ y -- x : 1 : 5
+ x ** y : 2 : 1 2
+ y ** x : 2 : 1 2
+
+ empty : 0 :
+ + 1 : 1 : 1
+ + 2 : 2 : 1 2
+ + c : 3 : 1 2 "c"
+ - 3 : 3 : 1 2 "c"
+ - 1 : 2 : 2 "c"
+ - 1 : 2 : 2 "c"
+ + 2 : 2 : 2 "c"
+ + 1 : 3 : 1 2 "c"
+ + 7.0 : 4 : 1 2 7.0 "c"
+ + 7.0 : 4 : 1 2 7.0 "c"
+ + 'cs' : 5 : 1 2 7.0 "c" 'cs'
+ + 'cs' : 5 : 1 2 7.0 "c" 'cs'
+ x = : 5 : 1 2 7.0 "c" 'cs'
+
+ 3,a,4 : 3 : 3 4 "a"
+ y ++ x : 8 : 1 2 3 4 7.0 "a" "c" 'cs'
+ y ** x : 0 :
+ y -- x : 3 : 3 4 "a"
+ x -- y : 5 : 1 2 7.0 "c" 'cs'
+
+ z from !y : 3 : 3 4 "a"
+
+ x : 7 : 1 2 3 5 6 7 9
+ y : 7 : 0 2 3 4 5 6 9
diff --git a/tests/general/sieve.icn b/tests/general/sieve.icn
new file mode 100644
index 0000000..8dba2a0
--- /dev/null
+++ b/tests/general/sieve.icn
@@ -0,0 +1,20 @@
+#
+# S I E V E O F E R A T O S T H E N E S
+#
+
+# This program illustrates the use of sets in implementing the
+# classical sieve algorithm for computing prime numbers.
+
+procedure main()
+ local limit, s, i
+ limit := 100
+ s := set()
+ every insert(s,1 to limit)
+ every member(s,i := 2 to limit) do
+ every delete(s,i + i to limit by i)
+ delete(s,1)
+ primes := sort(s)
+ write("There are ",*primes," primes in the first ",limit," integers.")
+ write("The primes are:")
+ every write(right(!primes,*limit + 1))
+end
diff --git a/tests/general/sieve.std b/tests/general/sieve.std
new file mode 100644
index 0000000..0a3c328
--- /dev/null
+++ b/tests/general/sieve.std
@@ -0,0 +1,27 @@
+There are 25 primes in the first 100 integers.
+The primes are:
+ 2
+ 3
+ 5
+ 7
+ 11
+ 13
+ 17
+ 19
+ 23
+ 29
+ 31
+ 37
+ 41
+ 43
+ 47
+ 53
+ 59
+ 61
+ 67
+ 71
+ 73
+ 79
+ 83
+ 89
+ 97
diff --git a/tests/general/sorting.icn b/tests/general/sorting.icn
new file mode 100644
index 0000000..944488c
--- /dev/null
+++ b/tests/general/sorting.icn
@@ -0,0 +1,234 @@
+#SRC: JCON
+
+# test sorting and copying
+
+procedure main(args)
+ listtest()
+ rectest()
+ tbltest()
+ copytest()
+ messtest()
+end
+
+
+
+# listtest() -- test sorting of lists and sets
+
+procedure listtest()
+ local n, x, S, L1, L2, L3
+
+ every n := (0 to 10) | 23 | 47 | 91 do {
+
+ write(n, ":")
+ S := set()
+ while *S < n do
+ insert(S, randval())
+
+ L1 := list()
+ every put (L1, !S)
+
+ L2 := sort(L1)
+ L3 := sort(set(L1))
+
+ check(L2, L3)
+
+ L2 := sort(copy(L1))
+ L3 := sort(copy(set(L1)))
+ check(L2, L3)
+
+ }
+end
+
+
+# rectest() -- test sorting of records
+
+record r0()
+record r1(a)
+record r2(a,b)
+record r5(a,b,c,d,e)
+
+procedure rectest()
+ write()
+ wlist(sort(r0()))
+ wlist(sort(copy(r0()),))
+ wlist(sort(r1(12)))
+ wlist(sort(r2(5,2)))
+ wlist(sort(r5(2,7,1,8,3)))
+ wlist(sort(r5(3,1,4,1,6)))
+ wlist(sort(r5("t","e","p","a","d")))
+ wlist(sort(copy(r5("t","e","p","a","d"))))
+ return
+end
+
+
+
+# tbltest() -- test sorting of tables
+
+procedure tbltest()
+ local T, L
+
+ T := table()
+ T[7] := "h"
+ T[2] := "a"
+ T[8] := "r"
+ T[0] := "e"
+ T[3] := "o"
+ T[6] := "s"
+ T[5] := "n"
+ T[1] := "t"
+ T[4] := "i"
+ T[9] := "d"
+
+ write()
+ L := sort(T); every writes(" ", *L | !!L | "\n")
+ L := sort(T, 1); every writes(" ", *L | !!L | "\n")
+ L := sort(T, 2); every writes(" ", *L | !!L | "\n")
+ L := sort(T, 3); every writes(" ", *L | !L | "\n")
+ L := sort(T, 4); every writes(" ", *L | !L | "\n")
+
+ T := copy(T)
+ L := sort(T); every writes(" ", *L | !!L | "\n")
+ L := sort(T, 1); every writes(" ", *L | !!L | "\n")
+ L := sort(T, 2); every writes(" ", *L | !!L | "\n")
+ L := sort(T, 3); every writes(" ", *L | !L | "\n")
+ L := sort(T, 4); every writes(" ", *L | !L | "\n")
+ return
+end
+
+
+
+# randval() -- return random integer, real, string, or cset value
+
+procedure randval()
+ return case ?4 of {
+ 1: ?999 # 000 - 999
+ 2: ?99 / 10.0 # 0.0 - 9.9
+ 3: ?&letters || ?&letters || ?&letters # "AAA" - "ZZZ"
+ 4: ?&digits ++ ?&letters ++ ?&letters # '0AA' - '9ZZ'
+ }
+end
+
+
+# check that two lists have identical components
+# and that they are in ascending order
+
+procedure check(a, b)
+ local i, ai, ai1, bi, d
+
+ if *a ~= *b then
+ stop("different sizes: ", image(a), " / ", image(b))
+ every i := 1 to *a do {
+ ai := a[i]
+ bi := b[i]
+ ai1 := a[i-1] | &null
+ if ai ~=== bi then
+ stop("element ", i, " differs")
+ if type(ai) === type(ai1) then {
+ case type(ai) of {
+ "integer": d := (ai1 > ai) | &null
+ "real": d := (ai1 > ai) | &null
+ "string": d := (ai1 >> ai) | &null
+ }
+ stop("element ", i, " out of order: ", image(\d))
+ }
+ }
+ return
+end
+
+
+# write list
+
+procedure wlist(L)
+ writes(*L, ":")
+ every writes(right(!L, 4) | "\n")
+ return
+end
+
+
+
+# test copy(), especially that copies are really distinct
+
+procedure copytest()
+ local L1, L2, S1, S2, T1, T2, R1, R2
+
+ write()
+
+ L1 := [1,2,3]
+ push(L1, L1)
+ L2 := copy(L1)
+ pull(L2)
+ put(L2, 4)
+ every writes(" ", "L1:" | image(!L1) | "\n")
+ every writes(" ", "L2:" | image(!L2) | "\n")
+
+ S1 := set([1,2,3])
+ insert(S1, S1)
+ S2 := copy(S1)
+ delete(S2, 2)
+ insert(S2, 5)
+ every writes(" ", "S1:" | image(!sort(S1)) | "\n")
+ every writes(" ", "S2:" | image(!sort(S2)) | "\n")
+
+ T1 := table()
+ T1[2] := "j"
+ T1[5] := "c"
+ T1[8] := "n"
+ T1[15] := T1
+ T2 := copy(T1)
+ delete(T2, 5)
+ insert(T2, 11, "t")
+ every writes(" ", "T1:" | image(!sort(T1,3)) | "\n")
+ every writes(" ", "T2:" | image(!sort(T2,3)) | "\n")
+
+ R1 := r5(1,3,5,7,9)
+ R2 := copy(R1)
+ R1.b := 4
+ R2.d := 6
+ every writes(" ", "R1:" | image(R1) | image(!sort(R1)) | "\n")
+ every writes(" ", "R2:" | image(R2) | image(!sort(R2)) | "\n")
+
+ return
+end
+
+
+
+# sort different types together
+
+procedure messtest()
+ local L1, L2, L3
+
+ write()
+ L1 := [
+ '', '0cs', 4.4, set(), 2.2, "a", &null, integer, wlist, "epsilons",
+ r0, "delta", push, "beta", table(5), [], write, '123cs', [3,4], -3^41,
+ image, insert(table(3),4,7), &input, 3.3, reverse, r1(1), [], table(4),
+ r5, r5(1,23), &null, create 1 | 2, 5.5, set([5,6]), "", r2(5,6), -7^23,
+ "epsilon", [1,2,3], r5(7,8,9), r2, &output, 4, , set([0,1,2]), 1,
+ r5(1,2,3), r1, check, create 3 | 4, serial, 'XYZcs', 1.1, r1(5), 5^28,
+ '1234cs', 5, r0(), read, "gamma", r5(4,5,6,7,8), 2, create 5 to 7,
+ table, r2(1,2), right, r0(), "alpha", messtest, &errout, 11^19,
+ listtest, "gamma", main, 3]
+ put(L1, L1)
+ L2 := copy(L1)
+ every put(L1, copy(!L2))
+
+ write()
+ every write(image(!sort(L1)))
+
+ wsortf(L1, 2)
+ wsortf(L1, -1)
+ return
+end
+
+procedure wsortf(L, n)
+ local e, s
+
+ write()
+ every e := !sortf(L,n) do {
+ s := image(e)
+ if (s ? =("list" | "record")) & not (s ?= "record constructor") then
+ writes("key=", image(e[n]), " ") # may fail
+ write(s)
+ }
+ return
+end
diff --git a/tests/general/sorting.std b/tests/general/sorting.std
new file mode 100644
index 0000000..e913513
--- /dev/null
+++ b/tests/general/sorting.std
@@ -0,0 +1,503 @@
+0:
+1:
+2:
+3:
+4:
+5:
+6:
+7:
+8:
+9:
+10:
+23:
+47:
+91:
+
+0:
+0:
+1: 12
+2: 2 5
+5: 1 2 3 7 8
+5: 1 1 3 4 6
+5: a d e p t
+5: a d e p t
+
+ 10 0 e 1 t 2 a 3 o 4 i 5 n 6 s 7 h 8 r 9 d
+ 10 0 e 1 t 2 a 3 o 4 i 5 n 6 s 7 h 8 r 9 d
+ 10 2 a 9 d 0 e 7 h 4 i 5 n 3 o 8 r 6 s 1 t
+ 20 0 e 1 t 2 a 3 o 4 i 5 n 6 s 7 h 8 r 9 d
+ 20 2 a 9 d 0 e 7 h 4 i 5 n 3 o 8 r 6 s 1 t
+ 10 0 e 1 t 2 a 3 o 4 i 5 n 6 s 7 h 8 r 9 d
+ 10 0 e 1 t 2 a 3 o 4 i 5 n 6 s 7 h 8 r 9 d
+ 10 2 a 9 d 0 e 7 h 4 i 5 n 3 o 8 r 6 s 1 t
+ 20 0 e 1 t 2 a 3 o 4 i 5 n 6 s 7 h 8 r 9 d
+ 20 2 a 9 d 0 e 7 h 4 i 5 n 3 o 8 r 6 s 1 t
+
+ L1: list_164(4) 1 2 3
+ L2: list_164(4) 1 2 4
+ S1: 1 2 3 set_57(4)
+ S2: 1 3 5 set_57(4)
+ T1: 2 "j" 5 "c" 8 "n" 15 table_3(4)
+ T2: 2 "j" 8 "n" 11 "t" 15 table_3(4)
+ R1: record r5_6(5) 1 4 5 7 9
+ R2: record r5_7(5) 1 3 5 6 9
+
+
+&null
+&null
+&null
+&null
+&null
+&null
+-36472996377170786403
+-36472996377170786403
+-27368747340080916343
+-27368747340080916343
+1
+1
+2
+2
+3
+3
+4
+4
+5
+5
+37252902984619140625
+37252902984619140625
+61159090448414546291
+61159090448414546291
+1.1
+1.1
+2.2
+2.2
+3.3
+3.3
+4.4
+4.4
+5.5
+5.5
+""
+""
+"a"
+"a"
+"alpha"
+"alpha"
+"beta"
+"beta"
+"delta"
+"delta"
+"epsilon"
+"epsilon"
+"epsilons"
+"epsilons"
+"gamma"
+"gamma"
+"gamma"
+"gamma"
+''
+''
+'0cs'
+'0cs'
+'1234cs'
+'1234cs'
+'123cs'
+'123cs'
+'XYZcs'
+'XYZcs'
+&errout
+&errout
+&input
+&input
+&output
+&output
+co-expression_2(0)
+co-expression_2(0)
+co-expression_3(0)
+co-expression_3(0)
+co-expression_4(0)
+co-expression_4(0)
+procedure check
+procedure check
+function image
+function image
+function integer
+function integer
+procedure listtest
+procedure listtest
+procedure main
+procedure main
+procedure messtest
+procedure messtest
+function push
+function push
+record constructor r0
+record constructor r0
+record constructor r1
+record constructor r1
+record constructor r2
+record constructor r2
+record constructor r5
+record constructor r5
+function read
+function read
+function reverse
+function reverse
+function right
+function right
+function serial
+function serial
+function table
+function table
+procedure wlist
+procedure wlist
+function write
+function write
+list_173(0)
+list_174(2)
+list_175(0)
+list_177(3)
+list_179(152)
+list_181(0)
+list_182(2)
+list_183(0)
+list_184(3)
+list_185(151)
+set_59(0)
+set_60(2)
+set_61(3)
+set_62(0)
+set_63(2)
+set_64(3)
+table_5(0)
+table_6(1)
+table_7(0)
+table_8(0)
+table_9(1)
+table_10(0)
+record r0_4(0)
+record r0_5(0)
+record r0_6(0)
+record r0_7(0)
+record r1_2(1)
+record r1_3(1)
+record r1_4(1)
+record r1_5(1)
+record r2_2(2)
+record r2_3(2)
+record r2_4(2)
+record r2_5(2)
+record r5_8(5)
+record r5_9(5)
+record r5_10(5)
+record r5_11(5)
+record r5_12(5)
+record r5_13(5)
+record r5_14(5)
+record r5_15(5)
+
+&null
+&null
+&null
+&null
+&null
+&null
+-36472996377170786403
+-36472996377170786403
+-27368747340080916343
+-27368747340080916343
+1
+1
+2
+2
+3
+3
+4
+4
+5
+5
+37252902984619140625
+37252902984619140625
+61159090448414546291
+61159090448414546291
+1.1
+1.1
+2.2
+2.2
+3.3
+3.3
+4.4
+4.4
+5.5
+5.5
+""
+""
+"a"
+"a"
+"alpha"
+"alpha"
+"beta"
+"beta"
+"delta"
+"delta"
+"epsilon"
+"epsilon"
+"epsilons"
+"epsilons"
+"gamma"
+"gamma"
+"gamma"
+"gamma"
+''
+''
+'0cs'
+'0cs'
+'1234cs'
+'1234cs'
+'123cs'
+'123cs'
+'XYZcs'
+'XYZcs'
+&errout
+&errout
+&input
+&input
+&output
+&output
+co-expression_2(0)
+co-expression_2(0)
+co-expression_3(0)
+co-expression_3(0)
+co-expression_4(0)
+co-expression_4(0)
+procedure check
+procedure check
+function image
+function image
+function integer
+function integer
+procedure listtest
+procedure listtest
+procedure main
+procedure main
+procedure messtest
+procedure messtest
+function push
+function push
+record constructor r0
+record constructor r0
+record constructor r1
+record constructor r1
+record constructor r2
+record constructor r2
+record constructor r5
+record constructor r5
+function read
+function read
+function reverse
+function reverse
+function right
+function right
+function serial
+function serial
+function table
+function table
+procedure wlist
+procedure wlist
+function write
+function write
+list_173(0)
+list_175(0)
+list_181(0)
+list_183(0)
+key=2 list_177(3)
+key=2 list_184(3)
+key=4 list_174(2)
+key=4 list_182(2)
+key='0cs' list_179(152)
+key='0cs' list_185(151)
+set_59(0)
+set_60(2)
+set_61(3)
+set_62(0)
+set_63(2)
+set_64(3)
+table_5(0)
+table_6(1)
+table_7(0)
+table_8(0)
+table_9(1)
+table_10(0)
+record r0_4(0)
+record r0_5(0)
+record r0_6(0)
+record r0_7(0)
+record r1_2(1)
+record r1_3(1)
+record r1_4(1)
+record r1_5(1)
+key=2 record r2_3(2)
+key=2 record r2_5(2)
+key=2 record r5_10(5)
+key=2 record r5_14(5)
+key=5 record r5_11(5)
+key=5 record r5_15(5)
+key=6 record r2_2(2)
+key=6 record r2_4(2)
+key=8 record r5_9(5)
+key=8 record r5_13(5)
+key=23 record r5_8(5)
+key=23 record r5_12(5)
+
+&null
+&null
+&null
+&null
+&null
+&null
+-36472996377170786403
+-36472996377170786403
+-27368747340080916343
+-27368747340080916343
+1
+1
+2
+2
+3
+3
+4
+4
+5
+5
+37252902984619140625
+37252902984619140625
+61159090448414546291
+61159090448414546291
+1.1
+1.1
+2.2
+2.2
+3.3
+3.3
+4.4
+4.4
+5.5
+5.5
+""
+""
+"a"
+"a"
+"alpha"
+"alpha"
+"beta"
+"beta"
+"delta"
+"delta"
+"epsilon"
+"epsilon"
+"epsilons"
+"epsilons"
+"gamma"
+"gamma"
+"gamma"
+"gamma"
+''
+''
+'0cs'
+'0cs'
+'1234cs'
+'1234cs'
+'123cs'
+'123cs'
+'XYZcs'
+'XYZcs'
+&errout
+&errout
+&input
+&input
+&output
+&output
+co-expression_2(0)
+co-expression_2(0)
+co-expression_3(0)
+co-expression_3(0)
+co-expression_4(0)
+co-expression_4(0)
+procedure check
+procedure check
+function image
+function image
+function integer
+function integer
+procedure listtest
+procedure listtest
+procedure main
+procedure main
+procedure messtest
+procedure messtest
+function push
+function push
+record constructor r0
+record constructor r0
+record constructor r1
+record constructor r1
+record constructor r2
+record constructor r2
+record constructor r5
+record constructor r5
+function read
+function read
+function reverse
+function reverse
+function right
+function right
+function serial
+function serial
+function table
+function table
+procedure wlist
+procedure wlist
+function write
+function write
+list_173(0)
+list_175(0)
+list_181(0)
+list_183(0)
+key=3 list_177(3)
+key=3 list_184(3)
+key=3 list_185(151)
+key=4 list_174(2)
+key=4 list_182(2)
+key=list_185(151) list_179(152)
+set_59(0)
+set_60(2)
+set_61(3)
+set_62(0)
+set_63(2)
+set_64(3)
+table_5(0)
+table_6(1)
+table_7(0)
+table_8(0)
+table_9(1)
+table_10(0)
+record r0_4(0)
+record r0_5(0)
+record r0_6(0)
+record r0_7(0)
+key=&null record r5_8(5)
+key=&null record r5_9(5)
+key=&null record r5_10(5)
+key=&null record r5_12(5)
+key=&null record r5_13(5)
+key=&null record r5_14(5)
+key=1 record r1_2(1)
+key=1 record r1_4(1)
+key=2 record r2_3(2)
+key=2 record r2_5(2)
+key=5 record r1_3(1)
+key=5 record r1_5(1)
+key=6 record r2_2(2)
+key=6 record r2_4(2)
+key=8 record r5_11(5)
+key=8 record r5_15(5)
diff --git a/tests/general/statics.icn b/tests/general/statics.icn
new file mode 100644
index 0000000..1b7dcce
--- /dev/null
+++ b/tests/general/statics.icn
@@ -0,0 +1,26 @@
+#SRC: JCON
+
+procedure main()
+ foo()
+ foo()
+ p()
+ p()
+end
+
+procedure foo()
+ static a
+
+ write(image(a))
+ a := 1;
+end
+
+
+procedure p()
+ static c
+ initial c := 0
+
+ c +:= 1
+
+ write(c)
+
+end
diff --git a/tests/general/statics.std b/tests/general/statics.std
new file mode 100644
index 0000000..60cb064
--- /dev/null
+++ b/tests/general/statics.std
@@ -0,0 +1,4 @@
+&null
+1
+1
+2
diff --git a/tests/general/string.icn b/tests/general/string.icn
new file mode 100644
index 0000000..960befc
--- /dev/null
+++ b/tests/general/string.icn
@@ -0,0 +1,128 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write(" ----> ",image() | "none")
+ write("s := \"abcd\" ----> ",image(s := "abcd") | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ||:= \"x\" ----> ",image(s ||:= "x") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ||:= \"xx\" ----> ",image(s ||:= "xx") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ||:= \"X\" ----> ",image(s ||:= "X") | "none")
+ write("s ----> ",image(s) | "none")
+end
+
+procedure p2()
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ||:= \"abc\" ----> ",image(s ||:= "abc") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ==:= \"x\" ----> ",image(s ==:= "x") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ==:= \"xx\" ----> ",image(s ==:= "xx") | "none")
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ==:= \"X\" ----> ",image(s ==:= "X") | "none")
+end
+
+procedure p3()
+ write("s ----> ",image(s) | "none")
+ write("s := \"x\" ----> ",image(s := "x") | "none")
+ write("s ==:= \"abc\" ----> ",image(s ==:= "abc") | "none")
+ write("s ----> ",image(s) | "none")
+ write("{s[1:2] := \"xx\";s} ----> ",image({s[1:2] := "xx";s}) | "none")
+ write("{s[-1:0] := \"\";s} ----> ",image({s[-1:0] := "";s}) | "none")
+ write("{s[1] := \"abc\";s} ----> ",image({s[1] := "abc";s}) | "none")
+ write("{s[1+:2] := \"y\";s} ----> ",image({s[1+:2] := "y";s}) | "none")
+ write("{s[2] :=: s[3];s} ----> ",image({s[2] :=: s[3];s}) | "none")
+ write("s[6] := \"t\" ----> ",image(s[6] := "t") | "none")
+ write("s[0-:6] := \"u\" ----> ",image(s[0-:6] := "u") | "none")
+end
+
+procedure p4()
+ write("{s[1:0] :=: s[0:1];s} ----> ",image({s[1:0] :=: s[0:1];s}) | "none")
+ write("\"x\" << \"x\" ----> ",image("x" << "x") | "none")
+ write("\"x\" << \"X\" ----> ",image("x" << "X") | "none")
+ write("\"X\" << \"x\" ----> ",image("X" << "x") | "none")
+ write("\"xx\" <<= \"xx\" ----> ",image("xx" <<= "xx") | "none")
+ write("\"xxx\" <<= \"xx\" ----> ",image("xxx" <<= "xx") | "none")
+ write("\"xx\" <<= \"xxx\" ----> ",image("xx" <<= "xxx") | "none")
+ write("\"x\" >>= \"x\" ----> ",image("x" >>= "x") | "none")
+ write("\"x\" >>= \"xx\" ----> ",image("x" >>= "xx") | "none")
+ write("\"xx\" >>= \"x\" ----> ",image("xx" >>= "x") | "none")
+ write("\"x\" >> \"x\" ----> ",image("x" >> "x") | "none")
+end
+
+procedure p5()
+ write("\"x\" >> \"X\" ----> ",image("x" >> "X") | "none")
+ write("\"X\" >> \"x\" ----> ",image("X" >> "x") | "none")
+ write("\"x\" == \"x\" ----> ",image("x" == "x") | "none")
+ write("\"x\" == \"X\" ----> ",image("x" == "X") | "none")
+ write("\"X\" == \"x\" ----> ",image("X" == "x") | "none")
+ write("\"x\" ~== \"x\" ----> ",image("x" ~== "x") | "none")
+ write("\"x\" ~== \"X\" ----> ",image("x" ~== "X") | "none")
+ write("\"X\" ~== \"x\" ----> ",image("X" ~== "x") | "none")
+ write("every i := 1 to 9 do write(integer(repl(\"2\",i))) ----> ",image(every i := 1 to 9 do write(integer(repl("2",i)))) | "none")
+ write("every i := 1 to 9 do write(repl(\"2\",i) + 1) ----> ",image(every i := 1 to 9 do write(repl("2",i) + 1)) | "none")
+end
+
+procedure p6()
+ write("every i := 1 to 30 do write(integer(repl(\"0\",i) || \"2\")) ----> ",image(every i := 1 to 30 do write(integer(repl("0",i) || "2"))) | "none")
+ write("every i := 1 to 30 do write((repl(\"0\",i) || \"2\") + 1) ----> ",image(every i := 1 to 30 do write((repl("0",i) || "2") + 1)) | "none")
+ write("c1 := 'abcde' ----> ",image(c1 := 'abcde') | "none")
+ write("c2 := 'aeuoi' ----> ",image(c2 := 'aeuoi') | "none")
+ write("c1 ++ c2 ----> ",image(c1 ++ c2) | "none")
+ write("c1 -- c2 ----> ",image(c1 -- c2) | "none")
+ write("c1 ** c2 ----> ",image(c1 ** c2) | "none")
+ write("2 ~=== +2 ----> ",image(2 ~=== +2) | "none")
+ write("3 ~=== *\"abc\" ----> ",image(3 ~=== *"abc") | "none")
+end
+
+procedure p7()
+ write("'abc' ~=== ('abc' ++ '') ----> ",image('abc' ~=== ('abc' ++ '')) | "none")
+ write("any('aeiou',&lcase) ----> ",image(any('aeiou',&lcase)) | "none")
+ write("any('aeiou',&ucase) ----> ",image(any('aeiou',&ucase)) | "none")
+ write("every write(any('aeiou',&lcase,1 to 5,10 to 20)) ----> ",image(every write(any('aeiou',&lcase,1 to 5,10 to 20))) | "none")
+ write("match(\"abc\",\"abcabcabcabc\") ----> ",image(match("abc","abcabcabcabc")) | "none")
+ write("match(\"abc\",\"xabcabcabcabc\") ----> ",image(match("abc","xabcabcabcabc")) | "none")
+ write("every write(match(\"abc\",\"xabcabcabcabc\",1 to 10,1 to 10)) ----> ",image(every write(match("abc","xabcabcabcabc",1 to 10,1 to 10))) | "none")
+ write("upto('56d&',&lcase) ----> ",image(upto('56d&',&lcase)) | "none")
+ write("upto('56d&',&ucase) ----> ",image(upto('56d&',&ucase)) | "none")
+ write("upto('56d&',&lcase,15) ----> ",image(upto('56d&',&lcase,15)) | "none")
+ write("many(&lcase,\"this is a Test\") ----> ",image(many(&lcase,"this is a Test")) | "none")
+end
+
+procedure p8()
+ write("many(&lcase,\"this is a Test\",5) ----> ",image(many(&lcase,"this is a Test",5)) | "none")
+ write("many(&lcase,\"this is a Test\",5,9) ----> ",image(many(&lcase,"this is a Test",5,9)) | "none")
+ write("find(\"aa\",\"xxaaaaaa\") ----> ",image(find("aa","xxaaaaaa")) | "none")
+ write("every write(find(\"aa\",\"xxaaaaaa\")) ----> ",image(every write(find("aa","xxaaaaaa"))) | "none")
+ write("every write(find(\"aa\",\"xxaaaaaa\",4,7)) ----> ",image(every write(find("aa","xxaaaaaa",4,7))) | "none")
+ write("bal('-','(',')',\"-35\") ----> ",image(bal('-','(',')',"-35")) | "none")
+ write("bal('+','(',')',\"((2*x)+3)+(5*y)\") ----> ",image(bal('+','(',')',"((2*x)+3)+(5*y)")) | "none")
+ write("every write(bal('+','(',')',\"((2*x)+3)+(5*y)\",1 to 10)) ----> ",image(every write(bal('+','(',')',"((2*x)+3)+(5*y)",1 to 10))) | "none")
+ write("bal('+','[','[',\"[[2*x[+3[+[5*y[\") ----> ",image(bal('+','[','[',"[[2*x[+3[+[5*y[")) | "none")
+ write("bal('+','([','])',\"([2*x)+3]+(5*y]\") ----> ",image(bal('+','([','])',"([2*x)+3]+(5*y]")) | "none")
+ write("bal(,,,\"()+()\") ----> ",image(bal(,,,"()+()")) | "none")
+end
+
+procedure p9()
+ write("bal(&cset,,,\"()+()\") ----> ",image(bal(&cset,,,"()+()")) | "none")
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+end
+
+global s
diff --git a/tests/general/string.std b/tests/general/string.std
new file mode 100644
index 0000000..03e469a
--- /dev/null
+++ b/tests/general/string.std
@@ -0,0 +1,215 @@
+ ----> &null
+s := "abcd" ----> "abcd"
+s := "x" ----> "x"
+s ||:= "x" ----> "xx"
+s ----> "xx"
+s := "x" ----> "x"
+s ||:= "xx" ----> "xxx"
+s ----> "xxx"
+s := "x" ----> "x"
+s ||:= "X" ----> "xX"
+s ----> "xX"
+s := "x" ----> "x"
+s ||:= "abc" ----> "xabc"
+s ----> "xabc"
+s := "x" ----> "x"
+s ==:= "x" ----> "x"
+s ----> "x"
+s := "x" ----> "x"
+s ==:= "xx" ----> none
+s ----> "x"
+s := "x" ----> "x"
+s ==:= "X" ----> none
+s ----> "x"
+s := "x" ----> "x"
+s ==:= "abc" ----> none
+s ----> "x"
+{s[1:2] := "xx";s} ----> "xx"
+{s[-1:0] := "";s} ----> "x"
+{s[1] := "abc";s} ----> "abc"
+{s[1+:2] := "y";s} ----> "yc"
+{s[2] :=: s[3];s} ----> "yc"
+s[6] := "t" ----> none
+s[0-:6] := "u" ----> none
+{s[1:0] :=: s[0:1];s} ----> "yc"
+"x" << "x" ----> none
+"x" << "X" ----> none
+"X" << "x" ----> "x"
+"xx" <<= "xx" ----> "xx"
+"xxx" <<= "xx" ----> none
+"xx" <<= "xxx" ----> "xxx"
+"x" >>= "x" ----> "x"
+"x" >>= "xx" ----> none
+"xx" >>= "x" ----> "x"
+"x" >> "x" ----> none
+"x" >> "X" ----> "X"
+"X" >> "x" ----> none
+"x" == "x" ----> "x"
+"x" == "X" ----> none
+"X" == "x" ----> none
+"x" ~== "x" ----> none
+"x" ~== "X" ----> "X"
+"X" ~== "x" ----> "x"
+2
+22
+222
+2222
+22222
+222222
+2222222
+22222222
+222222222
+every i := 1 to 9 do write(integer(repl("2",i))) ----> none
+3
+23
+223
+2223
+22223
+222223
+2222223
+22222223
+222222223
+every i := 1 to 9 do write(repl("2",i) + 1) ----> none
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+every i := 1 to 30 do write(integer(repl("0",i) || "2")) ----> none
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+3
+every i := 1 to 30 do write((repl("0",i) || "2") + 1) ----> none
+c1 := 'abcde' ----> 'abcde'
+c2 := 'aeuoi' ----> 'aeiou'
+c1 ++ c2 ----> 'abcdeiou'
+c1 -- c2 ----> 'bcd'
+c1 ** c2 ----> 'ae'
+2 ~=== +2 ----> none
+3 ~=== *"abc" ----> none
+'abc' ~=== ('abc' ++ '') ----> none
+any('aeiou',&lcase) ----> 2
+any('aeiou',&ucase) ----> none
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+6
+6
+6
+6
+6
+6
+6
+6
+6
+6
+6
+every write(any('aeiou',&lcase,1 to 5,10 to 20)) ----> none
+match("abc","abcabcabcabc") ----> 4
+match("abc","xabcabcabcabc") ----> none
+5
+5
+5
+5
+5
+5
+5
+8
+8
+8
+5
+5
+5
+8
+5
+8
+5
+8
+every write(match("abc","xabcabcabcabc",1 to 10,1 to 10)) ----> none
+upto('56d&',&lcase) ----> 4
+upto('56d&',&ucase) ----> none
+upto('56d&',&lcase,15) ----> none
+many(&lcase,"this is a Test") ----> 5
+many(&lcase,"this is a Test",5) ----> none
+many(&lcase,"this is a Test",5,9) ----> none
+find("aa","xxaaaaaa") ----> 3
+3
+4
+5
+6
+7
+every write(find("aa","xxaaaaaa")) ----> none
+4
+5
+every write(find("aa","xxaaaaaa",4,7)) ----> none
+bal('-','(',')',"-35") ----> 1
+bal('+','(',')',"((2*x)+3)+(5*y)") ----> 10
+10
+7
+7
+10
+every write(bal('+','(',')',"((2*x)+3)+(5*y)",1 to 10)) ----> none
+bal('+','[','[',"[[2*x[+3[+[5*y[") ----> none
+bal('+','([','])',"([2*x)+3]+(5*y]") ----> 10
+bal(,,,"()+()") ----> 1
+bal(&cset,,,"()+()") ----> 1
diff --git a/tests/general/string1.icn b/tests/general/string1.icn
new file mode 100644
index 0000000..6e6f927
--- /dev/null
+++ b/tests/general/string1.icn
@@ -0,0 +1,54 @@
+#SRC: JCON
+
+# string test -- including operations on string *constants*
+
+procedure main()
+ local s, t
+
+ s := "abcde"
+ write("type ", type(s))
+ write("*s ", *s)
+ write("s: ", s)
+ write("s: ", image(s))
+ every writes("!: " | !s | "\n")
+ every writes("1: " | s[1 to 5] | "\n")
+ every writes("0: " | s[0 to 7] | "\n")
+ every writes("-5: " | s[-5 to -1] | "\n")
+ every writes("-7: " | s[-7 to -0] | "\n")
+
+ write("s1: ", s[1:6]);
+ write("s2: ", s[1+:5]);
+ write("s3: ", s[1-:-5]);
+ write("s4: ", s[1:0]);
+ write("s5: ", s[-5:0]);
+ write("s6: ", s[6:1]);
+ write("s7: ", s[0:-5]);
+ write("s8: ", s[2:4]);
+ write("s9: ", s[-2:-4]);
+
+ write("k1: ","ABCDE"[1:6]);
+ write("k2: ","ABCDE"[1+:5]);
+ write("k3: ","ABCDE"[1-:-5]);
+ write("k4: ","ABCDE"[1:0]);
+ write("k5: ","ABCDE"[-5:0]);
+ write("k6: ","ABCDE"[6:1]);
+ write("k7: ","ABCDE"[0:-5]);
+ write("k8: ","ABCDE"[2:4]);
+ write("k9: ","ABCDE"[-2:-4]);
+
+ t := "abc" || "de"
+ write("t: ", image(t))
+ (s === t) | write("not ===")
+ (s ~=== t) & write("are ~===")
+
+ write("?x: ", ?"x")
+ write("?y: ", ?"yyyyyyyyyyy")
+ write("?z: ", ?"" | "nope") # should "nope"
+
+ write("c1: ", image("" || ""))
+ write("c2: ", image("a" || ""))
+ write("c3: ", image("" || "b"))
+ write("c4: ", image("cd" || "ef"))
+ write("c5: ", image(3.14 || 159))
+ write("c6: ", image('abc' || 'def'))
+end
diff --git a/tests/general/string1.std b/tests/general/string1.std
new file mode 100644
index 0000000..cb12e58
--- /dev/null
+++ b/tests/general/string1.std
@@ -0,0 +1,37 @@
+type string
+*s 5
+s: abcde
+s: "abcde"
+!: abcde
+1: abcde
+0: abcde
+-5: abcde
+-7: abcde
+s1: abcde
+s2: abcde
+s3: abcde
+s4: abcde
+s5: abcde
+s6: abcde
+s7: abcde
+s8: bc
+s9: bc
+k1: ABCDE
+k2: ABCDE
+k3: ABCDE
+k4: ABCDE
+k5: ABCDE
+k6: ABCDE
+k7: ABCDE
+k8: BC
+k9: BC
+t: "abcde"
+?x: x
+?y: y
+?z: nope
+c1: ""
+c2: "a"
+c3: "b"
+c4: "cdef"
+c5: "3.14159"
+c6: "abcdef"
diff --git a/tests/general/struct.icn b/tests/general/struct.icn
new file mode 100644
index 0000000..1463b74
--- /dev/null
+++ b/tests/general/struct.icn
@@ -0,0 +1,202 @@
+record array(a,b,c,d,e,f,g)
+
+procedure p1()
+ write(" ----> ",image() | "none")
+ write("list(0) ----> ",image(list(0)) | "none")
+ write("list(0,1) ----> ",image(list(0,1)) | "none")
+ write("list(1,1) ----> ",image(list(1,1)) | "none")
+ write("list(100,\"a\") ----> ",image(list(100,"a")) | "none")
+ write("table() ----> ",image(table()) | "none")
+ write("table(0) ----> ",image(table(0)) | "none")
+ write("a := [] ----> ",image(a := []) | "none")
+ write("every put(a,!&lcase) ----> ",image(every put(a,!&lcase)) | "none")
+ write("a1 := sort(a) ----> ",image(a1 := sort(a)) | "none")
+ write("every write(!a1) ----> ",image(every write(!a1)) | "none")
+end
+
+procedure p2()
+ write("sort(a1) ----> ",image(sort(a1)) | "none")
+ write("t := table() ----> ",image(t := table()) | "none")
+ write("every t[!&lcase] := 1 ----> ",image(every t[!&lcase] := 1) | "none")
+ write("sort(t) ----> ",image(sort(t)) | "none")
+ write("a := sort(t) ----> ",image(a := sort(t)) | "none")
+ write("every write((!a)[1]) ----> ",image(every write((!a)[1])) | "none")
+ write("every write((!a)[2]) ----> ",image(every write((!a)[2])) | "none")
+ write("set([1,0,1,0,1,0,1,0]) ----> ",image(set([1,0,1,0,1,0,1,0])) | "none")
+ write("set([]) ----> ",image(set([])) | "none")
+ write("s := set([1,2,3,4,5,6,7,8,9,10]) ----> ",image(s := set([1,2,3,4,5,6,7,8,9,10])) | "none")
+ write("*s ----> ",image(*s) | "none")
+end
+
+procedure p3()
+ write("every write(!sort(s)) ----> ",image(every write(!sort(s))) | "none")
+ write("*copy(s) ----> ",image(*copy(s)) | "none")
+ write("image(s) ----> ",image(image(s)) | "none")
+ write("type(s) ----> ",image(type(s)) | "none")
+ write("member(s,8) ----> ",image(member(s,8)) | "none")
+ write("member(s,\"8\") ----> ",image(member(s,"8")) | "none")
+ write("s := set([]) ----> ",image(s := set([])) | "none")
+ write("every insert(s,1 to 100) ----> ",image(every insert(s,1 to 100)) | "none")
+ write("*s ----> ",image(*s) | "none")
+ write("every delete(s,15 to 30) ----> ",image(every delete(s,15 to 30)) | "none")
+ write("*s ----> ",image(*s) | "none")
+end
+
+procedure p4()
+ write("every s1 := insert(set([]),!&lcase) ----> ",image(every s1 := insert(set([]),!&lcase)) | "none")
+ write("s2 := set([\"a\",\"aa\",\"ab\",\"b\",1,2,3,4]) ----> ",image(s2 := set(["a","aa","ab","b",1,2,3,4])) | "none")
+ write("s3 := s1 ++ s2 ----> ",image(s3 := s1 ++ s2) | "none")
+ write("s4 := s1 ** s2 ----> ",image(s4 := s1 ** s2) | "none")
+ write("s5 := s1 -- s2 ----> ",image(s5 := s1 -- s2) | "none")
+ write("*s3 ----> ",image(*s3) | "none")
+ write("*s4 ----> ",image(*s4) | "none")
+ write("*s5 ----> ",image(*s5) | "none")
+ write("t := table() ----> ",image(t := table()) | "none")
+ write("every t[1 | &output | &cset | [] | \"hello\" | main | 2 | table()] := ?100 ----> ",image(every t[1 | &output | &cset | [] | "hello" | main | 2 | table()] := ?100) | "none")
+ write("a := sort(t,3) ----> ",image(a := sort(t,3)) | "none")
+end
+
+procedure p5()
+ write("every i := 1 to *a - 1 by 2 do write(image(a[i]),\" \",a[i + 1]) ----> ",image(every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | "none")
+ write("a := sort(t,4) ----> ",image(a := sort(t,4)) | "none")
+ write("every i := 1 to *a - 1 by 2 do write(image(a[i]),\" \",a[i + 1]) ----> ",image(every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | "none")
+ write("t := table() ----> ",image(t := table()) | "none")
+ write("every t[1 | &output | &cset | [] | \"hello\" | main | 2 | table()] := ?100 ----> ",image(every t[1 | &output | &cset | [] | "hello" | main | 2 | table()] := ?100) | "none")
+ write("a := sort(t,3) ----> ",image(a := sort(t,3)) | "none")
+ write("every i := 1 to *a - 1 by 2 do write(image(a[i]),\" \",a[i + 1]) ----> ",image(every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | "none")
+ write("a := sort(t,4) ----> ",image(a := sort(t,4)) | "none")
+ write("every i := 1 to *a - 1 by 2 do write(image(a[i]),\" \",a[i + 1]) ----> ",image(every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1])) | "none")
+ write("x := [array(),table(),write,[],&input,1,\"abc\",'aa',&null] ----> ",image(x := [array(),table(),write,[],&input,1,"abc",'aa',&null]) | "none")
+ write("x := sort(x) ----> ",image(x := sort(x)) | "none")
+end
+
+procedure p6()
+ write("every write(image(!x)) ----> ",image(every write(image(!x))) | "none")
+ write("t := table(table()) ----> ",image(t := table(table())) | "none")
+ write("every t[1 to 10] := 1 do write(image(t)) ----> ",image(every t[1 to 10] := 1 do write(image(t))) | "none")
+ write("t := table() ----> ",image(t := table()) | "none")
+ write("every t[1 to 10] := 1 do write(*t) ----> ",image(every t[1 to 10] := 1 do write(*t)) | "none")
+ write("t[] := 6 ----> ",image(t[] := 6) | "none")
+ write("t[] ----> ",image(t[]) | "none")
+ write("*t ----> ",image(*t) | "none")
+ write("t[&null] := 7 ----> ",image(t[&null] := 7) | "none")
+ write("t[] ----> ",image(t[]) | "none")
+ write("*t ----> ",image(*t) | "none")
+end
+
+procedure p7()
+ write("x := [] ----> ",image(x := []) | "none")
+ write("*x ----> ",image(*x) | "none")
+ write("every push(x,1 to 10) ----> ",image(every push(x,1 to 10)) | "none")
+ write("every 1 to 10 do write(pop(x)) ----> ",image(every 1 to 10 do write(pop(x))) | "none")
+ write("*x ----> ",image(*x) | "none")
+ write("pop(x) ----> ",image(pop(x)) | "none")
+ write("pull(x) ----> ",image(pull(x)) | "none")
+ write("get(x) ----> ",image(get(x)) | "none")
+ write("every put(x,1 to 10) ----> ",image(every put(x,1 to 10)) | "none")
+ write("every 1 to 10 do write(get(x)) ----> ",image(every 1 to 10 do write(get(x))) | "none")
+ write("every push(x,1 to 10) ----> ",image(every push(x,1 to 10)) | "none")
+end
+
+procedure p8()
+ write("every 1 to 10 do write(pull(x)) ----> ",image(every 1 to 10 do write(pull(x))) | "none")
+ write("x := [1,2,3,4,5,6,7,8,9,0] ----> ",image(x := [1,2,3,4,5,6,7,8,9,0]) | "none")
+ write("every write(image(x[1:0 to -20 by -1])) ----> ",image(every write(image(x[1:0 to -20 by -1]))) | "none")
+ write("a := [1,2,3,4,5,6,7,8] ----> ",image(a := [1,2,3,4,5,6,7,8]) | "none")
+ write("a1 := a[2:4] ----> ",image(a1 := a[2:4]) | "none")
+ write("a2 := a[7:2] ----> ",image(a2 := a[7:2]) | "none")
+ write("a3 := a[2+:3] ----> ",image(a3 := a[2+:3]) | "none")
+ write("a4 := a[-1-:3] ----> ",image(a4 := a[-1-:3]) | "none")
+ write("a1[1] ----> ",image(a1[1]) | "none")
+ write("a2[1] ----> ",image(a2[1]) | "none")
+ write("a3[1] ----> ",image(a3[1]) | "none")
+end
+
+procedure p9()
+ write("a4[1] ----> ",image(a4[1]) | "none")
+ write("a4[1] := a ----> ",image(a4[1] := a) | "none")
+ write("a := [1,2,3,4] ----> ",image(a := [1,2,3,4]) | "none")
+ write("a1 := a[1:2] ----> ",image(a1 := a[1:2]) | "none")
+ write("every write(!a1) ----> ",image(every write(!a1)) | "none")
+ write("a2 := a[3:0] ----> ",image(a2 := a[3:0]) | "none")
+ write("every write(!a2) ----> ",image(every write(!a2)) | "none")
+ write("a4 := a[2:2] ----> ",image(a4 := a[2:2]) | "none")
+ write("every write(!a4) ----> ",image(every write(!a4)) | "none")
+ write("a5 := a[0-:2] ----> ",image(a5 := a[0-:2]) | "none")
+ write("every write(!a5) ----> ",image(every write(!a5)) | "none")
+end
+
+procedure p10()
+ write("a3 := a[0:3] ----> ",image(a3 := a[0:3]) | "none")
+ write("every write(!a3) ----> ",image(every write(!a3)) | "none")
+ write("a := \"abcd\" ----> ",image(a := "abcd") | "none")
+ write("a1 := a[1:2] ----> ",image(a1 := a[1:2]) | "none")
+ write("every write(!a1) ----> ",image(every write(!a1)) | "none")
+ write("a2 := a[3:0] ----> ",image(a2 := a[3:0]) | "none")
+ write("every write(!a2) ----> ",image(every write(!a2)) | "none")
+ write("a3 := a[0:3] ----> ",image(a3 := a[0:3]) | "none")
+ write("every write(!a3) ----> ",image(every write(!a3)) | "none")
+ write("a4 := a[2:2] ----> ",image(a4 := a[2:2]) | "none")
+ write("every write(!a4) ----> ",image(every write(!a4)) | "none")
+end
+
+procedure p11()
+ write("a5 := a[0-:2] ----> ",image(a5 := a[0-:2]) | "none")
+ write("every write(!a5) ----> ",image(every write(!a5)) | "none")
+ write("[] ||| [] ----> ",image([] ||| []) | "none")
+ write("[1,2,3] ||| [] ----> ",image([1,2,3] ||| []) | "none")
+ write("[] ||| [1,2,3] ----> ",image([] ||| [1,2,3]) | "none")
+ write("r := array(1,2,3,4,5,6,7,8,9) ----> ",image(r := array(1,2,3,4,5,6,7,8,9)) | "none")
+ write("r.a ----> ",image(r.a) | "none")
+ write("r.b ----> ",image(r.b) | "none")
+ write("r.c ----> ",image(r.c) | "none")
+ write("r.d ----> ",image(r.d) | "none")
+ write("r.e ----> ",image(r.e) | "none")
+end
+
+procedure p12()
+ write("r.f ----> ",image(r.f) | "none")
+ write("type(r) ----> ",image(type(r)) | "none")
+ write("image(r) ----> ",image(image(r)) | "none")
+ write("r.a +:= 0 ----> ",image(r.a +:= 0) | "none")
+ write("r.b +:= 0 ----> ",image(r.b +:= 0) | "none")
+ write("r.c +:= 0 ----> ",image(r.c +:= 0) | "none")
+ write("r.d +:= 0 ----> ",image(r.d +:= 0) | "none")
+ write("r.e +:= 0 ----> ",image(r.e +:= 0) | "none")
+ write("r.f +:= 0 ----> ",image(r.f +:= 0) | "none")
+ write("r.a ----> ",image(r.a) | "none")
+ write("r.b ----> ",image(r.b) | "none")
+end
+
+procedure p13()
+ write("r.c ----> ",image(r.c) | "none")
+ write("r.d ----> ",image(r.d) | "none")
+ write("r.e ----> ",image(r.e) | "none")
+ write("r.f ----> ",image(r.f) | "none")
+ write("r := array(\"a\",2,array(),r,main) ----> ",image(r := array("a",2,3.5,array(),r,main)) | "none")
+ write("every write(image(!r)) ----> ",image(every write(image(!r))) | "none")
+ write("r[1] :=: r.d ----> ",image(r[1] :=: r.d) | "none")
+ write("every write(image(!r)) ----> ",image(every write(image(!r))) | "none")
+ # test that overflow is not ignored when comparing integers
+ a := [847198497, -2035912587]
+ every writes(" ", "a:" | !sort(a) | "\n")
+end
+
+procedure main()
+ p1()
+ p2()
+ p3()
+ p4()
+ p5()
+ p6()
+ p7()
+ p8()
+ p9()
+ p10()
+ p11()
+ p12()
+ p13()
+end
+
+global s, t, x, r
+global a, a1, a2, a3, a4
diff --git a/tests/general/struct.std b/tests/general/struct.std
new file mode 100644
index 0000000..86c87a7
--- /dev/null
+++ b/tests/general/struct.std
@@ -0,0 +1,359 @@
+ ----> &null
+list(0) ----> list_1(0)
+list(0,1) ----> list_2(0)
+list(1,1) ----> list_3(1)
+list(100,"a") ----> list_4(100)
+table() ----> table_1(0)
+table(0) ----> table_2(0)
+a := [] ----> list_5(0)
+every put(a,!&lcase) ----> none
+a1 := sort(a) ----> list_6(26)
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+every write(!a1) ----> none
+sort(a1) ----> list_7(26)
+t := table() ----> table_3(0)
+every t[!&lcase] := 1 ----> none
+sort(t) ----> list_8(26)
+a := sort(t) ----> list_35(26)
+a
+b
+c
+d
+e
+f
+g
+h
+i
+j
+k
+l
+m
+n
+o
+p
+q
+r
+s
+t
+u
+v
+w
+x
+y
+z
+every write((!a)[1]) ----> none
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+every write((!a)[2]) ----> none
+set([1,0,1,0,1,0,1,0]) ----> set_1(2)
+set([]) ----> set_2(0)
+s := set([1,2,3,4,5,6,7,8,9,10]) ----> set_3(10)
+*s ----> 10
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+every write(!sort(s)) ----> none
+*copy(s) ----> 10
+image(s) ----> "set_3(10)"
+type(s) ----> "set"
+member(s,8) ----> 8
+member(s,"8") ----> none
+s := set([]) ----> set_5(0)
+every insert(s,1 to 100) ----> none
+*s ----> 100
+every delete(s,15 to 30) ----> none
+*s ----> 84
+every s1 := insert(set([]),!&lcase) ----> none
+s2 := set(["a","aa","ab","b",1,2,3,4]) ----> set_7(8)
+s3 := s1 ++ s2 ----> set_8(32)
+s4 := s1 ** s2 ----> set_9(2)
+s5 := s1 -- s2 ----> set_10(24)
+*s3 ----> 32
+*s4 ----> 2
+*s5 ----> 24
+t := table() ----> table_4(0)
+every t[1 | &output | &cset | [] | "hello" | main | 2 | table()] := ?100 ----> none
+a := sort(t,3) ----> list_70(16)
+1 22
+2 8
+"hello" 43
+&cset 32
+&output 42
+procedure main 31
+list_69(0) 52
+table_5(0) 74
+every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1]) ----> none
+a := sort(t,4) ----> list_71(16)
+2 8
+1 22
+procedure main 31
+&cset 32
+&output 42
+"hello" 43
+list_69(0) 52
+table_5(0) 74
+every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1]) ----> none
+t := table() ----> table_6(0)
+every t[1 | &output | &cset | [] | "hello" | main | 2 | table()] := ?100 ----> none
+a := sort(t,3) ----> list_73(16)
+1 6
+2 58
+"hello" 54
+&cset 14
+&output 72
+procedure main 63
+list_72(0) 34
+table_7(0) 71
+every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1]) ----> none
+a := sort(t,4) ----> list_74(16)
+1 6
+&cset 14
+list_72(0) 34
+"hello" 54
+2 58
+procedure main 63
+table_7(0) 71
+&output 72
+every i := 1 to *a - 1 by 2 do write(image(a[i])," ",a[i + 1]) ----> none
+x := [array(),table(),write,[],&input,1,"abc",'aa',&null] ----> list_76(9)
+x := sort(x) ----> list_77(9)
+&null
+1
+"abc"
+'a'
+&input
+function write
+list_75(0)
+table_8(0)
+record array_1(7)
+every write(image(!x)) ----> none
+t := table(table()) ----> table_10(0)
+table_10(1)
+table_10(2)
+table_10(3)
+table_10(4)
+table_10(5)
+table_10(6)
+table_10(7)
+table_10(8)
+table_10(9)
+table_10(10)
+every t[1 to 10] := 1 do write(image(t)) ----> none
+t := table() ----> table_11(0)
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+every t[1 to 10] := 1 do write(*t) ----> none
+t[] := 6 ----> 6
+t[] ----> 6
+*t ----> 11
+t[&null] := 7 ----> 7
+t[] ----> 7
+*t ----> 11
+x := [] ----> list_78(0)
+*x ----> 0
+every push(x,1 to 10) ----> none
+10
+9
+8
+7
+6
+5
+4
+3
+2
+1
+every 1 to 10 do write(pop(x)) ----> none
+*x ----> 0
+pop(x) ----> none
+pull(x) ----> none
+get(x) ----> none
+every put(x,1 to 10) ----> none
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+every 1 to 10 do write(get(x)) ----> none
+every push(x,1 to 10) ----> none
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+every 1 to 10 do write(pull(x)) ----> none
+x := [1,2,3,4,5,6,7,8,9,0] ----> list_79(10)
+list_80(10)
+list_81(9)
+list_82(8)
+list_83(7)
+list_84(6)
+list_85(5)
+list_86(4)
+list_87(3)
+list_88(2)
+list_89(1)
+list_90(0)
+every write(image(x[1:0 to -20 by -1])) ----> none
+a := [1,2,3,4,5,6,7,8] ----> list_91(8)
+a1 := a[2:4] ----> list_92(2)
+a2 := a[7:2] ----> list_93(5)
+a3 := a[2+:3] ----> list_94(3)
+a4 := a[-1-:3] ----> list_95(3)
+a1[1] ----> 2
+a2[1] ----> 2
+a3[1] ----> 2
+a4[1] ----> 5
+a4[1] := a ----> list_91(8)
+a := [1,2,3,4] ----> list_96(4)
+a1 := a[1:2] ----> list_97(1)
+1
+every write(!a1) ----> none
+a2 := a[3:0] ----> list_98(2)
+3
+4
+every write(!a2) ----> none
+a4 := a[2:2] ----> list_99(0)
+every write(!a4) ----> none
+a5 := a[0-:2] ----> list_100(2)
+3
+4
+every write(!a5) ----> none
+a3 := a[0:3] ----> list_101(2)
+3
+4
+every write(!a3) ----> none
+a := "abcd" ----> "abcd"
+a1 := a[1:2] ----> "a"
+a
+every write(!a1) ----> none
+a2 := a[3:0] ----> "cd"
+c
+d
+every write(!a2) ----> none
+a3 := a[0:3] ----> "cd"
+c
+d
+every write(!a3) ----> none
+a4 := a[2:2] ----> ""
+every write(!a4) ----> none
+a5 := a[0-:2] ----> "cd"
+c
+d
+every write(!a5) ----> none
+[] ||| [] ----> list_104(0)
+[1,2,3] ||| [] ----> list_107(3)
+[] ||| [1,2,3] ----> list_110(3)
+r := array(1,2,3,4,5,6,7,8,9) ----> record array_2(7)
+r.a ----> 1
+r.b ----> 2
+r.c ----> 3
+r.d ----> 4
+r.e ----> 5
+r.f ----> 6
+type(r) ----> "array"
+image(r) ----> "record array_2(7)"
+r.a +:= 0 ----> 1
+r.b +:= 0 ----> 2
+r.c +:= 0 ----> 3
+r.d +:= 0 ----> 4
+r.e +:= 0 ----> 5
+r.f +:= 0 ----> 6
+r.a ----> 1
+r.b ----> 2
+r.c ----> 3
+r.d ----> 4
+r.e ----> 5
+r.f ----> 6
+r := array("a",2,array(),r,main) ----> record array_4(7)
+"a"
+2
+3.5
+record array_3(7)
+record array_2(7)
+procedure main
+&null
+every write(image(!r)) ----> none
+r[1] :=: r.d ----> record array_3(7)
+record array_3(7)
+2
+3.5
+"a"
+record array_2(7)
+procedure main
+&null
+every write(image(!r)) ----> none
+ a: -2035912587 847198497
diff --git a/tests/general/subjpos.icn b/tests/general/subjpos.icn
new file mode 100644
index 0000000..05e4e81
--- /dev/null
+++ b/tests/general/subjpos.icn
@@ -0,0 +1,82 @@
+#SRC: JCON
+
+procedure main()
+ local i, s, x
+
+ ws() # dump initial state
+ write()
+
+ every setsubj(s := "cat" | "" | "donut" | "x") do
+ every i := -*s-2 to *s+3 do
+ setpos(i)
+ write()
+
+ "outer" ? {
+ ws()
+ &pos := 3
+ ws()
+ "inner" ? {
+ ws()
+ &pos := 2
+ ws()
+ }
+ ws()
+ }
+
+ "123456" ? {
+ &pos := 3
+ x := 4
+ write("&pos=", &pos, " x=", x)
+ &pos :=: x
+ write("&pos=", &pos, " x=", x)
+ &pos := 3
+ x := 9
+ &pos :=: x
+ write("&pos=", &pos, " x=", x)
+ &pos := 3
+ x := 9
+ x :=: &pos
+ write("&pos=", &pos, " x=", x)
+ &pos := 3
+ x := 9
+ every &pos <-> x do write("&pos=", &pos, " x=", x)
+ write("&pos=", &pos, " x=", x)
+ &pos := 3
+ x := 9
+ every x <-> &pos do write("&pos=", &pos, " x=", x)
+ write("&pos=", &pos, " x=", x)
+ &pos := 3
+ x := 2
+ every &pos <-> x do &subject := "A"
+ write("&pos=", &pos, " x=", x)
+ &pos := 3
+ x := 2
+ every x <-> &pos do &subject := "A"
+ write("&pos=", &pos, " x=", x)
+ }
+end
+
+procedure setpos(n)
+ writes("p := ", right(image(n),10))
+ if &pos := n then
+ writes(" ")
+ else
+ writes(" FAILED")
+ ws()
+ return
+end
+
+procedure setsubj(s)
+ writes("s := ", right(image(s),10))
+ if &subject := s then
+ writes(" ")
+ else
+ writes(" FAILED")
+ ws()
+ return
+end
+
+procedure ws() # write state of &setpos and &subject
+ write(" &pos=", image(&pos), " &subject=", image(&subject))
+ return
+end
diff --git a/tests/general/subjpos.std b/tests/general/subjpos.std
new file mode 100644
index 0000000..04abc77
--- /dev/null
+++ b/tests/general/subjpos.std
@@ -0,0 +1,62 @@
+ &pos=1 &subject=""
+
+s := "cat" &pos=1 &subject="cat"
+p := -5 FAILED &pos=1 &subject="cat"
+p := -4 FAILED &pos=1 &subject="cat"
+p := -3 &pos=1 &subject="cat"
+p := -2 &pos=2 &subject="cat"
+p := -1 &pos=3 &subject="cat"
+p := 0 &pos=4 &subject="cat"
+p := 1 &pos=1 &subject="cat"
+p := 2 &pos=2 &subject="cat"
+p := 3 &pos=3 &subject="cat"
+p := 4 &pos=4 &subject="cat"
+p := 5 FAILED &pos=4 &subject="cat"
+p := 6 FAILED &pos=4 &subject="cat"
+s := "" &pos=1 &subject=""
+p := -2 FAILED &pos=1 &subject=""
+p := -1 FAILED &pos=1 &subject=""
+p := 0 &pos=1 &subject=""
+p := 1 &pos=1 &subject=""
+p := 2 FAILED &pos=1 &subject=""
+p := 3 FAILED &pos=1 &subject=""
+s := "donut" &pos=1 &subject="donut"
+p := -7 FAILED &pos=1 &subject="donut"
+p := -6 FAILED &pos=1 &subject="donut"
+p := -5 &pos=1 &subject="donut"
+p := -4 &pos=2 &subject="donut"
+p := -3 &pos=3 &subject="donut"
+p := -2 &pos=4 &subject="donut"
+p := -1 &pos=5 &subject="donut"
+p := 0 &pos=6 &subject="donut"
+p := 1 &pos=1 &subject="donut"
+p := 2 &pos=2 &subject="donut"
+p := 3 &pos=3 &subject="donut"
+p := 4 &pos=4 &subject="donut"
+p := 5 &pos=5 &subject="donut"
+p := 6 &pos=6 &subject="donut"
+p := 7 FAILED &pos=6 &subject="donut"
+p := 8 FAILED &pos=6 &subject="donut"
+s := "x" &pos=1 &subject="x"
+p := -3 FAILED &pos=1 &subject="x"
+p := -2 FAILED &pos=1 &subject="x"
+p := -1 &pos=1 &subject="x"
+p := 0 &pos=2 &subject="x"
+p := 1 &pos=1 &subject="x"
+p := 2 &pos=2 &subject="x"
+p := 3 FAILED &pos=2 &subject="x"
+p := 4 FAILED &pos=2 &subject="x"
+
+ &pos=1 &subject="outer"
+ &pos=3 &subject="outer"
+ &pos=1 &subject="inner"
+ &pos=2 &subject="inner"
+ &pos=3 &subject="outer"
+&pos=3 x=4
+&pos=4 x=3
+&pos=3 x=9
+&pos=3 x=3
+&pos=3 x=9
+&pos=3 x=3
+&pos=1 x=3
+&pos=1 x=2
diff --git a/tests/general/substring.icn b/tests/general/substring.icn
new file mode 100644
index 0000000..8d34975
--- /dev/null
+++ b/tests/general/substring.icn
@@ -0,0 +1,65 @@
+#SRC: JCON
+
+# string subscripting test
+
+procedure main()
+ local i, j, k, s, t
+
+ s := "abcde"
+ t := "ABCDE"
+ write("A. ", !s)
+ every write("B. ", !s)
+ every i := 0 to 6 do write("C ", i, ". ", s[i] | "--")
+ every i := 0 to -6 by -1 do write("D ", i, ". ", s[i] | "--")
+ every i := -10 to 10 do write("E ", i, ". ", s[3:i] | "--")
+ every i := -10 to 5 do write("F ", i, ". ", s[3+:i] | "--") #some SHOULD fail
+ every i := -5 to 10 do write("G ", i, ". ", s[3-:i] | "--") #some SHOULD fail
+
+ !s := "X"
+ write("H. ", s)
+ every !s := "Y"
+ write("I. ", s)
+
+ every i := -6 to 6 do {
+ s := "abcde"
+ if s[i] := t[i] then
+ write("J ", i, ". ", s)
+ else
+ write("J ", i, ". --")
+ }
+
+ every i := 1 to 6 do {
+ every j := 1 to 6 do {
+ s := "abcde"
+ writes("K ", i, " ", j, ". ")
+ if s[i:j] := "(*)" then
+ write(s)
+ else
+ write(s, " [failed]")
+ }
+ }
+
+ every i := 1 to 6 do {
+ every j := 1 to 6 do {
+ every k := 1 to 6 do {
+ s := "abcde"
+ writes("L ", i, " ", j, " ", k, ". ")
+ if s[i:j][k:2] := "(*)" then
+ write(s)
+ else
+ write(s, " [failed]")
+ }
+ }
+ }
+
+ s := "abcde"
+ every !s <- "-" do write("M ", s)
+ every s [1 to 5] <- "-" do write("N ", s)
+ every s [(-5 to 6) +: 0] <- "--" do write("O ", s)
+
+ s := "abcde"
+ every s[2:4] := !"123" do write("P ", s)
+ s := "fghij"
+ every s[2:4] := !"456" do { write("Q ", s); s := "klmno" }
+
+end
diff --git a/tests/general/substring.std b/tests/general/substring.std
new file mode 100644
index 0000000..84cb4aa
--- /dev/null
+++ b/tests/general/substring.std
@@ -0,0 +1,368 @@
+A. a
+B. a
+B. b
+B. c
+B. d
+B. e
+C 0. --
+C 1. a
+C 2. b
+C 3. c
+C 4. d
+C 5. e
+C 6. --
+D 0. --
+D -1. e
+D -2. d
+D -3. c
+D -4. b
+D -5. a
+D -6. --
+E -10. --
+E -9. --
+E -8. --
+E -7. --
+E -6. --
+E -5. ab
+E -4. b
+E -3.
+E -2. c
+E -1. cd
+E 0. cde
+E 1. ab
+E 2. b
+E 3.
+E 4. c
+E 5. cd
+E 6. cde
+E 7. --
+E 8. --
+E 9. --
+E 10. --
+F -10. --
+F -9. --
+F -8. ab
+F -7. b
+F -6.
+F -5. c
+F -4. cd
+F -3. cde
+F -2. ab
+F -1. b
+F 0.
+F 1. c
+F 2. cd
+F 3. cde
+F 4. --
+F 5. --
+G -5. --
+G -4. --
+G -3. cde
+G -2. cd
+G -1. c
+G 0.
+G 1. b
+G 2. ab
+G 3. cde
+G 4. cd
+G 5. c
+G 6.
+G 7. b
+G 8. ab
+G 9. --
+G 10. --
+H. Xbcde
+I. YYYYY
+J -6. --
+J -5. Abcde
+J -4. aBcde
+J -3. abCde
+J -2. abcDe
+J -1. abcdE
+J 0. --
+J 1. Abcde
+J 2. aBcde
+J 3. abCde
+J 4. abcDe
+J 5. abcdE
+J 6. --
+K 1 1. (*)abcde
+K 1 2. (*)bcde
+K 1 3. (*)cde
+K 1 4. (*)de
+K 1 5. (*)e
+K 1 6. (*)
+K 2 1. (*)bcde
+K 2 2. a(*)bcde
+K 2 3. a(*)cde
+K 2 4. a(*)de
+K 2 5. a(*)e
+K 2 6. a(*)
+K 3 1. (*)cde
+K 3 2. a(*)cde
+K 3 3. ab(*)cde
+K 3 4. ab(*)de
+K 3 5. ab(*)e
+K 3 6. ab(*)
+K 4 1. (*)de
+K 4 2. a(*)de
+K 4 3. ab(*)de
+K 4 4. abc(*)de
+K 4 5. abc(*)e
+K 4 6. abc(*)
+K 5 1. (*)e
+K 5 2. a(*)e
+K 5 3. ab(*)e
+K 5 4. abc(*)e
+K 5 5. abcd(*)e
+K 5 6. abcd(*)
+K 6 1. (*)
+K 6 2. a(*)
+K 6 3. ab(*)
+K 6 4. abc(*)
+K 6 5. abcd(*)
+K 6 6. abcde(*)
+L 1 1 1. abcde [failed]
+L 1 1 2. abcde [failed]
+L 1 1 3. abcde [failed]
+L 1 1 4. abcde [failed]
+L 1 1 5. abcde [failed]
+L 1 1 6. abcde [failed]
+L 1 2 1. (*)bcde
+L 1 2 2. a(*)bcde
+L 1 2 3. abcde [failed]
+L 1 2 4. abcde [failed]
+L 1 2 5. abcde [failed]
+L 1 2 6. abcde [failed]
+L 1 3 1. (*)bcde
+L 1 3 2. a(*)bcde
+L 1 3 3. a(*)cde
+L 1 3 4. abcde [failed]
+L 1 3 5. abcde [failed]
+L 1 3 6. abcde [failed]
+L 1 4 1. (*)bcde
+L 1 4 2. a(*)bcde
+L 1 4 3. a(*)cde
+L 1 4 4. a(*)de
+L 1 4 5. abcde [failed]
+L 1 4 6. abcde [failed]
+L 1 5 1. (*)bcde
+L 1 5 2. a(*)bcde
+L 1 5 3. a(*)cde
+L 1 5 4. a(*)de
+L 1 5 5. a(*)e
+L 1 5 6. abcde [failed]
+L 1 6 1. (*)bcde
+L 1 6 2. a(*)bcde
+L 1 6 3. a(*)cde
+L 1 6 4. a(*)de
+L 1 6 5. a(*)e
+L 1 6 6. a(*)
+L 2 1 1. (*)bcde
+L 2 1 2. a(*)bcde
+L 2 1 3. abcde [failed]
+L 2 1 4. abcde [failed]
+L 2 1 5. abcde [failed]
+L 2 1 6. abcde [failed]
+L 2 2 1. abcde [failed]
+L 2 2 2. abcde [failed]
+L 2 2 3. abcde [failed]
+L 2 2 4. abcde [failed]
+L 2 2 5. abcde [failed]
+L 2 2 6. abcde [failed]
+L 2 3 1. a(*)cde
+L 2 3 2. ab(*)cde
+L 2 3 3. abcde [failed]
+L 2 3 4. abcde [failed]
+L 2 3 5. abcde [failed]
+L 2 3 6. abcde [failed]
+L 2 4 1. a(*)cde
+L 2 4 2. ab(*)cde
+L 2 4 3. ab(*)de
+L 2 4 4. abcde [failed]
+L 2 4 5. abcde [failed]
+L 2 4 6. abcde [failed]
+L 2 5 1. a(*)cde
+L 2 5 2. ab(*)cde
+L 2 5 3. ab(*)de
+L 2 5 4. ab(*)e
+L 2 5 5. abcde [failed]
+L 2 5 6. abcde [failed]
+L 2 6 1. a(*)cde
+L 2 6 2. ab(*)cde
+L 2 6 3. ab(*)de
+L 2 6 4. ab(*)e
+L 2 6 5. ab(*)
+L 2 6 6. abcde [failed]
+L 3 1 1. (*)bcde
+L 3 1 2. a(*)bcde
+L 3 1 3. a(*)cde
+L 3 1 4. abcde [failed]
+L 3 1 5. abcde [failed]
+L 3 1 6. abcde [failed]
+L 3 2 1. a(*)cde
+L 3 2 2. ab(*)cde
+L 3 2 3. abcde [failed]
+L 3 2 4. abcde [failed]
+L 3 2 5. abcde [failed]
+L 3 2 6. abcde [failed]
+L 3 3 1. abcde [failed]
+L 3 3 2. abcde [failed]
+L 3 3 3. abcde [failed]
+L 3 3 4. abcde [failed]
+L 3 3 5. abcde [failed]
+L 3 3 6. abcde [failed]
+L 3 4 1. ab(*)de
+L 3 4 2. abc(*)de
+L 3 4 3. abcde [failed]
+L 3 4 4. abcde [failed]
+L 3 4 5. abcde [failed]
+L 3 4 6. abcde [failed]
+L 3 5 1. ab(*)de
+L 3 5 2. abc(*)de
+L 3 5 3. abc(*)e
+L 3 5 4. abcde [failed]
+L 3 5 5. abcde [failed]
+L 3 5 6. abcde [failed]
+L 3 6 1. ab(*)de
+L 3 6 2. abc(*)de
+L 3 6 3. abc(*)e
+L 3 6 4. abc(*)
+L 3 6 5. abcde [failed]
+L 3 6 6. abcde [failed]
+L 4 1 1. (*)bcde
+L 4 1 2. a(*)bcde
+L 4 1 3. a(*)cde
+L 4 1 4. a(*)de
+L 4 1 5. abcde [failed]
+L 4 1 6. abcde [failed]
+L 4 2 1. a(*)cde
+L 4 2 2. ab(*)cde
+L 4 2 3. ab(*)de
+L 4 2 4. abcde [failed]
+L 4 2 5. abcde [failed]
+L 4 2 6. abcde [failed]
+L 4 3 1. ab(*)de
+L 4 3 2. abc(*)de
+L 4 3 3. abcde [failed]
+L 4 3 4. abcde [failed]
+L 4 3 5. abcde [failed]
+L 4 3 6. abcde [failed]
+L 4 4 1. abcde [failed]
+L 4 4 2. abcde [failed]
+L 4 4 3. abcde [failed]
+L 4 4 4. abcde [failed]
+L 4 4 5. abcde [failed]
+L 4 4 6. abcde [failed]
+L 4 5 1. abc(*)e
+L 4 5 2. abcd(*)e
+L 4 5 3. abcde [failed]
+L 4 5 4. abcde [failed]
+L 4 5 5. abcde [failed]
+L 4 5 6. abcde [failed]
+L 4 6 1. abc(*)e
+L 4 6 2. abcd(*)e
+L 4 6 3. abcd(*)
+L 4 6 4. abcde [failed]
+L 4 6 5. abcde [failed]
+L 4 6 6. abcde [failed]
+L 5 1 1. (*)bcde
+L 5 1 2. a(*)bcde
+L 5 1 3. a(*)cde
+L 5 1 4. a(*)de
+L 5 1 5. a(*)e
+L 5 1 6. abcde [failed]
+L 5 2 1. a(*)cde
+L 5 2 2. ab(*)cde
+L 5 2 3. ab(*)de
+L 5 2 4. ab(*)e
+L 5 2 5. abcde [failed]
+L 5 2 6. abcde [failed]
+L 5 3 1. ab(*)de
+L 5 3 2. abc(*)de
+L 5 3 3. abc(*)e
+L 5 3 4. abcde [failed]
+L 5 3 5. abcde [failed]
+L 5 3 6. abcde [failed]
+L 5 4 1. abc(*)e
+L 5 4 2. abcd(*)e
+L 5 4 3. abcde [failed]
+L 5 4 4. abcde [failed]
+L 5 4 5. abcde [failed]
+L 5 4 6. abcde [failed]
+L 5 5 1. abcde [failed]
+L 5 5 2. abcde [failed]
+L 5 5 3. abcde [failed]
+L 5 5 4. abcde [failed]
+L 5 5 5. abcde [failed]
+L 5 5 6. abcde [failed]
+L 5 6 1. abcd(*)
+L 5 6 2. abcde(*)
+L 5 6 3. abcde [failed]
+L 5 6 4. abcde [failed]
+L 5 6 5. abcde [failed]
+L 5 6 6. abcde [failed]
+L 6 1 1. (*)bcde
+L 6 1 2. a(*)bcde
+L 6 1 3. a(*)cde
+L 6 1 4. a(*)de
+L 6 1 5. a(*)e
+L 6 1 6. a(*)
+L 6 2 1. a(*)cde
+L 6 2 2. ab(*)cde
+L 6 2 3. ab(*)de
+L 6 2 4. ab(*)e
+L 6 2 5. ab(*)
+L 6 2 6. abcde [failed]
+L 6 3 1. ab(*)de
+L 6 3 2. abc(*)de
+L 6 3 3. abc(*)e
+L 6 3 4. abc(*)
+L 6 3 5. abcde [failed]
+L 6 3 6. abcde [failed]
+L 6 4 1. abc(*)e
+L 6 4 2. abcd(*)e
+L 6 4 3. abcd(*)
+L 6 4 4. abcde [failed]
+L 6 4 5. abcde [failed]
+L 6 4 6. abcde [failed]
+L 6 5 1. abcd(*)
+L 6 5 2. abcde(*)
+L 6 5 3. abcde [failed]
+L 6 5 4. abcde [failed]
+L 6 5 5. abcde [failed]
+L 6 5 6. abcde [failed]
+L 6 6 1. abcde [failed]
+L 6 6 2. abcde [failed]
+L 6 6 3. abcde [failed]
+L 6 6 4. abcde [failed]
+L 6 6 5. abcde [failed]
+L 6 6 6. abcde [failed]
+M -bcde
+M a-cde
+M ab-de
+M abc-e
+M abcd-
+N -bcde
+N a-cde
+N ab-de
+N abc-e
+N abcd-
+O --abcde
+O a--bcde
+O ab--cde
+O abc--de
+O abcd--e
+O abcde--
+O --abcde
+O a--bcde
+O ab--cde
+O abc--de
+O abcd--e
+O abcde--
+P a1de
+P a2de
+P a3de
+Q f4ij
+Q k5mno
+Q k6mno
diff --git a/tests/general/table.icn b/tests/general/table.icn
new file mode 100644
index 0000000..231de53
--- /dev/null
+++ b/tests/general/table.icn
@@ -0,0 +1,97 @@
+#SRC: JCON
+
+# table test
+
+procedure main()
+ local k, x, y
+
+ x := table()
+ tdump("initial", x)
+ writes("should fail ", image(?x))
+ every writes(" ", ">>" | !x | "\n") # portable with 0 or 1 entries
+ x[2] := 3;
+ every writes(" ", ">>" | !x | image(?x) | "\n")
+ x[4] := 7;
+ x["a"] := "A";
+ tdump("+2+4+a", x)
+
+ every !x := 88
+ tdump("!x=88", x)
+
+ every x[key(x)] := 99
+ tdump("[all]=99", x)
+
+ every k := key(x) do
+ x[k] := k
+ tdump("x[k]=k", x)
+
+ /x[1] | write("/1")
+ \x[2] | write("\\2")
+
+ x := table()
+ if member(x) then write("NULL IS MEMBER")
+ insert(x) | write("failed 0")
+ insert(x, 1) | write("failed 1")
+ insert(x, 3, ) | write("failed 3")
+ insert(x, 5, 55) | write("failed 5")
+ insert(insert(x, 6, 66), 7, 77) | write("failed 67")
+ insert(x, , "null") | write("failed n")
+ if not member(x) then write("NULL IS NOT MEMBER")
+ tdump("insert", x)
+ delete(x) | write("failed dn")
+ delete(x, 3, 6) | write("failed d36") # del only 3
+ delete(delete(x, 7), 1) | write("failed d71")
+ tdump("delete", x)
+
+ x := table(0)
+ write(x[47])
+ tdump("t0", x)
+ insert(x) | write("failed 0")
+ insert(x, 1) | write("failed 1")
+ insert(x, 3, ) | write("failed 3")
+ insert(x, 5, 55) | write("failed 5")
+ insert(insert(x, 6, 66), 7, 77) | write("failed 67")
+ insert(x, , "null") | write("failed n")
+ tdump("t0i", x)
+ delete(x) | write("failed dn")
+ delete(x, 3, 6) | write("failed d36") # del only 3
+ delete(delete(x, 7), 1) | write("failed d71")
+ tdump("t0d", x)
+
+ write()
+ x := table(7)
+ every x[3] <- 19
+ every write("k ", key(x))
+ every write("v ", !x)
+
+ x := table()
+ every k := 0 to 4 do
+ x[k] := k + 10
+ y := copy(x)
+ every !x +:= 20
+ every !y +:= 40
+ tdump("30s", x)
+ tdump("50s", y)
+
+end
+
+
+# dump a table, assuming that keys are drawn from: &null, 0 - 9, "a" - "e"
+#
+# also checks member()
+
+procedure tdump(label, T)
+ local x
+
+ writes(right(label, 10), " :", right(*T, 2), " :")
+ every x := &null | (0 to 9) | !"abcde" do
+ if x === key(T) then {
+ writes(" [", image(x), "]", image(T[x]))
+ member(T, x) | writes(":NONMEMBER")
+ }
+ else {
+ member(T, x) & writes(" MEMBER:", image(x))
+ }
+ write()
+ return
+end
diff --git a/tests/general/table.std b/tests/general/table.std
new file mode 100644
index 0000000..a409ba1
--- /dev/null
+++ b/tests/general/table.std
@@ -0,0 +1,18 @@
+ initial : 0 :
+ >>
+ >> 3 3
+ +2+4+a : 3 : [2]3 [4]7 ["a"]"A"
+ !x=88 : 3 : [2]88 [4]88 ["a"]88
+ [all]=99 : 3 : [2]99 [4]99 ["a"]99
+ x[k]=k : 3 : [2]2 [4]4 ["a"]"a"
+ insert : 6 : [&null]"null" [1]&null [3]&null [5]55 [6]66 [7]77
+ delete : 2 : [5]55 [6]66
+0
+ t0 : 0 :
+ t0i : 6 : [&null]"null" [1]&null [3]&null [5]55 [6]66 [7]77
+ t0d : 2 : [5]55 [6]66
+
+k 3
+v 7
+ 30s : 5 : [0]30 [1]31 [2]32 [3]33 [4]34
+ 50s : 5 : [0]50 [1]51 [2]52 [3]53 [4]54
diff --git a/tests/general/tpp.icn b/tests/general/tpp.icn
new file mode 100644
index 0000000..b2a7e82
--- /dev/null
+++ b/tests/general/tpp.icn
@@ -0,0 +1,315 @@
+# tpp.icn -- test file for Icon preprocessor
+#
+# generates lots of deliberate errors
+# includes tpp1.icn, tpp2.icn, tpp3.icn
+
+# force out #lines to test that this file is called "stdin"
+$include "/dev/null"
+
+# following should be legal
+#line 11 "a.b.c"
+#line 22 defgh
+#line 33"ijklm"#
+#line 44
+#line 55xyzzy#comment
+
+#line 0 "bad #lines"
+# following should be illegal but ignored
+#line
+#line 91 not.quoted
+#line 92 extra stuff
+#line 93 "extra" stuff
+#line 94 extra+
+# line 95 "passed through unrecognized"
+#line 96 "unterminated
+#line 97 "unterminated\
+#line 98 ""
+
+# following should be legal
+$line 11 "a.b.c"
+ $ line 22 defgh
+$line 33"ijklm"#comment
+$line 44
+$line 55xyzzy#comment
+$( digraphs for EBCDIC $)
+
+$line 0 "bad.ppdirs"
+# following should be illegal and diagnosed
+$line
+$line 91 not.quoted
+$line 92 extra stuff
+$line 93 "extra" stuff
+$line 94 extra+
+$line 96 "unterminated
+$line 97 "unterminated\
+$line 98""
+$unknown/preprocessing/directive
+
+$line 0 "include.tests"
+=a=
+$include "/dev/null"
+=b=
+ $ include "/dev/null" # comment
+=c=
+$include"abc\def\"ghi#jkl\#mno\\pqr stu" # lots of escapes
+=d=
+$include # no name (two ways)
+=e=
+$include
+=f=
+$include "unterminated
+=g=
+$include "unterminated\
+=h=
+$include nonexistent
+=i=
+$include extra+
+=j=
+$include "more extra stuff" dafslkjasfd
+=k=
+$include "tpp1.icn" # should get circularity error
+=l=
+$include"tpp3.icn"#likewise
+=m=
+
+$line 0 "predef.tst"
+#== predef test ==
+should be defined as 1: _UNIX _ASCII _PIPES _SYSTEM_FUNCTION
+should not be defined: _MACINTOSH _VMS _EBCDIC _DOS_FUNCTIONS
+it depends: _COMPILED _INTERPRETED
+$undef _PIPES
+$undef _ASCII
+$define _ASCII 128
+$define _EBCDIC 0
+bogus: pipes:_PIPES ascii:_ASCII ebcdic:_EBCDIC
+
+$line 0 "define.tst"
+#== define test ==
+
+#= illegal =
+$define
+$define 12
+$define "fred" 93
+$define b1 "
+$define b2 'dsfkjlfasd\'
+$define f(x) (x^2+2*x+1)
+
+#= null =
+$define n1
+$define n2 # also null
+a=n1=b=n2=c
+
+#= simple =
+$define one 1
+$define pi 3.14159
+$define plus +
+$define twine "string"
+$define vowels 'aeiou'
+$define expr ((sqrt(5) + 1) / 2) #phi
+$define xy_47_Hike "fffrtb"
+$undef nothing
+
+one pi plus twine vowels expr xy_47_Hike
+one+pi,plus/twine,vowels\expr?xy_47_Hike! # one pi plus etc
+one"pi"plus"twine"vowels"expr"xy_47_Hike
+'one'pi'plus'twine'vowels'expr'xy_47_Hike'
+
+#= redefinition =
+$define pi 2.7183
+pi
+$undef pi
+$define pi 2.7183
+pi
+
+#= deferred interpretation =
+$define aaa bbb
+$define bbb 42
+aaa bbb
+
+$define yyy xxx
+$define xxx 47
+xxx yyy
+
+#= dubious pasting=
+$define X e3
+$define Y 456e
+123X Y+3
+
+#= recursion =
+$define r r
+r
+$define rr rr rr
+rr
+$define a b b b
+$define b c c c
+$define c a a a
+a
+b
+c
+
+= context =
+$define _ <%>
+123_abc+_+123_+abc_+_"_"_+36rX_+123e10_+12.e+5_+e7_+_#_
+
+$line 0 "error.tst"
+#= $error =
+$error
+ $error
+$error # no text, just comment
+ $ error this program does not work
+
+$line 0 "if.tst"
+#= conditional compilation =
+
+$define isdef
+
+# $ifdef & $ifndef both true and false, with and without $else
+
+$ifdef isdef
+ "isdef is defined"
+$endif
+
+$ifdef notdef
+ "notdef is defined"
+$endif
+
+$ifndef isdef
+ "isdef is not defined"
+$endif
+
+$ifndef notdef
+ "notdef is not defined"
+$endif
+
+$ifdef isdef
+ "isdef is defined"
+$else
+ "isdef is not defined"
+$endif
+
+$ifdef notdef
+ "notdef is defined"
+$else
+ "notdef is not defined"
+$endif
+
+# nesting without $else
+
+$ifdef isdef
+ (true...)
+ $ifndef isdef
+ (wrong...)
+ $ifdef isdef
+ (yes, but skipped)
+ $endif
+ (...wrong)
+ $endif
+ (...true)
+$endif
+
+# full nesting, with some nonstandard spacing
+
+$ifdef isdef # meaningless comment
+ (begin true branch)
+ $ ifdef isdef
+ "isdef is defined"
+ $ else # else
+ "isdef is not defined"
+ $ endif # endif
+ (end true branch)
+ $ else #isdef not defined
+ (begin else branch)
+ $ ifdef notdef
+ "notdef is defined"
+ $ else
+ "notdef is not defined"
+ $ endif
+ (end true branch)
+ $ endif # end test
+
+# test all paths through four nested ifs
+$include "tpp4.icn"
+$define id4 *4*
+$include "tpp4.icn"
+$define id3 *3*
+$include "tpp4.icn"
+$undef id4
+$include "tpp4.icn"
+$define id2 *2*
+$include "tpp4.icn"
+$define id4 *4*
+$include "tpp4.icn"
+$undef id3
+$include "tpp4.icn"
+$undef id4
+$include "tpp4.icn"
+$define id1 *1*
+$include "tpp4.icn"
+$define id4 *4*
+$include "tpp4.icn"
+$define id3 *3*
+$include "tpp4.icn"
+$undef id4
+$include "tpp4.icn"
+$undef id2
+$include "tpp4.icn"
+$define id4 *4*
+$include "tpp4.icn"
+$undef id3
+$include "tpp4.icn"
+$undef id4
+$include "tpp4.icn"
+$undef id1
+
+# make sure it accepts anything resembling an $if when skipping
+
+$ifdef notdef
+ <skipped>
+ $bogus # should be no problem when skipped
+ <skipped>
+ $ifread "/some/file/that/doesnt/really/exist"
+ $include "/some/file/that/doesnt/really/exist"
+ $endif #ifexists
+ <should still be skipping>
+$endif
+<should pass this line>
+
+# test diagnostics for missing args
+$ifdef
+$endif
+$ifndef # missing here too
+$endif
+
+# test diagnostics for extraneous args
+$ifdef notdef
+$else notdef
+$endif notdef
+$ifndef notdef
+$else notdef
+$endif notdef
+
+# test else/endif out of place
+$endif # wrong place -- should get error
+$else # wrong place -- should get error
+$include "tpp5.icn" # includes unterminated $ifdef
+$else # should <not> match $if in tpp5.icn
+$endif # should <not> match $if in tpp5.icn
+# now try again when unterminated $if succeeds
+$define id5
+$include "tpp5.icn" # includes unterminated $ifdef
+$else # should <not> match $if in tpp5.icn
+$endif # should <not> match $if in tpp5.icn
+
+# test line directives encountered while skipping
+
+$ifdef notdef
+...
+#line 111 "invented"
+...
+$endif (& show line)
+
+$ifdef notdef
+...
+ $ line 222 "invented"
+...
+$endif (& show line)
diff --git a/tests/general/tpp.ok b/tests/general/tpp.ok
new file mode 100644
index 0000000..004f79a
--- /dev/null
+++ b/tests/general/tpp.ok
@@ -0,0 +1,565 @@
+tpp.icn:
+File bad.ppdirs; Line 2 # $line: no line number
+File bad.ppdirs; Line 3 # $line: too many arguments
+File bad.ppdirs; Line 4 # $line: too many arguments
+File bad.ppdirs; Line 5 # $line: too many arguments
+File bad.ppdirs; Line 6 # $line: too many arguments
+File bad.ppdirs; Line 7 # $line: invalid file name
+File bad.ppdirs; Line 8 # $line: invalid file name
+File bad.ppdirs; Line 9 # $line: invalid file name
+File bad.ppdirs; Line 10 # "unknown": invalid preprocessing directive
+File include.tests; Line 6 # "abcdef"ghi#jkl#mno\pqr stu": cannot open
+File include.tests; Line 8 # $include: invalid file name
+File include.tests; Line 10 # $include: invalid file name
+File include.tests; Line 12 # $include: invalid file name
+File include.tests; Line 14 # $include: invalid file name
+File include.tests; Line 16 # "nonexistent": cannot open
+File include.tests; Line 18 # $include: too many arguments
+File include.tests; Line 20 # $include: too many arguments
+File tpp3.icn; Line 3 # "tpp1.icn": circular include
+File tpp2.icn; Line 3 # "tpp3.icn": circular include
+File define.tst; Line 4 # $define: missing name
+File define.tst; Line 5 # $define: missing name
+File define.tst; Line 6 # $define: missing name
+File define.tst; Line 7 # $define: unterminated literal
+File define.tst; Line 8 # $define: unterminated literal
+File define.tst; Line 9 # $define: "(" after name requires preceding space
+File define.tst; Line 32 # "pi": value redefined
+File error.tst; Line 2 # explicit $error
+File error.tst; Line 3 # explicit $error
+File error.tst; Line 4 # explicit $error
+File error.tst; Line 5 # "this program does not work": explicit $error
+File if.tst; Line 117 # $ifdef/$ifndef: missing name
+File if.tst; Line 119 # $ifdef/$ifndef: missing name
+File if.tst; Line 124 # "notdef": extraneous arguments on $else/$endif
+File if.tst; Line 125 # "notdef": extraneous arguments on $else/$endif
+File if.tst; Line 127 # "notdef": extraneous arguments on $else/$endif
+File if.tst; Line 128 # "notdef": extraneous arguments on $else/$endif
+File if.tst; Line 131 # unexpected $endif
+File if.tst; Line 132 # unexpected $else
+File tpp5.icn; Line 3 # unexpected $endif
+File tpp5.icn; Line 5 # unexpected $else
+File tpp5.icn; Line 12 # unterminated $if
+File if.tst; Line 134 # unexpected $else
+File if.tst; Line 135 # unexpected $endif
+File tpp5.icn; Line 3 # unexpected $endif
+File tpp5.icn; Line 5 # unexpected $else
+File tpp5.icn; Line 12 # unterminated $if
+File if.tst; Line 139 # unexpected $else
+File if.tst; Line 140 # unexpected $endif
+File invented; Line 113 # "(& show line)": extraneous arguments on $else/$endif
+File invented; Line 224 # "(& show line)": extraneous arguments on $else/$endif
+tpp9.icn:
+50 errors
+#line 0 "tpp.icn"
+# tpp.icn -- test file for Icon preprocessor
+#
+# generates lots of deliberate errors
+# includes tpp1.icn, tpp2.icn, tpp3.icn
+
+# force out #lines to test that this file is called "stdin"
+#line 0 "/dev/null"
+#line 7 "tpp.icn"
+
+# following should be legal
+#line 11 "a.b.c"
+#line 22 "defgh"
+#line 33 "ijklm"
+#line 44 "ijklm"
+#line 55 "xyzzy"
+
+#line 0 "bad #lines"
+# following should be illegal but ignored
+
+
+
+
+
+# line 95 "passed through unrecognized"
+
+
+
+
+# following should be legal
+#line 11 "a.b.c"
+#line 22 "defgh"
+#line 33 "ijklm"
+#line 44 "ijklm"
+#line 55 "xyzzy"
+$( digraphs for EBCDIC $)
+
+#line 0 "bad.ppdirs"
+# following should be illegal and diagnosed
+
+
+
+
+
+
+
+
+
+
+#line 0 "include.tests"
+=a=
+#line 0 "/dev/null"
+#line 2 "include.tests"
+=b=
+#line 0 "/dev/null"
+#line 4 "include.tests"
+=c=
+
+=d=
+
+=e=
+
+=f=
+
+=g=
+
+=h=
+
+=i=
+
+=j=
+
+=k=
+#line 0 "tpp1.icn"
+# tpp1.icn: part 1 of circular include test
+ =1=
+#line 0 "tpp2.icn"
+# tpp2.icn: part 1 of circular include test
+ =2=
+#line 0 "tpp3.icn"
+# tpp3.icn: part 1 of circular include test
+ =3=
+
+ =3=
+#line 3 "tpp2.icn"
+ =2=
+#line 3 "tpp1.icn"
+ =1=
+#line 22 "include.tests"
+=l=
+#line 0 "tpp3.icn"
+# tpp3.icn: part 1 of circular include test
+ =3=
+#line 0 "tpp1.icn"
+# tpp1.icn: part 1 of circular include test
+ =1=
+#line 0 "tpp2.icn"
+# tpp2.icn: part 1 of circular include test
+ =2=
+
+ =2=
+#line 3 "tpp1.icn"
+ =1=
+#line 3 "tpp3.icn"
+ =3=
+#line 24 "include.tests"
+=m=
+
+#line 0 "predef.tst"
+#== predef test ==
+should be defined as 1: 1 1 1 1
+should not be defined: _MACINTOSH _VMS _EBCDIC _DOS_FUNCTIONS
+it depends: _COMPILED _INTERPRETED
+
+
+
+
+bogus: pipes:_PIPES ascii:128 ebcdic:0
+
+#line 0 "define.tst"
+#== define test ==
+
+#= illegal =
+
+
+
+
+
+
+
+#= null =
+
+
+a==b==c
+
+#= simple =
+
+
+
+
+
+
+
+
+
+1 3.14159 + "string" 'aeiou' ((sqrt(5) + 1) / 2) "fffrtb"
+1+3.14159,+/"string",'aeiou'\((sqrt(5) + 1) / 2)?"fffrtb"! # one pi plus etc
+1"pi"+"twine"'aeiou'"expr""fffrtb"
+'one'3.14159'plus'"string"'vowels'((sqrt(5) + 1) / 2)'xy_47_Hike'
+
+#= redefinition =
+
+3.14159
+
+
+2.7183
+
+#= deferred interpretation =
+
+
+42 42
+
+
+
+47 47
+
+#= dubious pasting=
+
+
+123e3 456e+3
+
+#= recursion =
+
+r
+
+rr rr
+
+
+
+a a a a a a a a a a a a a a a a a a a a a a a a a a a
+b b b b b b b b b b b b b b b b b b b b b b b b b b b
+c c c c c c c c c c c c c c c c c c c c c c c c c c c
+
+= context =
+
+123_abc+<%>+123<%>+abc_+<%>"_"<%>+36rX<%>+123e10<%>+12.e+5<%>+e7_+<%>#_
+
+#line 0 "error.tst"
+#= $error =
+
+
+
+
+
+#line 0 "if.tst"
+#= conditional compilation =
+
+
+
+# $ifdef & $ifndef both true and false, with and without $else
+
+
+ "isdef is defined"
+
+
+#line 13 "if.tst"
+
+#line 17 "if.tst"
+
+
+ "notdef is not defined"
+
+
+
+ "isdef is defined"
+#line 27 "if.tst"
+
+#line 31 "if.tst"
+ "notdef is not defined"
+
+
+# nesting without $else
+
+
+ (true...)
+#line 45 "if.tst"
+ (...true)
+
+
+# full nesting, with some nonstandard spacing
+
+
+ (begin true branch)
+
+ "isdef is defined"
+#line 57 "if.tst"
+ (end true branch)
+#line 67 "if.tst"
+
+# test all paths through four nested ifs
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+#line 47 "tpp4.icn"
+#line 54 "tpp4.icn"
+#line 57 "tpp4.icn"
+ - - - - : id1 id2 id3 id4
+
+
+
+
+#line 70 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+#line 47 "tpp4.icn"
+#line 54 "tpp4.icn"
+
+ - - - + : id1 id2 id3 *4*
+#line 59 "tpp4.icn"
+
+
+
+#line 72 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+#line 47 "tpp4.icn"
+
+
+ - - + + : id1 id2 *3* *4*
+#line 53 "tpp4.icn"
+#line 60 "tpp4.icn"
+
+
+#line 74 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+#line 47 "tpp4.icn"
+
+#line 51 "tpp4.icn"
+ - - + - : id1 id2 *3* id4
+
+#line 60 "tpp4.icn"
+
+
+#line 76 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+
+
+#line 37 "tpp4.icn"
+ - + + - : id1 *2* *3* id4
+
+#line 46 "tpp4.icn"
+#line 61 "tpp4.icn"
+
+#line 78 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+
+
+
+ - + + + : id1 *2* *3* *4*
+#line 39 "tpp4.icn"
+#line 46 "tpp4.icn"
+#line 61 "tpp4.icn"
+
+#line 80 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+
+#line 40 "tpp4.icn"
+
+ - + - + : id1 *2* id3 *4*
+#line 45 "tpp4.icn"
+
+#line 61 "tpp4.icn"
+
+#line 82 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+#line 32 "tpp4.icn"
+
+#line 40 "tpp4.icn"
+#line 43 "tpp4.icn"
+ - + - - : id1 *2* id3 id4
+
+
+#line 61 "tpp4.icn"
+
+#line 84 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+
+#line 10 "tpp4.icn"
+#line 13 "tpp4.icn"
+ + + - - : *1* *2* id3 id4
+
+
+#line 31 "tpp4.icn"
+#line 62 "tpp4.icn"
+#line 86 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+
+#line 10 "tpp4.icn"
+
+ + + - + : *1* *2* id3 *4*
+#line 15 "tpp4.icn"
+
+#line 31 "tpp4.icn"
+#line 62 "tpp4.icn"
+#line 88 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+
+
+
+ + + + + : *1* *2* *3* *4*
+#line 9 "tpp4.icn"
+#line 16 "tpp4.icn"
+#line 31 "tpp4.icn"
+#line 62 "tpp4.icn"
+#line 90 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+
+
+#line 7 "tpp4.icn"
+ + + + - : *1* *2* *3* id4
+
+#line 16 "tpp4.icn"
+#line 31 "tpp4.icn"
+#line 62 "tpp4.icn"
+#line 92 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+#line 17 "tpp4.icn"
+
+#line 21 "tpp4.icn"
+ + - + - : *1* id2 *3* id4
+
+#line 30 "tpp4.icn"
+
+#line 62 "tpp4.icn"
+#line 94 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+#line 17 "tpp4.icn"
+
+
+ + - + + : *1* id2 *3* *4*
+#line 23 "tpp4.icn"
+#line 30 "tpp4.icn"
+
+#line 62 "tpp4.icn"
+#line 96 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+#line 17 "tpp4.icn"
+#line 24 "tpp4.icn"
+
+ + - - + : *1* id2 id3 *4*
+#line 29 "tpp4.icn"
+
+
+#line 62 "tpp4.icn"
+#line 98 "if.tst"
+
+#line 0 "tpp4.icn"
+# tpp4.icn: nested $if test
+
+#line 17 "tpp4.icn"
+#line 24 "tpp4.icn"
+#line 27 "tpp4.icn"
+ + - - - : *1* id2 id3 id4
+
+
+
+#line 62 "tpp4.icn"
+#line 100 "if.tst"
+
+
+# make sure it accepts anything resembling an $if when skipping
+
+#line 113 "if.tst"
+<should pass this line>
+
+# test diagnostics for missing args
+
+
+
+
+
+# test diagnostics for extraneous args
+#line 124 "if.tst"
+
+
+#line 128 "if.tst"
+
+# test else/endif out of place
+
+
+#line 0 "tpp5.icn"
+# tpp5.icn: test for unterminated $if
+
+
+
+
+
+
+#line 133 "if.tst"
+
+
+# now try again when unterminated $if succeeds
+
+#line 0 "tpp5.icn"
+# tpp5.icn: test for unterminated $if
+
+
+
+
+
+
+#line 9 "tpp5.icn"
+
+
+#outer unterminated $ifdef should get error
+#line 138 "if.tst"
+
+
+
+# test line directives encountered while skipping
+
+#line 113 "invented"
+
+#line 224 "invented"
+#line 0 "tpp9.icn"
+# tpp9.icn: test that predefined symbols revert
+# to correct values with the start of a new file
+
+pipes:1 ascii:1 ebcdic:_EBCDIC # were redefined in tpp.icn
+
+should be defined as 1: 1 1 1 1
+should not be defined: _MACINTOSH _VMS _EBCDIC _DOS_FUNCTIONS
+it depends: _COMPILED _INTERPRETED
diff --git a/tests/general/tpp1.icn b/tests/general/tpp1.icn
new file mode 100644
index 0000000..ce9fe1d
--- /dev/null
+++ b/tests/general/tpp1.icn
@@ -0,0 +1,4 @@
+# tpp1.icn: part 1 of circular include test
+ =1=
+$include "tpp2.icn"
+ =1=
diff --git a/tests/general/tpp2.icn b/tests/general/tpp2.icn
new file mode 100644
index 0000000..cc87ca6
--- /dev/null
+++ b/tests/general/tpp2.icn
@@ -0,0 +1,4 @@
+# tpp2.icn: part 1 of circular include test
+ =2=
+$include "tpp3.icn"
+ =2=
diff --git a/tests/general/tpp3.icn b/tests/general/tpp3.icn
new file mode 100644
index 0000000..48fbe22
--- /dev/null
+++ b/tests/general/tpp3.icn
@@ -0,0 +1,4 @@
+# tpp3.icn: part 1 of circular include test
+ =3=
+$include "tpp1.icn"
+ =3=
diff --git a/tests/general/tpp4.icn b/tests/general/tpp4.icn
new file mode 100644
index 0000000..e8f3f7e
--- /dev/null
+++ b/tests/general/tpp4.icn
@@ -0,0 +1,62 @@
+# tpp4.icn: nested $if test
+$ifdef id1
+ $ifdef id2
+ $ifdef id3
+ $ifdef id4
+ + + + + : id1 id2 id3 id4
+ $else
+ + + + - : id1 id2 id3 id4
+ $endif
+ $else
+ $ifdef id4
+ + + - + : id1 id2 id3 id4
+ $else
+ + + - - : id1 id2 id3 id4
+ $endif
+ $endif
+ $else
+ $ifdef id3
+ $ifdef id4
+ + - + + : id1 id2 id3 id4
+ $else
+ + - + - : id1 id2 id3 id4
+ $endif
+ $else
+ $ifdef id4
+ + - - + : id1 id2 id3 id4
+ $else
+ + - - - : id1 id2 id3 id4
+ $endif
+ $endif
+ $endif
+$else
+ $ifdef id2
+ $ifdef id3
+ $ifdef id4
+ - + + + : id1 id2 id3 id4
+ $else
+ - + + - : id1 id2 id3 id4
+ $endif
+ $else
+ $ifdef id4
+ - + - + : id1 id2 id3 id4
+ $else
+ - + - - : id1 id2 id3 id4
+ $endif
+ $endif
+ $else
+ $ifdef id3
+ $ifdef id4
+ - - + + : id1 id2 id3 id4
+ $else
+ - - + - : id1 id2 id3 id4
+ $endif
+ $else
+ $ifdef id4
+ - - - + : id1 id2 id3 id4
+ $else
+ - - - - : id1 id2 id3 id4
+ $endif
+ $endif
+ $endif
+$endif
diff --git a/tests/general/tpp5.icn b/tests/general/tpp5.icn
new file mode 100644
index 0000000..99f6257
--- /dev/null
+++ b/tests/general/tpp5.icn
@@ -0,0 +1,12 @@
+# tpp5.icn: test for unterminated $if
+
+$endif # should not match includer's $if
+
+$else # should not match includer's $if
+
+$ifdef id5
+ $ifdef x
+ $else
+ $endif
+
+#outer unterminated $ifdef should get error
diff --git a/tests/general/tpp9.icn b/tests/general/tpp9.icn
new file mode 100644
index 0000000..ee52472
--- /dev/null
+++ b/tests/general/tpp9.icn
@@ -0,0 +1,8 @@
+# tpp9.icn: test that predefined symbols revert
+# to correct values with the start of a new file
+
+pipes:_PIPES ascii:_ASCII ebcdic:_EBCDIC # were redefined in tpp.icn
+
+should be defined as 1: _UNIX _ASCII _PIPES _SYSTEM_FUNCTION
+should not be defined: _MACINTOSH _VMS _EBCDIC _DOS_FUNCTIONS
+it depends: _COMPILED _INTERPRETED
diff --git a/tests/general/tracer.icn b/tests/general/tracer.icn
new file mode 100644
index 0000000..82b49d8
--- /dev/null
+++ b/tests/general/tracer.icn
@@ -0,0 +1,30 @@
+global s
+procedure main()
+ &trace := -1
+ s := "abcdef"
+ &subject := "123456"
+ &pos := 4
+ every tracer(1)
+ every foo(&pos | &subject | &pos[1] | &subject[2:5])
+ display()
+ write(&line)
+ write(&file)
+ write(&level)
+end
+
+procedure tracer(a)
+ local i
+ static j
+ i := 2
+ j := 3
+ suspend .(a | i | j | s | &subject |
+ &pos | &random | &trace | &subject[3:4] | &pos[1] |
+ s[3] | s[3:5] | &random[1] | &trace[1] | &subject[2:5][1])
+ suspend (a | i | j | s | &subject |
+ &pos | &random | &trace | &subject[3:4] | &pos[1] |
+ s[3] | s[3:5] | &random[1] | &trace[1] | &subject[2:5][1])
+end
+
+procedure foo(s)
+ return s
+end
diff --git a/tests/general/tracer.std b/tests/general/tracer.std
new file mode 100644
index 0000000..bf778c8
--- /dev/null
+++ b/tests/general/tracer.std
@@ -0,0 +1,85 @@
+tracer.icn : 7 | tracer(1)
+tracer.icn : 20 | tracer suspended 1
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended 2
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended 3
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "abcdef"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "123456"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended 4
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended 0
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended -16
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "3"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "4"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "c"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "cd"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "0"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "-"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 20 | tracer suspended "2"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended 1
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended 2
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended (variable = 3)
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended (variable = "abcdef")
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended &subject = "123456"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended &pos = 4
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended &random = 0
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended &trace = -47
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended &subject[3] = "3"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended "4"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended "abcdef"[3] = "c"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended "abcdef"[3+:2] = "cd"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended "0"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended "-"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 23 | tracer suspended &subject[2] = "2"
+tracer.icn : 7 | tracer resumed
+tracer.icn : 26 | tracer failed
+tracer.icn : 8 | foo(4)
+tracer.icn : 29 | foo returned 4
+tracer.icn : 8 | foo("123456")
+tracer.icn : 29 | foo returned "123456"
+tracer.icn : 8 | foo("4")
+tracer.icn : 29 | foo returned "4"
+tracer.icn : 8 | foo("234")
+tracer.icn : 29 | foo returned "234"
+co-expression_1(1)
+
+main local identifiers:
+
+global identifiers:
+ display = function display
+ foo = procedure foo
+ main = procedure main
+ s = "abcdef"
+ tracer = procedure tracer
+ write = function write
+10
+tracer.icn
+1
+tracer.icn : 13 main failed
diff --git a/tests/general/transmit.dat b/tests/general/transmit.dat
new file mode 100644
index 0000000..cb238cb
--- /dev/null
+++ b/tests/general/transmit.dat
@@ -0,0 +1,4 @@
+Version 7 of Icon corrects a number of problems
+with co-expressions that existed in previous
+versions. The most significant one is proper
+handling of co-expression return points.
diff --git a/tests/general/transmit.icn b/tests/general/transmit.icn
new file mode 100644
index 0000000..512fc6b
--- /dev/null
+++ b/tests/general/transmit.icn
@@ -0,0 +1,29 @@
+global words, lines, writer
+
+procedure main()
+ if not(&features == "co-expressions") then
+ stop("co-expressions not supported")
+ &trace := -1
+
+ words := create word()
+ lines := create reader()
+ writer := create output()
+ @writer
+end
+
+procedure word()
+ static letters
+ initial letters := &lcase ++ &ucase
+ while line := @lines do
+ line ? while tab(upto(letters)) do
+ tab(many(letters)) @ writer
+end
+
+procedure reader()
+ while read() @ words
+end
+
+procedure output()
+ while write(&errout,@words)
+ @&main
+end
diff --git a/tests/general/transmit.std b/tests/general/transmit.std
new file mode 100644
index 0000000..fefb3cb
--- /dev/null
+++ b/tests/general/transmit.std
@@ -0,0 +1,104 @@
+transmit.icn : 11 | main; co-expression_1 : &null @ co-expression_4
+transmit.icn : 10 | output()
+transmit.icn : 27 | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 8 | | word()
+transmit.icn : 17 | | | word; co-expression_2 : &null @ co-expression_3
+transmit.icn : 9 | | | reader()
+transmit.icn : 23 | | | | reader; co-expression_3 : "Version 7 of Ico..." @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "Version" @ co-expression_4
+Version
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "of" @ co-expression_4
+of
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "Icon" @ co-expression_4
+Icon
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "corrects" @ co-expression_4
+corrects
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "a" @ co-expression_4
+a
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "number" @ co-expression_4
+number
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "of" @ co-expression_4
+of
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "problems" @ co-expression_4
+problems
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 17 | | | | word; co-expression_2 : &null @ co-expression_3
+transmit.icn : 23 | | | | reader; co-expression_3 : "with co-expressi..." @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "with" @ co-expression_4
+with
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "co" @ co-expression_4
+co
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "expressions" @ co-expression_4
+expressions
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "that" @ co-expression_4
+that
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "existed" @ co-expression_4
+existed
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "in" @ co-expression_4
+in
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "previous" @ co-expression_4
+previous
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 17 | | | | word; co-expression_2 : &null @ co-expression_3
+transmit.icn : 23 | | | | reader; co-expression_3 : "versions. The mo..." @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "versions" @ co-expression_4
+versions
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "The" @ co-expression_4
+The
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "most" @ co-expression_4
+most
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "significant" @ co-expression_4
+significant
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "one" @ co-expression_4
+one
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "is" @ co-expression_4
+is
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "proper" @ co-expression_4
+proper
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 17 | | | | word; co-expression_2 : &null @ co-expression_3
+transmit.icn : 23 | | | | reader; co-expression_3 : "handling of co-e..." @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "handling" @ co-expression_4
+handling
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "of" @ co-expression_4
+of
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "co" @ co-expression_4
+co
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "expression" @ co-expression_4
+expression
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "return" @ co-expression_4
+return
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 19 | | | | word; co-expression_2 : "points" @ co-expression_4
+points
+transmit.icn : 27 | | | | output; co-expression_4 : &null @ co-expression_2
+transmit.icn : 17 | | | | word; co-expression_2 : &null @ co-expression_3
+transmit.icn : 24 | | | reader failed
+transmit.icn : 9 | | | main; co-expression_3 failed to co-expression_2
+transmit.icn : 20 | | word failed
+transmit.icn : 8 | | main; co-expression_2 failed to co-expression_4
+transmit.icn : 28 | | output; co-expression_4 : &null @ co-expression_1
+transmit.icn : 12 | main failed
diff --git a/tests/general/trim.icn b/tests/general/trim.icn
new file mode 100644
index 0000000..1ec221e
--- /dev/null
+++ b/tests/general/trim.icn
@@ -0,0 +1,14 @@
+#SRC: JCON
+
+procedure main()
+ write(image(trim("abc ")))
+ write(image(trim("abc ", ' ')))
+ write(image(trim("abc ", 'x')))
+ write(image(trim("abc ", 'abc ')))
+ write(image(trim("a c ", ' ')))
+ write(image(trim("a c", ' ')))
+ write(image(trim(" ", ' ')))
+ write(image(trim(" ", ' ')))
+ write(image(trim("", ' ')))
+ write(image(trim("")))
+end
diff --git a/tests/general/trim.std b/tests/general/trim.std
new file mode 100644
index 0000000..161bde1
--- /dev/null
+++ b/tests/general/trim.std
@@ -0,0 +1,10 @@
+"abc"
+"abc"
+"abc "
+""
+"a c"
+"a c"
+""
+""
+""
+""
diff --git a/tests/general/var.icn b/tests/general/var.icn
new file mode 100644
index 0000000..3762944
--- /dev/null
+++ b/tests/general/var.icn
@@ -0,0 +1,69 @@
+#SRC: V9GEN
+
+procedure main(a)
+ local x, l0, l1, l2, l3, l4, l5, l6, l7, l8, l9
+ static y
+ variable("a") := 1
+ variable("x") := 2
+ variable("y") := 3
+ if variable("z") then write("oops z")
+ &subject := "abcde"
+ &pos := 3
+ write("&pos &subject: ", &pos, " ", variable("&subject"))
+ variable("&subject") := "wxyz"
+ write("&pos &subject: ", &pos, " ", variable("&subject"))
+ if variable("&clock") then write("oops &clock")
+ main2()
+ write()
+
+ # test display()
+ # some formats should differ from those of image()
+ l0 := []
+ l1 := [&letters -- 'jJ']
+ l2 := ["supercalifragilistic", "expialidocious"]
+ l3 := [&phi, &e, &pi]
+ l4 := [1,2,3,4]
+ l5 := [1,2,3,4,5]
+ l6 := [1,2,3,4,5,6]
+ l7 := [1,2,3,4,5,6,7]
+ l8 := [1,2,3,4,5,6,7,8]
+ l9 := [l0, l1, l2, l3, l4, l5, l6, l7, l8]
+ recurse(1, 4)
+end
+
+record complex(r,i)
+
+procedure main2(a)
+ local T, L, L1
+ static s
+ every write(image(name(main | T | L | s | a)))
+ T := table()
+ L := list(200)
+ L1 := []
+ every 1 to 200 do push(L1,1)
+ write(image(L[10]))
+ write(image(name(&error)))
+ write(image(name(T["abc"])))
+ T["abc"] := 1
+ write(image(name(T["abc"])))
+ every write(image(name(L[1 | 2 | 3 | -1 | -10])))
+ every write(image(name(L1[1 | 2 | 3 | -1 | -10])))
+ write(image(name(complex().r)))
+ return
+end
+
+procedure recurse(a,b) # to build up some context for display()
+ local x, y
+ x := a + b
+ y := a - b
+ if a < 5 then
+ recurse(a + 1, b + a)
+ else {
+ write(repl('-',70))
+ display(3, &output)
+ write(repl('-',70))
+ display(, &output)
+ write(repl('-',70))
+ }
+ return
+end
diff --git a/tests/general/var.std b/tests/general/var.std
new file mode 100644
index 0000000..892c350
--- /dev/null
+++ b/tests/general/var.std
@@ -0,0 +1,114 @@
+&pos &subject: 3 abcde
+&pos &subject: 1 wxyz
+"main"
+"T"
+"L"
+"s"
+"a"
+&null
+"&error"
+"T[\"abc\"]"
+"T[\"abc\"]"
+"L[1]"
+"L[2]"
+"L[3]"
+"L[200]"
+"L[191]"
+"L[1]"
+"L[2]"
+"L[3]"
+"L[200]"
+"L[191]"
+"complex.r"
+
+----------------------------------------------------------------------
+co-expression_1(1)
+
+recurse local identifiers:
+ a = 5
+ b = 14
+ x = 19
+ y = -9
+recurse local identifiers:
+ a = 4
+ b = 10
+ x = 14
+ y = -6
+recurse local identifiers:
+ a = 3
+ b = 7
+ x = 10
+ y = -4
+
+global identifiers:
+ complex = record constructor complex
+ display = function display
+ image = function image
+ list = function list
+ main = procedure main
+ main2 = procedure main2
+ name = function name
+ push = function push
+ recurse = procedure recurse
+ repl = function repl
+ table = function table
+ variable = function variable
+ write = function write
+----------------------------------------------------------------------
+co-expression_1(1)
+
+recurse local identifiers:
+ a = 5
+ b = 14
+ x = 19
+ y = -9
+recurse local identifiers:
+ a = 4
+ b = 10
+ x = 14
+ y = -6
+recurse local identifiers:
+ a = 3
+ b = 7
+ x = 10
+ y = -4
+recurse local identifiers:
+ a = 2
+ b = 5
+ x = 7
+ y = -3
+recurse local identifiers:
+ a = 1
+ b = 4
+ x = 5
+ y = -3
+main local identifiers:
+ a = 1
+ x = 2
+ l0 = list_4 = []
+ l1 = list_5 = ['ABCDEFGHIKLMNOPQ...']
+ l2 = list_6 = ["supercalifragili...","expialidocious"]
+ l3 = list_7 = [1.618033989,2.718281828,3.141592654]
+ l4 = list_8 = [1,2,3,4]
+ l5 = list_9 = [1,2,3,4,5]
+ l6 = list_10 = [1,2,3,4,5,6]
+ l7 = list_11 = [1,2,3,...,5,6,7]
+ l8 = list_12 = [1,2,3,...,6,7,8]
+ l9 = list_13 = [list_4 = [],list_5(1),list_6(2),...,list_10(6),list_11(7),list_12(8)]
+ y = 3
+
+global identifiers:
+ complex = record constructor complex
+ display = function display
+ image = function image
+ list = function list
+ main = procedure main
+ main2 = procedure main2
+ name = function name
+ push = function push
+ recurse = procedure recurse
+ repl = function repl
+ table = function table
+ variable = function variable
+ write = function write
+----------------------------------------------------------------------
diff --git a/tests/general/wordcnt.dat b/tests/general/wordcnt.dat
new file mode 100644
index 0000000..da17d7a
--- /dev/null
+++ b/tests/general/wordcnt.dat
@@ -0,0 +1,23 @@
+#
+# W O R D T A B U L A T I O N
+#
+
+# This main procedure processes standard input and writes the results
+# with the words in a column 20 characters wide.
+
+procedure main()
+ wordcount(20)
+end
+
+procedure wordcount(n)
+ local t, line, x, y
+ static letters
+ initial letters := &lcase ++ &ucase
+ t := table(,0)
+ every line := !&input do
+ scan line using
+ while tab(upto(letters)) do
+ t[tab(many(letters))] +:= 1
+ x := sort(t)
+ every y := !x do write(left(y[1],n),y[2])
+end
diff --git a/tests/general/wordcnt.icn b/tests/general/wordcnt.icn
new file mode 100644
index 0000000..2f0882f
--- /dev/null
+++ b/tests/general/wordcnt.icn
@@ -0,0 +1,24 @@
+#
+# W O R D C O U N T I N G
+#
+
+# This program tabulates the words in standard input and writes the
+# results with the words in a column 20 characters wide. The definition
+# of a "word" is naive.
+
+procedure main()
+ wordcount(20)
+end
+
+procedure wordcount(n)
+ local t, line, x, i
+ static letters
+ initial letters := &lcase ++ &ucase
+ t := table(0)
+ while line := read() do
+ line ? while tab(upto(letters)) do
+ t$<tab(many(letters))$> +:= 1
+ x := sort(t,3)
+ every i := 1 to *x - 1 by 2 do
+ write(left(x$<i$>,n),x$<i + 1$>)
+end
diff --git a/tests/general/wordcnt.std b/tests/general/wordcnt.std
new file mode 100644
index 0000000..ddfab34
--- /dev/null
+++ b/tests/general/wordcnt.std
@@ -0,0 +1,53 @@
+A 2
+B 1
+D 1
+I 1
+L 1
+N 1
+O 2
+R 1
+T 2
+This 1
+U 1
+W 1
+a 1
+and 1
+characters 1
+column 1
+do 3
+end 2
+every 2
+in 1
+initial 1
+input 2
+lcase 1
+left 1
+letters 4
+line 3
+local 1
+main 2
+many 1
+n 2
+procedure 3
+processes 1
+results 1
+scan 1
+sort 1
+standard 1
+static 1
+t 4
+tab 2
+table 1
+the 2
+ucase 1
+upto 1
+using 1
+while 1
+wide 1
+with 1
+wordcount 2
+words 1
+write 1
+writes 1
+x 3
+y 4