shithub: mc

ref: 8e1bb5d4fc204ce149ceb545aef7b783d73641bc
dir: /lib/escfmt/test/escsh.myr/

View raw version
use std
use escfmt
use testr

const main = {
	testr.run([
		[.name="basic", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("word"))
			testr.check(ctx, std.sleq("'word'", s), "mismatched escape")
			std.slfree(s)
		}],
		[.name="twowords", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("two words"))
			testr.check(ctx, std.sleq("'two words'", s), "mismatched escape")
			std.slfree(s)
		}],
		[.name="simplequote", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("two'words"))
			testr.check(ctx, std.sleq("'two'\\''words'", s), "mismatched escape")
			std.slfree(s)
		}],
		[.name="quotequote", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("two'\\''words"))
			testr.check(ctx, std.sleq("'two'\\''\\'\\'''\\''words'", s), "mismatched escape")
			std.slfree(s)
		}]
	][:])
}