Hello,

attached is a patch with a test script for find.

It tests only the expression handling and uses only primaries which are
currently implemented in the find toy.

Felix
# HG changeset patch
# User Felix Janda <felix.ja...@posteo.de>
# Date 1365936336 -7200
# Node ID c2a5fd17d7885f99d74304458c07245b2b336eea
# Parent  db9878df884a93d895a0662f972e5c8827b0f073
Add tests for find's expression parsing

diff -r db9878df884a -r c2a5fd17d788 scripts/test/find.test
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/test/find.test	Sun Apr 14 12:45:36 2013 +0200
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+[ -f testing.sh ] && . testing.sh
+
+mkdir dir
+cd dir
+touch file
+mkfifo fifo
+ln -s fifo link
+cd ..
+
+#testing "name" "command" "result" "infile" "stdin"
+
+# Testing operators
+
+testing "find -type l -a -type d -o -type p" \
+	"find dir -type l -a -type d -o -type p" "dir/fifo\n" "" ""
+testing "find -type l -type d -o -type p" "find dir -type l -type d -o -type p" \
+	"dir/fifo\n" "" ""
+testing "find -type l -o -type d -a -type p" \
+	"find dir -type l -o -type d -a -type p" "dir/link\n" "" ""
+testing "find -type l -o -type d -type p" "find dir -type l -o -type d -type p" \
+	"dir/link\n" "" ""
+testing "find -type l ( -type d -o -type l )" \
+	"find dir -type l \( -type d -o -type l \)" "dir/link\n" "" ""
+testing "find extra parantheses" \
+	"find dir \( \( -type l \) \( -type d -o \( \( -type l \) \) \) \)" \
+	"dir/link\n" "" ""
+testing "find ( -type p -o -type d ) -type p" \
+	"find dir \( -type p -o -type d \) -type p" "dir/fifo\n" "" ""
+testing "find -type l -o -type d -type p -o -type f" \
+	"find dir -type l -o -type d -type p -o -type f | sort" \
+	"dir/file\ndir/link\n" "" ""
+
+# Testing short-circuit evaluations
+
+testing "find -type f -a -print" \
+	"find dir -type f -a -print" "dir/file\n" "" ""
+testing "find -print -o -print" \
+	"find dir -type f -a \( -print -o -print \)" "dir/file\n" "" ""
+
+rm -rf dir
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to