-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.sh
More file actions
executable file
·149 lines (132 loc) · 3.28 KB
/
Copy pathverify.sh
File metadata and controls
executable file
·149 lines (132 loc) · 3.28 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/sh
#Copyright (C) 2025 Ivan Gaydardzhiev
#Licensed under the GPL-3.0-only
G='\033[0;32m'
R='\033[0;31m'
N='\033[0m'
[ ! -f slug ] && make
fprint() {
printf "[%s] Test: %-20s Result: %b\n" "$(date '+%Y-%m-%d %H:%M:%S')" "${1}" "${2}"
}
test_ackermann() {
capture=$(./slug scripts/ackermann.slg)
[ "${capture}" = "1021" ] && {
fprint "Ackermann(3,7)" "${G}PASSED${N}";
return 0;
} || {
fprint "Ackermann(3,7)" "${R}FAILED${N}";
return 2;
}
}
test_increment() {
capture=$(./slug scripts/anon_func.slg)
[ "${capture}" = "8" ] && {
fprint "Increment" "${G}PASSED${N}";
return 0;
} || {
fprint "Increment" "${R}FAILED${N}";
return 3;
}
}
test_core_lang() {
expected="20\n1\n0\n1\n2\n3\n4\n20\n15\n42"
expected=$(printf '%b' "${expected}")
capture=$(./slug scripts/core_language_test.slg)
[ "${capture}" = "${expected}" ] && {
fprint "Core Language" "${G}PASSED${N}";
return 0;
} || {
fprint "Core Language" "${R}FAILED${N}";
return 4;
}
}
test_turing() {
capture=$(./slug scripts/turing.slg)
[ "${capture}" = "120" ] && {
fprint "Turing Completeness" "${G}PASSED${N}";
return 0;
} || {
fprint "Turing Completeness" "${R}FAILED${N}";
return 5;
}
}
test_hof() {
capture=$(./slug scripts/higher_order_functions_and_closures.slg)
[ "${capture}" = "25" ] && {
fprint "Higher Order" "${G}PASSED${N}";
return 0;
} || {
fprint "Higher Order" "${R}FAILED${N}";
return 6;
}
}
test_recursion() {
capture=$(./slug scripts/recursion.slg)
[ "${capture}" = "120" ] && {
fprint "Recursion" "${G}PASSED${N}";
return 0;
} || {
fprint "Recursion" "${R}FAILED${N}";
return 7;
}
}
test_demorgan() {
expected="true\ntrue\ntrue\ntrue\n"
expected=$(printf %b "${expected}")
capture=$(./slug scripts/demorgan_law.slg)
[ "${capture}" = "${expected}" ] && {
fprint "DeMorgan" "${G}PASSED${N}";
return 0;
} || {
fprint "DeMorgan" "${R}FAILED${N}";
return 8;
}
}
test_truth() {
expected="true\ntrue\ntrue\ntrue\n"
expected=$(printf %b "${expected}")
capture=$(./slug scripts/truth_table_testing.slg)
[ "${capture}" = "${expected}" ] && {
fprint "Truth Table" "${G}PASSED${N}";
return 0;
} || {
fprint "Truth Table" "${R}FAILED${N}";
return 9;
}
}
test_entscheidungs() {
capture=$(./slug scripts/entscheidungs_problem.slg)
[ "${capture}" = "0" ] && {
fprint "EntscheidungsProblem" "${G}CONFIRMED${N}";
return 0;
} || {
fprint "EntscheidungsProblem" "${R}REFUTED${N}";
return 10;
}
}
test_halting() {
capture=$(./slug scripts/halting_paradox.slg)
[ "${capture}" = "0" ] && {
fprint "Halting Paradox" "${G}CONFIRMED${N}";
return 0;
} || {
fprint "Halting Paradox" "${R}REFUTED${N}";
return 11;
}
}
test_purediag() {
exec 3>&2 2>/dev/null
./slug scripts/pure_diag.slg
capture="${?}"
exec 2>&3 3>&-
[ "${capture}" = "139" ] && {
fprint "Self Reference" "${G}CONFIRMED${N}";
return 0;
} || {
fprint "Self Reference" "${R}REFUTED${N}";
return 12;
}
}
#TODO: add verification functions for church_numerals.slg & collatz.slg & palindrome_checker.slg & godel.slg
{ test_ackermann && test_increment && test_core_lang && test_turing && test_hof && test_recursion && test_demorgan && test_truth && test_entscheidungs && test_halting && test_purediag; ret="${?}"; } || exit 1
[ "${ret}" -eq 0 ] 2>/dev/null || printf "%s\n" "${ret}"