shithub: mc

ref: fdf87b91c1bbd64be75b8438ad6eaf492325e5b4
dir: /lib/regex/test/basic.myr/

View raw version
use std

use "testmatch"

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