echo T.utfre: tests of regular expression code for Unicode/utf-8
# adapted from T.re

awk '
BEGIN {
	FS = "\t"
	awk = "../a.out"
}
NF == 0 {
	next
}
$1 != "" {	# new test
	re = $1
}
$2 != "" {	# either ~ or !~
	op = $2
	if (op == "~")
		neg = "!"
	else if (op == "!~")
		neg = ""
}
$3 != "" {	# new test string
	str = $3
}
$3 == "\"\"" {	# explicit empty line
	$3 = ""
}
NF > 2 {	# generate a test
	input = $3
	test = sprintf("./echo '"'"'%s'"'"' | %s '"'"'%s/%s/ {print \"%d fails %s %s %s\"}'"'"'",
		input, awk, neg, re, NR, re, op, input)
	# printf(" %3d   %s %s %s:\n", NR, re, op, input)
	# print "test is |" test "|"
	system(test)
	# system("bprint -c ../a.out")
	nt++
}
END { print "	" nt, "tests" }
' <<\!!!!
	~	🖕
		🖕🖕
		🖕🖕🖕
		""
🖕	~	🖕
		b🖕
		b🖕b
	!~	""
		æ—¶
		xxxxx
.	~	æ—¶
		xæ—¶x
		🙂
	!~	""			
.の	~	xの
		xxの
		xのx
	!~	の
		のx
		""
$	~	x
		🙂
		""
.$	~	모
		xx모
		x모x
	!~	""
д$	~	д
		bд
		bbbд
	!~	дb
		x
		""
^	~	и
		""
		^
^λ$	~	λ
	!~	xλ
		λx
		xλx
		""
^λ.$	~	λx
		λλ
	!~	xλ
		λλλ
		λxy
		""
^$	~	""
	!~	に
		^
^.해	~	め해
		め해해
	!~	í•´
		""
^.*í•´	~	í•´
		め해
		めめめめめめ해
	!~	""
^.+해	~	め해
		めめめめめめ해
	!~	""
		í•´
		해め
í•´*	~	""
		í•´
		í•´í•´í•´í•´
		め해
		めめめめ
í•´í•´*	~	í•´
		í•´í•´í•´
		め해
	!~	めめめめ
		""
\$	~	🖕$
		$
		$🖕
		🖕$🖕
	!~	""
		🖕
\.	~	.
	!~	🖕
		""
xθ+y	~	xθy
		xθθy
		xθθθθθθy
	!~	θy
		xy
		xθ
xθ?y	~	xy
		xθy
	!~	xθθy
θ?b?の?	~	""
		x
^a?b?め	~	め
		aめ
		bめ
		abめ
		めa
	!~	""
		ab
		aba			
[Α-Ω]	~	Α
		aΔb
		xyΩ
	!~	abc
		β
		""
[^Α-Ω]	~	δ
		aΔb
		xyΩ
	!~	Α
		Δ
		""
[Α-ΔΦ-Ω]	~	Α
		Î’
		Δ
		Φ
		Ω
	!~	Π
		Σ
Π[[:lower:]]+	~	Πa
		Πab
	!~	Π
		ΠX
		Π:
		Π[
		Π]
の[0-9]+に	~	の0に
		の23に
		の12345に
	!~	0に
		のに
の[0-9]?に	~	のに
		の1に
	!~	の23に
の[[]に	~	の[に
	!~	のに
		の[[]に
		の]に
の[[-]に	~	の[に
		の-に
	!~	のに
		の[[]に
		の]に
の[[-a]に	~	の[に
		のaに
		の]に
	!~	のに
		の[[]に
		の-に
の[]-a]に	~	の]に
		のaに
	!~	のに
		の[に
		の-に
の[]]に	~	の]に
	!~	のに
		の[]]に
		の[に
の[^[]に	~	のaに
	!~	の[に
の[-]に	~	の-に
	!~	のに
		の+に
の[^-]に	~	の+に
	!~	の-に
		のに
の[][]に	~	の[に
		の]に
	!~	のに
		の][に
		の[]に
の[z-a]に	~	のに
	!~	の
		に
		のaに
		のzに
		の-に
に|だ	~	だ
		に
		だに
	!~	a
		""
^στο|τους$	~	στο
		στοd
		aτους
		τους
	!~	xστο
		τουςa
^(στο|τους)$	~	στο
		τους
	!~	στοτους
		στοx
		cτους
!!!!