shithub: mc

Download patch

ref: 506ccbf40f4a7f7e0fde363294744312e5bcf9cf
parent: 683cad57a0ba46f692208394b187e94c9eaea70f
author: Ori Bernstein <[email protected]>
date: Wed Jan 29 10:05:48 EST 2014

Make the test output more useful.

    It now says what the pattern and the text was, and indents the
    matches for easier scanning by eye.

--- a/test/data/regex-basic-expected
+++ b/test/data/regex-basic-expected
@@ -1,8 +1,8 @@
-Matched. 1 matches
-match 0: Abc
-Matched. 2 matches
-match 0: a
-match 1: a
-Matched. 2 matches
-match 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-match 1: aa
+Matched Abc via .*bc : 1
+	match 0: Abc
+Matched a via (a*)* : 2
+	match 0: a
+	match 1: a
+Matched aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa via (aa|aab?)* : 2
+	match 0: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+	match 1: aa
--- a/test/data/regex-capture-expected
+++ b/test/data/regex-capture-expected
@@ -1,18 +1,18 @@
-Matched. 2 matches
-match 0: Abc
-match 1: bc
-Matched. 2 matches
-match 0: Abcde
-match 1: bcd
-Matched. 2 matches
-match 0: abab
-match 1: b
-Matched. 3 matches
-match 0: Abcde
-match 1: c
-match 2: bcd
-Matched. 4 matches
-match 0: aaaa
-match 1: a
-match 2: aaa
-match 3: 
+Matched Abc via A(.*) : 2
+	match 0: Abc
+	match 1: bc
+Matched Abcde via A(.*)e : 2
+	match 0: Abcde
+	match 1: bcd
+Matched abab via (a|b)+ : 2
+	match 0: abab
+	match 1: b
+Matched Abcde via A(b(.*)d)e : 3
+	match 0: Abcde
+	match 1: c
+	match 2: bcd
+Matched aaaa via (a?)(a*)(a?) : 4
+	match 0: aaaa
+	match 1: a
+	match 2: aaa
+	match 3: 
--- a/test/data/regex-class-expected
+++ b/test/data/regex-class-expected
@@ -1,51 +1,56 @@
-Matched. 1 matches
-match 0: 1
-Matched. 1 matches
-match 0: 13
-Matched. 1 matches
-match 0: 13688
-No match
-No match
-No match
-Matched. 1 matches
-match 0: a
-Matched. 1 matches
-match 0: 1F
-Matched. 1 matches
-match 0: 13b8cDEf
-No match
-No match
-No match
-Matched. 1 matches
-match 0:  
-Matched. 1 matches
-match 0: 	
+Matched 1 via \d : 1
+	match 0: 1
+Matched 13 via \d\d : 1
+	match 0: 13
+Matched 13688 via \d+ : 1
+	match 0: 13688
+No match of x via \d
+No match of x3 via \d\d
+No match of 1368f via \d+
+Matched a via \x : 1
+	match 0: a
+Matched 1F via \x\x : 1
+	match 0: 1F
+Matched 13b8cDEf via \x+ : 1
+	match 0: 13b8cDEf
+No match of Z via \x
+No match of fg via \x\x
+No match of 13b8cg via \x+
+Matched   via \s : 1
+	match 0:  
+Matched 	
+ via \s\s : 1
+	match 0: 	
 
-Matched. 1 matches
-match 0: 	
+Matched 	
+
 	 via \s+ : 1
+	match 0: 	
 
 	
-No match
-No match
-No match
-Matched. 1 matches
-match 0: abcABC0123_
-No match
-Matched. 1 matches
-match 0:  
-Matched. 1 matches
-match 0: 	 
-Matched. 1 matches
-match 0: 	 	 
-No match
-No match
-No match
-Matched. 1 matches
-match 0: abcd
-Matched. 1 matches
-match 0: abCD
-Matched. 1 matches
-match 0: _abCD018
-Matched. 1 matches
-match 0: abba
-Matched. 1 matches
-match 0: abBa
+No match of a via \s
+No match of i
+ via \s\s
+No match of 	
+
.	 via \s+
+Matched abcABC0123_ via \w+ : 1
+	match 0: abcABC0123_
+No match of abcABC0123_. via \w+
+Matched   via \h : 1
+	match 0:  
+Matched 	  via \h\h : 1
+	match 0: 	 
+Matched 	 	  via \h+ : 1
+	match 0: 	 	 
+No match of 
+ via \h
+No match of 	
 via \h\h
+No match of 	 	. via \h+
+Matched abcd via [a-z]* : 1
+	match 0: abcd
+Matched abCD via [a-zA-Z]* : 1
+	match 0: abCD
+Matched _abCD018 via [a-zA-Z0-9_]* : 1
+	match 0: _abCD018
+Matched abba via [abc]* : 1
+	match 0: abba
+Matched abBa via [a-zABC]* : 1
+	match 0: abBa
--- a/test/data/regex-failmatch-expected
+++ b/test/data/regex-failmatch-expected
@@ -1,1 +1,1 @@
-No match
+No match of Abc via .*bcd
--- a/test/data/regex-negclass-expected
+++ b/test/data/regex-negclass-expected
@@ -1,50 +1,54 @@
-Matched. 1 matches
-match 0: x
-Matched. 1 matches
-match 0: xa!#^cs
-No match
-No match
-No match
-No match
-Matched. 1 matches
-match 0: Z
-Matched. 1 matches
-match 0: gg
-No match
-No match
-Matched. 1 matches
-match 0: a
-Matched. 1 matches
-match 0: i%
-Matched. 1 matches
-match 0: alskd690!#!!
-No match
-No match
-No match
-Matched. 1 matches
-match 0: !%!^^@@!^
-No match
-Matched. 1 matches
-match 0: 
+Matched x via \D : 1
+	match 0: x
+Matched xa!#^cs via \D+ : 1
+	match 0: xa!#^cs
+No match of 0 via \D
+No match of 9 via \D
+No match of a35x via \D+
+No match of 13688 via \D+
+Matched Z via \X : 1
+	match 0: Z
+Matched gg via \X\X : 1
+	match 0: gg
+No match of a via \X
+No match of zz13b8cDEf via \X+
+Matched a via \S : 1
+	match 0: a
+Matched i% via \S\S : 1
+	match 0: i%
+Matched alskd690!#!! via \S+ : 1
+	match 0: alskd690!#!!
+No match of   via \S
+No match of 	
+ via \S\S
+No match of 	 
+kait via \S+
+Matched !%!^^@@!^ via \W+ : 1
+	match 0: !%!^^@@!^
+No match of a^#$bcABC0123_ via \W+
+Matched 
+ via \H : 1
+	match 0: 
 
-Matched. 1 matches
-match 0: 
+Matched 
+
 via \H\H : 1
+	match 0: 
 
-No match
-No match
-No match
-Matched. 1 matches
-match 0: ABCD
-Matched. 1 matches
-match 0: 1234
-Matched. 1 matches
-match 0: -^^-
-Matched. 1 matches
-match 0: d6d
-Matched. 1 matches
-match 0: !^!!))#
-No match
-No match
-No match
-No match
-No match
+No match of 	 	. via \H+
+No match of 	  via \H\H
+No match of 	a35 	  via \H+
+Matched ABCD via [^a-z]* : 1
+	match 0: ABCD
+Matched 1234 via [^a-zA-Z]* : 1
+	match 0: 1234
+Matched -^^- via [^a-zA-Z0-9_]* : 1
+	match 0: -^^-
+Matched d6d via [^abc]* : 1
+	match 0: d6d
+Matched !^!!))# via [^a-zABC]* : 1
+	match 0: !^!!))#
+No match of abcd via [^a-z]*
+No match of abCD via [^a-zA-Z]*
+No match of _abCD018 via [^a-zA-Z0-9_]*
+No match of abba via [^abc]*
+No match of abBa via [^a-zABC]*
--- a/test/data/regex-unicode-expected
+++ b/test/data/regex-unicode-expected
@@ -1,7 +1,7 @@
-Matched. 1 matches
-match 0: Abæc
+Matched Abæc via .*bæc : 1
+	match 0: Abæc
 s = L
 s = L
-Matched. 2 matches
-match 0: Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-match 1: Aa
+Matched Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! via (\p{L}*)bæc\P{L}* : 2
+	match 0: Aabæc%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+	match 1: Aa
--- a/test/regex-basic.myr
+++ b/test/regex-basic.myr
@@ -18,18 +18,6 @@
 		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
 		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
 		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
-		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
 	][:], "")
 	testmatch(".*bc", "Abc")
 	testmatch("(a*)*", "a")
--- a/test/testmatch.myr
+++ b/test/testmatch.myr
@@ -7,25 +7,25 @@
 ;;
 
 const testmatch = {pat, text
-	run(regex.compile(pat), text)
+	run(regex.compile(pat), pat, text)
 }
 
 const dbgmatch = {pat, text
-	run(regex.dbgcompile(pat), text)
+	run(regex.dbgcompile(pat), pat, text)
 }
 
-const run = {regex, text
+const run = {regex, pat, text
 	var i
 	match regex
 	| `std.Success re:
 		match regex.exec(re, text)
 		| `std.Some m:
-			std.put("Matched. %i matches\n", m.len)
+			std.put("Matched %s via %s : %i\n", text, pat, m.len)
 			for i = 0; i < m.len; i++
-				std.put("match %i: %s\n", i, m[i])
+				std.put("\tmatch %i: %s\n", i, m[i])
 			;;
 		| `std.None:
-			std.put("No match\n")
+			std.put("No match of %s via %s\n", text, pat)
 		;;
 		regex.free(re)
 	| `std.Failure err: