aboutsummaryrefslogtreecommitdiff
path: root/tests
blob: 54582e916eb08522bdbbf4c251f937b391dc1870 (plain) (blame)
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
#!/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