<commit_before>#!/bin/sh

TOTAL=0
SUCCESS=0
FAILED=0

SDB=`dirname $0`/../../src/sdb

if [ ! -x $SDB ]; then
	echo "Cannot find ${SDB}"
	exit 1
fi

run() {
	K="$1"
	A=`echo "$K" | $SDB -`
	B="`echo \"$2\"`"
	GREEN="\x1b[32m"
	RED="\x1b[31m"
	RESET="\x1b[0m"
	if [ "$A" = "$B" ]; then
		echo "   ${GREEN}OK${RESET}  - "`printf -- "$B"`\
			" = "`printf -- "$K"`
		SUCCESS=$((${SUCCESS}+1))
	else
		echo " ${RED}ERROR${RESET} - "`printf -- "$B"`" = "\
			`printf -- "$K"`"  =>  "`printf -- "$A"`
		FAILED=$((${FAILED}+1))
	fi
}

title() {
	echo "------------------------------------------------"
	printf "|                                              |\r"
	echo "| $1 |"
	echo "------------------------------------------------"
}

title "Strings"
run "K=V\nK\nV" V
run "K=V\n+K=Y\nK" VY
run "K=V\nK=Y\nK" Y

title "References"
run 'K=V\nV=$K\nV' V
run 'K=V\n$K=$K\nV' V
run 'K=V\n$K=$K\n$K' V

title "Numbers"
run "K=0\n+K" 1
run "K=1\n-K" 0
run "K=0\n-K" 0
run "K=0\n+K=1\nK" 1
run "K=0\n+K=2\nK" 2
run "K=10\n-K=4\nK" 6
run "K=0\n-K=10\nK" 0
run "K=-1\n+K" 0

title "Arrays"
run "[]K=1,2,3\n[?]K" 3
run "[]K=1,2,3\n[1]K=9\n[]K" "1\n9\n3"
run "[]K=1,2,3\n[1]K" 2
run "[]K=1,2,3\n[-]K\n[]K" "3\n1\n2"
run "[]K=1,2,3\n[+]K\n[]K" "1\n2\n3"
run "[]K=1,2,3\n[-1]K" "3"
run "[]K=1,2,3\n[-1]K\n[?]K" "3\n2"
run "[]K=1,2,3\n[-1]K=\n[]K" "3\n2"
run "[]K=1,2,3\n[+1]K=a\n[]K" "1\na\n2\n3"
run "[]K=1,2,3\n[0]K" 1
run "[]K=1,2,3\n[4]K" ''
run "[]K=1,2\n[+]K=3\n[]K" '1\n2\n3'
#run "[]K=a,b,c\n(-b)K\nK" "a\nc"
run "[]K=a,b,c\n[-]K=b\n[]K" "a\nc"

title "Stack"
run "[]K=\n[+]K=1\nK" 1
run "[]K=\n[+]K=1\n[+]K=2\n[]K" "1\n2"
run "[]K=1,2,3\n[-]K\n[?]K" "3\n2"
run "[]K=1,2,3\n[-]K\n[]K" "3\n1\n2" # XXX
run "[]K=1,2,3\n[-]K\n[+]K=4\n[]K" "3\n1\n2\n4"

title "JSON"
run 'foo=[1,2,3]\nfoo?[1]' 2
run 'foo=[1,2,3]\n+foo?[1]\nfoo?[1]' "3\n3"<commit_msg>Add some tests<commit_after>#!/bin/sh

TOTAL=0
SUCCESS=0
FAILED=0

SDB=`dirname $0`/../../src/sdb

if [ ! -x $SDB ]; then
	echo "Cannot find ${SDB}"
	exit 1
fi

run() {
	K="$1"
	A=`echo "$K" | $SDB -`
	B="`echo \"$2\"`"
	GREEN="\x1b[32m"
	RED="\x1b[31m"
	RESET="\x1b[0m"
	if [ "$A" = "$B" ]; then
		echo "   ${GREEN}OK${RESET}  - "`printf -- "$B"`\
			" = "`printf -- "$K"`
		SUCCESS=$((${SUCCESS}+1))
	else
		echo " ${RED}ERROR${RESET} - "`printf -- "$B"`" = "\
			`printf -- "$K"`"  =>  "`printf -- "$A"`
		FAILED=$((${FAILED}+1))
	fi
}

title() {
	echo "------------------------------------------------"
	printf "|                                              |\r"
	echo "| $1 |"
	echo "------------------------------------------------"
}

title "Strings"
run "K=V\nK\nV" V
run "K=V\n+K=Y\nK" VY
run "K=V\nK=Y\nK" Y
run "K=Hello\nK" Hello
run "K=V\n+K= Y\nK" 'V Y'

title "References"
run 'K=V\nV=$K\nV' V
run 'K=V\n$K=$K\nV' V
run 'K=V\nY=$K\nY' V
run 'K=V\n$K=$K\n$K' V
run 'V=$K\nV' '$K'

title "Numbers"
run "K=0\n+K" 1
run "K=1\n-K" 0
run "K=0\n-K" 0
run "K=0\n+K=1\nK" 1
run "K=0\n+K=2\nK" 2
run "K=10\n-K=4\nK" 6
run "K=0\n-K=10\nK" 0
run "K=-1\n+K" 0
run "K=-2\n+K" -1
run "K=0\n+-+-+K" 1
run "K=18446744073709551615\n+K\n" 0

title "Arrays"
run "[]K=1,2,3\n[?]K" 3
run "[]K=1,2,3\n[1]K=9\n[]K" "1\n9\n3"
run "[]K=1,2,3\n[1]K" 2
run "[]K=1,2,3\n[-]K\n[]K" "3\n1\n2"
run "[]K=1,2,3\n[+]K\n[]K" "1\n2\n3"
run "[]K=1,2,3\n[-1]K" "3"
run "[]K=1,2,3\n[-1]K\n[?]K" "3\n2"
run "[]K=1,2,3\n[-1]K=\n[]K" "3\n2"
run "[]K=1,2,3\n[+1]K=a\n[]K" "1\na\n2\n3"
run "[]K=1,2,3\n[0]K" 1
run "[]K=1,2,3\n[4]K" ''
run "[]K=1,2\n[+]K=3\n[]K" '1\n2\n3'
#run "[]K=a,b,c\n(-b)K\nK" "a\nc"
run "[]K=a,b,c\n[-]K=b\n[]K" "a\nc"

title "Stack"
run "[]K=\n[+]K=1\nK" 1
run "[]K=\n[+]K=1\n[+]K=2\n[]K" "1\n2"
run "[]K=1,2,3\n[-]K\n[?]K" "3\n2"
run "[]K=1,2,3\n[-]K\n[]K" "3\n1\n2" # XXX
run "[]K=1,2,3\n[-]K\n[+]K=4\n[]K" "3\n1\n2\n4"

title "JSON"
run 'foo=[1,2,3]\nfoo?[1]' 2
run 'foo=[1,2,3]\n+foo?[1]\nfoo?[1]' "3\n3"
{'fraction_non_alphanumeric': 0.3922896587653035, 'fraction_numerical': 0.08205261786923677, 'mean_word_length': 2.5424354243542435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1631379', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2335, 'n_words': 372}