tester(test:Expr):map:dynamic_scope = printf("%s .. %s\n", test, eval(test)):nomap

lambda {
	nLines = 0
	open("test-file.az").readlines():chop {|line|
		println(line)
		nLines += 1
	}
	printf("<nLines = %d>\n", nLines)
}()
lambda {
	tester(`os.glob("test-*.az"))
	tester(`os.glob("test-*.az") {|filename| string.upper(filename) })
	tester(`os.glob("test-*.az"):xlist {|filename|
		if (string.find(filename, "op")) { filename }
	})
}()
lambda {
	import(re)
	tester(`os.listdir("."):xlist {|filename|
		if (m = re.match(r"test-([^\.]*)", filename)) { m.group(1) }
	})
}()
lambda {
	tester(`os.path.match("foo*", ["foo", "FOObar", "bar"]))
	tester(`os.path.match("foo*", ["foo", "FOObar", "bar"]):icase)
}()
lambda {
	println(os.listdir(".") {|filename, i, dirFlag|
		chooseif(dirFlag, "[%s]", "%s") % filename
	})
	println(os.listdir(".") {|filename, i, dirFlag|
		chooseif(dirFlag, "[%s]", "%s") % filename
	})
}
lambda {
	stats = os.stat(os.glob("test-*.az"))
	println("sort by name")
	for (stat in sort(stats, &{$s1.basename() <=> $s2.basename()})) {
		printf("%-32s %s\n", stat.basename(), stat.mtime().format("%Y-%m-%d %H:%M:%S"))
	}
	println("sort by creation time")
	for (stat in sort(stats, &{$s1.mtime() <=> $s2.mtime()})) {
		printf("%-32s %s\n", stat.basename(), stat.mtime().format("%Y-%m-%d %H:%M:%S"))
	}
}
<nLines = 46>
os.glob("test-*.az") .. ["test-application.az", "test-block.az", "test-csv.az", "test-declaration.az", "test-Dict.az", "test-diff.az", "test-emf.az", "test-error.az", "test-file.az", "test-filter.az", "test-formatter.az", "test-function.az", "test-List.az", "test-map.az", "test-module.az", "test-object.az", "test-operator.az", "test-optimize.az", "test-re.az", "test-repeater.az", "test-string.az", "test-value.az", "test-xml.az"]
os.glob("test-*.az") {|filename| string.upper(filename) } .. ["TEST-APPLICATION.AZ", "TEST-BLOCK.AZ", "TEST-CSV.AZ", "TEST-DECLARATION.AZ", "TEST-DICT.AZ", "TEST-DIFF.AZ", "TEST-EMF.AZ", "TEST-ERROR.AZ", "TEST-FILE.AZ", "TEST-FILTER.AZ", "TEST-FORMATTER.AZ", "TEST-FUNCTION.AZ", "TEST-LIST.AZ", "TEST-MAP.AZ", "TEST-MODULE.AZ", "TEST-OBJECT.AZ", "TEST-OPERATOR.AZ", "TEST-OPTIMIZE.AZ", "TEST-RE.AZ", "TEST-REPEATER.AZ", "TEST-STRING.AZ", "TEST-VALUE.AZ", "TEST-XML.AZ"]
os.glob("test-*.az"):xlist {|filename| if (string.find(filename, "op")) { filename } } .. ["test-operator.az", "test-optimize.az"]
os.listdir("."):xlist {|filename| if (m = re.match("test-([^\\.]*)", filename)) { m.group(1) } } .. ["application", "block", "csv", "declaration", "Dict", "diff", "emf", "error", "file", "filter", "formatter", "function", "List", "map", "module", "object", "operator", "optimize", "re", "repeater", "string", "value", "xml"]
os.path.match("foo*", ["foo", "FOObar", "bar"]) .. [true, false, false]
os.path.match("foo*", ["foo", "FOObar", "bar"]):icase .. [true, true, false]
