summaryrefslogtreecommitdiff
path: root/lib/regex/test/basic.myr
blob: 506b7c0702e4d958f5bb73a739d6a0139096005f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std

use "testmatch"

const main = {
	var s : byte[:]
		
	s = std.strjoin([
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
	][:], "")
	std.put("hi\n")
	testmatch(".*bc", "Abc", `std.Some [][:])
	std.put("1\n")
	dbgmatch("(a*)*", "a", `std.Some ["a"][:])
	std.put("2\n")
	testmatch("(aa|aab?)*", s, `std.Some ["aa"][:])
	std.put("3\n")
        /* greedy matches */
	testmatch("(<.*>).*", "<a foo> blah <bar>", `std.Some [
			"<a foo> blah <bar>",
		][:])
	std.put("3\n")
	testmatch("(<.+>).*", "<a foo> blah <bar>", `std.Some [
			"<a foo> blah <bar>",
		][:])
	std.put("4\n")
        /* reluctant matches */
	testmatch("(<.*?>).*", "<a foo> blah <bar>", `std.Some [
			"<a foo>",
		][:])
	std.put("5\n")
	testmatch("(<.+?>).*", "<a foo> blah <bar>", `std.Some [
			"<a foo>",
		][:])
	std.put("6\n")
}