aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-08-04 23:40:12 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-08-04 23:40:12 +0200
commitda135c09210105ef11e8c096f23f3ffc125b7f60 (patch)
tree7321ee6ef1c7f9357964ff816f7970bf6e31f2a1
parentbd5414ecb2cfa9c22ad18f925a53d76dc10cc413 (diff)
Add some testsHEADmaster
Co-authored-by: Luca Matei Pintilie <luca@lucamatei.com>
-rwxr-xr-xtests92
1 files changed, 92 insertions, 0 deletions
diff --git a/tests b/tests
new file mode 100755
index 0000000..54582e9
--- /dev/null
+++ b/tests
@@ -0,0 +1,92 @@
+#!/bin/sh
+
+fail() {
+ echo "$1" >&2
+ exit 1
+}
+
+testmmv() {
+ DIR=test-mmv
+ mkdir -p $DIR
+ touch \
+ $DIR/bytecodeVm.c \
+ $DIR/fastLexer.c \
+ $DIR/fastLexer.h \
+ $DIR/slowParser.c \
+ $DIR/slowParser.h
+ ls $DIR/*.[ch] | mmv sed 's/[A-Z]/\L-&/g'
+ >/dev/null ls \
+ $DIR/bytecode-vm.c \
+ $DIR/fast-lexer.c \
+ $DIR/fast-lexer.h \
+ $DIR/slow-parser.c \
+ $DIR/slow-parser.h \
+ || fail 'Missing lispcase files'
+ 2>/dev/null ls \
+ $DIR/bytecodeVm.c \
+ $DIR/fastLexer.c \
+ $DIR/fastLexer.h \
+ $DIR/slowParser.c \
+ $DIR/slowParser.h \
+ && fail 'Camelcase files not properly deleted'
+ return 0
+}
+
+testmcp() {
+ DIR=test-mcp
+ mkdir -p $DIR
+ touch \
+ $DIR/bytecodeVm.c \
+ $DIR/fastLexer.c \
+ $DIR/fastLexer.h \
+ $DIR/slowParser.c \
+ $DIR/slowParser.h
+ ls $DIR/*.[ch] | mcp sed 's/[A-Z]/\L-&/g'
+ >/dev/null ls \
+ $DIR/bytecode-vm.c \
+ $DIR/fast-lexer.c \
+ $DIR/fast-lexer.h \
+ $DIR/slow-parser.c \
+ $DIR/slow-parser.h \
+ || fail 'Missing lispcase files'
+ >/dev/null ls \
+ $DIR/bytecodeVm.c \
+ $DIR/fastLexer.c \
+ $DIR/fastLexer.h \
+ $DIR/slowParser.c \
+ $DIR/slowParser.h \
+ || fail 'Camelcase files not found'
+ return 0
+}
+
+testmmvbasename() {
+ DIR=test-mmv-basename
+ mkdir -p $DIR
+ touch \
+ $DIR/bytecode-vm.c \
+ $DIR/fast-lexer.c \
+ $DIR/fast-lexer.h \
+ $DIR/slow-parser.c \
+ $DIR/slow-parser.h
+ ls $DIR/*.[ch] | mmv --basename tr a-z A-Z
+ >/dev/null ls \
+ $DIR/BYTECODE-VM.C \
+ $DIR/FAST-LEXER.C \
+ $DIR/FAST-LEXER.H \
+ $DIR/SLOW-PARSER.C \
+ $DIR/SLOW-PARSER.H \
+ || fail 'Uppercase files not found'
+ 2>/dev/null ls \
+ $DIR/bytecode-vm.c \
+ $DIR/fast-lexer.c \
+ $DIR/fast-lexer.h \
+ $DIR/slow-parser.c \
+ $DIR/slow-parser.h \
+ && fail 'Lowercase files found'
+ return 0
+}
+
+trap 'rm -rf test-mmv test-mcp test-mmv-basename' EXIT
+testmmv
+testmcp
+testmmvbasename