Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove readlink -f from test scripts.

Clean up tokenizer-test.sh
Hide successful test output.
  • Loading branch information...
commit e028db56fc3bf1f7e28b6b58f8a9d19edcfe57cc 1 parent 31f6152
@medgar123 medgar123 authored
View
4 all-tests.sh
@@ -1,8 +1,6 @@
#! /usr/bin/env bash
-__filename=`readlink -f $0`
-__dirname=`dirname $__filename`
-cd $__dirname
+cd ${0%/*}
#set -e
fail=0
View
15 test/invalid-test.sh
@@ -1,15 +1,7 @@
#! /usr/bin/env bash
-__filename=`readlink -f $0`
-__dirname=`dirname $__filename`
-cd $__dirname
+cd ${0%/*}
-echo _=$_
-echo 0=$0
-echo __filename=$__filename
-echo __dirname=$__dirname
-echo PWD=$PWD
-#env
fails=0
for input in invalid/*
do
@@ -20,11 +12,6 @@ do
cat outlog
echo "<<<"
let fails=$fails+1
-# else
-# echo "OK: cat $input | ../bin/json_parse failed correctly"
-# echo "stderr was >>>"
-# cat errlog
-# echo "<<<"
fi
done
echo "$fails test(s) failed"
View
26 test/parse-test.sh 100644 → 100755
@@ -1,12 +1,24 @@
+#! /usr/bin/env bash
-__filename=`readlink -f $0`
-__dirname=`dirname $__filename`
-cd $__dirname
+cd ${0%/*}
. ../parse.sh
-cat ../package.json | tokenize | parse
+ptest () {
+ tokenize | parse >/dev/null
+}
-#echo '"oooo" ' | tokenize | parse
-echo '[true, 1, [0, {}]] ' | tokenize | parse
-echo '{"true": 1}' | tokenize | parse
+fails=0
+for input in '"oooo" ' '[true, 1, [0, {}]] ' '{"true": 1}'
+do
+ echo "$input" | ptest || let fails=$fails+1
+done
+
+if ! ptest < ../package.json
+then
+ echo "Parsing package.json failed!"
+ let fails=$fails+1
+fi
+
+echo "$fails test(s) failed"
+exit $fails
View
78 test/tokenizer-test.sh 100644 → 100755
@@ -1,40 +1,50 @@
#! /usr/bin/env bash
-__filename=`readlink -f $0`
-__dirname=`dirname $__filename`
-cd $__dirname
+cd ${0%/*}
. ../parse.sh
set -e
-diff <( echo '"dah"' | tokenize ) <( echo '"dah"' )
-diff <( echo '""' | tokenize ) <( echo '""' )
-diff <( echo '["dah"]' | tokenize ) <( printf '[\n\"dah\"\n]\n' )
-diff <( echo '" "' | tokenize ) <( printf '" "\n' )
-diff <( printf '" \\" "' | tokenize ) <( printf '" \\" "\n' )
-
-diff \
-<( echo '["dah"]' | tokenize ) \
-<( echo \
-'[
-"dah"
-]')
-
-diff <( echo '123' | tokenize ) <( echo '123' )
-diff <( echo '123.142' | tokenize ) <( echo '123.142' )
-diff <( echo '-123' | tokenize ) <( echo '-123')
-
-#diff <( echo '1e23' | tokenize ) <( printf '1e23\n' )
-diff <( echo '0.1' | tokenize ) <( echo '0.1' )
-diff <( echo '-110' | tokenize ) <( echo '-110' )
-diff <( echo '-110.10' | tokenize ) <( echo '-110.10' )
-diff <( echo '-110e10' | tokenize ) <( echo '-110e10' )
-diff <( echo 'null' | tokenize ) <( echo 'null' )
-diff <( echo 'true' | tokenize ) <( echo 'true' )
-diff <( echo 'false' | tokenize ) <( echo 'false' )
-diff <( echo '[ null , -110e10, "null" ]' \
- | tokenize ) <( printf '[\nnull\n,\n-110e10\n,\n"null"\n]\n' )
-diff <( echo '{"e": false}' | tokenize ) <( printf '{\n"e"\n:\nfalse\n}\n' )
-diff <( echo '{"e": "string"}' | tokenize ) <( printf '{\n"e"\n:\n"string"\n}\n' )
-
-cat ../package.json | tokenize
+ttest () {
+ local input="$1"; shift
+ local expected="$(printf '%s\n' "$@")"
+ if ! echo "$input" | tokenize |diff -u - <(echo "$expected")
+ then
+ let fails=$fails+1
+ fi
+}
+
+fails=0
+ttest '"dah"' '"dah"'
+ttest '""' '""'
+ttest '["dah"]' '[' '"dah"' ']'
+ttest '" "' '" "'
+ttest '" \" "' '" \" "'
+
+ttest '["dah"]' '[' '"dah"' ']'
+
+ttest '123' '123'
+ttest '123.142' '123.142'
+ttest '-123' '-123'
+
+ttest '1e23' '1e23'
+ttest '0.1' '0.1'
+ttest '-110' '-110'
+ttest '-110.10' '-110.10'
+ttest '-110e10' '-110e10'
+ttest 'null' 'null'
+ttest 'true' 'true'
+ttest 'false' 'false'
+ttest '[ null , -110e10, "null" ]' \
+ '[' 'null' ',' '-110e10' ',' '"null"' ']'
+ttest '{"e": false}' '{' '"e"' ':' 'false' '}'
+ttest '{"e": "string"}' '{' '"e"' ':' '"string"' '}'
+
+if ! cat ../package.json | tokenize >/dev/null
+then
+ let fails=$fails+1
+ echo "Tokenizing package.json failed!"
+fi
+
+echo "$fails test(s) failed"
+exit $fails
View
6 test/valid-test.sh
@@ -1,8 +1,6 @@
+#! /usr/bin/env bash
-__filename=`readlink -f $0`
-__dirname=`dirname $__filename`
-
-cd $__dirname
+cd ${0%/*}
set -e
fails=0
Please sign in to comment.
Something went wrong with that request. Please try again.