shithub: mc

ref: cf50193c7dc0c13d373d60982e7cb95168e0167e
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.eq("'word'", s), "mismatched escape")
			std.slfree(s)
		}],
		[.name="twowords", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("two words"))
			testr.check(ctx, std.eq("'two words'", s), "mismatched escape")
			std.slfree(s)
		}],
		[.name="simplequote", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("two'words"))
			testr.check(ctx, std.eq("'two'\\''words'", s), "mismatched escape")
			std.slfree(s)
		}],
		[.name="quotequote", .fn={ctx
			var s = std.fmt("{}", escfmt.sh("two'\\''words"))
			testr.check(ctx, std.eq("'two'\\''\\'\\'''\\''words'", s), "mismatched escape")
			std.slfree(s)
		}]
	][:])
}