From 8a192b734e468efb758bd7ae8d843cc02f024454 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Wed, 15 Nov 2023 14:25:31 +0100
Subject: More testing

---
 test/idx_inc.blc         |  1 +
 test/idx_inc.blc.dump    | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/idx_open.blc        |  1 +
 test/idx_open.blc.dump   | 45 +++++++++++++++++++++++++++++++++++++++
 test/idx_simple.blc      |  1 +
 test/idx_simple.blc.dump | 45 +++++++++++++++++++++++++++++++++++++++
 test/idx_unbound.blc     |  1 +
 test/inc.blc             |  1 -
 test/open.blc            |  1 -
 test/parenting.blc       |  1 +
 test/run                 | 16 ++++++++++++++
 test/simple.blc          |  1 -
 12 files changed, 166 insertions(+), 3 deletions(-)
 create mode 100644 test/idx_inc.blc
 create mode 100644 test/idx_inc.blc.dump
 create mode 100644 test/idx_open.blc
 create mode 100644 test/idx_open.blc.dump
 create mode 100644 test/idx_simple.blc
 create mode 100644 test/idx_simple.blc.dump
 create mode 100644 test/idx_unbound.blc
 delete mode 100644 test/inc.blc
 delete mode 100644 test/open.blc
 create mode 100644 test/parenting.blc
 create mode 100755 test/run
 delete mode 100644 test/simple.blc

(limited to 'test')

diff --git a/test/idx_inc.blc b/test/idx_inc.blc
new file mode 100644
index 0000000..9cd3419
--- /dev/null
+++ b/test/idx_inc.blc
@@ -0,0 +1 @@
+0001000011000110
diff --git a/test/idx_inc.blc.dump b/test/idx_inc.blc.dump
new file mode 100644
index 0000000..bede771
--- /dev/null
+++ b/test/idx_inc.blc.dump
@@ -0,0 +1,55 @@
+[DEBUG] reading from inc.blc
+[DEBUG] referring head of 71eb
+[DEBUG] referring head of 76e3
+[DEBUG] reducing...
+[DEBUG] queue size: 1
+
+---
+Map dump:
+type	refs	hash	term                     parents
+1	1	bc00	[[1]]                    {([[1]] [1]), }
+1	1	d5b2	[([[1]] [1])]            {}
+1	2	76e3	[1]                      {[[1]], ([[1]] [1]), }
+2	1	49e4	([[1]] [1])              {[([[1]] [1])], }
+3	2	71eb	1                        {[1], }
+---
+
+[DEBUG] reducing 49e4
+[DEBUG] substituting bc00 with 76e3
+[DEBUG] substituting 76e3 with 76e3
+[DEBUG] substituting 71eb with 76e3
+[DEBUG] shifting 76e3
+[DEBUG] shifting 71eb
+[DEBUG] rehashing var 71eb (2)
+[DEBUG] dereferring head of 71eb
+[DEBUG] dereferring head of 71eb
+[DEBUG] rehashing abs 76e3 (ccd5)
+[DEBUG] dereferring head of 76e3
+[DEBUG] rehashing abs 76e3 (e935)
+[DEBUG] dereferring head of 76e3
+[DEBUG] rehashing parents of 276f
+[DEBUG] rehashing abs bc00 (276f)
+[DEBUG] dereferring head of bc00
+[DEBUG] destroying head of bc00
+[DEBUG] destroying head of 49e4
+[DEBUG] destroying head of d5b2
+[DEBUG] rehashing parents of ae76
+[DEBUG] no more redexes!
+
+---
+Map dump:
+type	refs	hash	term                     parents
+1	1	76e3	[1]                      {}
+3	1	ccd5	2                        {[2], }
+1	1	e935	[2]                      {[[2]], }
+1	1	ae76	[[[2]]]                  {}
+3	1	71eb	1                        {[1], }
+1	1	276f	[[2]]                    {[[[2]]], }
+---
+
+[DEBUG] destroying head of 76e3
+[DEBUG] destroying head of ccd5
+[DEBUG] destroying head of e935
+[DEBUG] destroying head of 276f
+[DEBUG] destroying head of ae76
+[DEBUG] destroying head of 71eb
diff --git a/test/idx_open.blc b/test/idx_open.blc
new file mode 100644
index 0000000..1540526
--- /dev/null
+++ b/test/idx_open.blc
@@ -0,0 +1 @@
+0001001111100000110
diff --git a/test/idx_open.blc.dump b/test/idx_open.blc.dump
new file mode 100644
index 0000000..94a265b
--- /dev/null
+++ b/test/idx_open.blc.dump
@@ -0,0 +1,45 @@
+[DEBUG] reading from open.blc
+[DEBUG] reducing...
+[DEBUG] queue size: 1
+
+---
+Map dump:
+type	refs	hash	term                     parents
+1	1	bc00	[[1]]                    {([4] [[1]]), }
+1	1	7573	[4]                      {([4] [[1]]), }
+1	1	76e3	[1]                      {[[1]], }
+1	1	3418	[([4] [[1]])]            {}
+3	1	71eb	1                        {[1], }
+3	1	c8dd	4                        {[4], }
+2	1	8cde	([4] [[1]])              {[([4] [[1]])], }
+---
+
+[DEBUG] reducing 8cde
+[DEBUG] substituting 7573 with bc00
+[DEBUG] substituting c8dd with bc00
+[DEBUG] shifting c8dd
+[DEBUG] rehashing var c8dd (3)
+[DEBUG] dereferring head of c8dd
+[DEBUG] dereferring head of 71eb
+[DEBUG] destroying head of 71eb
+[DEBUG] destroying head of 76e3
+[DEBUG] destroying head of bc00
+[DEBUG] destroying head of 8cde
+[DEBUG] destroying head of 3418
+[DEBUG] rehashing abs 7573 (5f3e)
+[DEBUG] dereferring head of 7573
+[DEBUG] destroying head of 7573
+[DEBUG] rehashing parents of f80c
+[DEBUG] dereferring head of c8dd
+[DEBUG] destroying head of c8dd
+[DEBUG] no more redexes!
+
+---
+Map dump:
+type	refs	hash	term                     parents
+1	1	f80c	[3]                      {}
+3	1	5f3e	3                        {[3], }
+---
+
+[DEBUG] destroying head of f80c
+[DEBUG] destroying head of 5f3e
diff --git a/test/idx_simple.blc b/test/idx_simple.blc
new file mode 100644
index 0000000..05c2b00
--- /dev/null
+++ b/test/idx_simple.blc
@@ -0,0 +1 @@
+000100100000110
diff --git a/test/idx_simple.blc.dump b/test/idx_simple.blc.dump
new file mode 100644
index 0000000..2adc459
--- /dev/null
+++ b/test/idx_simple.blc.dump
@@ -0,0 +1,45 @@
+[DEBUG] reading from simple.blc
+[DEBUG] reducing...
+[DEBUG] queue size: 1
+
+---
+Map dump:
+type	refs	hash	term                     parents
+1	1	bc00	[[1]]                    {([0] [[1]]), }
+1	1	76e3	[1]                      {[[1]], }
+2	1	4db9	([0] [[1]])              {[([0] [[1]])], }
+1	1	180b	[0]                      {([0] [[1]]), }
+3	1	71eb	1                        {[1], }
+1	1	4e2b	[([0] [[1]])]            {}
+3	1	b2bf	0                        {[0], }
+---
+
+[DEBUG] reducing 4db9
+[DEBUG] substituting 180b with bc00
+[DEBUG] substituting b2bf with bc00
+[DEBUG] shifting bc00
+[DEBUG] shifting 76e3
+[DEBUG] shifting 71eb
+[DEBUG] rehashing abs 180b (bc00)
+[DEBUG] dereferring head of 180b
+[DEBUG] destroying head of 180b
+[DEBUG] destroying head of 4db9
+[DEBUG] destroying head of 4e2b
+[DEBUG] rehashing parents of 7deb
+[DEBUG] dereferring head of b2bf
+[DEBUG] destroying head of b2bf
+[DEBUG] no more redexes!
+
+---
+Map dump:
+type	refs	hash	term                     parents
+1	1	bc00	[[1]]                    {[[[1]]], }
+1	1	76e3	[1]                      {[[1]], }
+3	1	71eb	1                        {[1], }
+1	1	7deb	[[[1]]]                  {}
+---
+
+[DEBUG] destroying head of bc00
+[DEBUG] destroying head of 7deb
+[DEBUG] destroying head of 76e3
+[DEBUG] destroying head of 71eb
diff --git a/test/idx_unbound.blc b/test/idx_unbound.blc
new file mode 100644
index 0000000..835abbb
--- /dev/null
+++ b/test/idx_unbound.blc
@@ -0,0 +1 @@
+01000000100010
diff --git a/test/inc.blc b/test/inc.blc
deleted file mode 100644
index 9cd3419..0000000
--- a/test/inc.blc
+++ /dev/null
@@ -1 +0,0 @@
-0001000011000110
diff --git a/test/open.blc b/test/open.blc
deleted file mode 100644
index 1540526..0000000
--- a/test/open.blc
+++ /dev/null
@@ -1 +0,0 @@
-0001001111100000110
diff --git a/test/parenting.blc b/test/parenting.blc
new file mode 100644
index 0000000..bc2a397
--- /dev/null
+++ b/test/parenting.blc
@@ -0,0 +1 @@
+01010010000000000111011110010010000000000111100111011110
diff --git a/test/run b/test/run
new file mode 100755
index 0000000..8822eb9
--- /dev/null
+++ b/test/run
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+FAIL="\033[0;31m[FAIL]\033[0m "
+SUCC="\033[0;32m[SUCC]\033[0m "
+
+# for file in *.blc; do
+for file in idx_open.blc idx_simple.blc; do
+	../build/calm "$file" &>../build/"$file".dump
+	cmp "$file".dump ../build/"$file".dump && printf "$SUCC" || printf "$FAIL"
+	echo "reduction of $file"
+	rm ../build/"$file".dump
+	valgrind --leak-check=full -s --error-exitcode=1 ../build/calm "$file" &>/dev/null && printf "$SUCC" || printf "$FAIL"
+	echo "memory failures of $file"
+done
diff --git a/test/simple.blc b/test/simple.blc
deleted file mode 100644
index 05c2b00..0000000
--- a/test/simple.blc
+++ /dev/null
@@ -1 +0,0 @@
-000100100000110
-- 
cgit v1.2.3