From da135c09210105ef11e8c096f23f3ffc125b7f60 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sun, 4 Aug 2024 23:40:12 +0200 Subject: Add some tests Co-authored-by: Luca Matei Pintilie --- tests | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 tests 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 -- cgit v1.2.3