|
@@ -25,6 +25,9 @@ func TestQuote(t *testing.T) {
|
|
|
// Double quote when there is unprintable char.
|
|
|
Args("a\nb").Rets(`"a\nb"`),
|
|
|
Args("\x1b\"\\").Rets(`"\e\"\\"`),
|
|
|
+ Args("\x00").Rets(`"\x00"`),
|
|
|
+ Args("\u0600").Rets(`"\u0600"`), // Arabic number sign
|
|
|
+ Args("\U000110BD").Rets(`"\U000110bd"`), // Kathi number sign
|
|
|
|
|
|
// Commas and equal signs are always quoted, so that the quoted string is
|
|
|
// safe for use everywhere.
|
|
@@ -33,6 +36,21 @@ func TestQuote(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+func TestQuoteAs(t *testing.T) {
|
|
|
+ Test(t, Fn("QuoteAs", QuoteAs).ArgsFmt("(%q, %s)").RetsFmt("(%q, %s)"), Table{
|
|
|
+ // DoubleQuote is always respected.
|
|
|
+ Args("", DoubleQuoted).Rets(`""`, DoubleQuoted),
|
|
|
+ Args("a", DoubleQuoted).Rets(`"a"`, DoubleQuoted),
|
|
|
+
|
|
|
+ // SingleQuoted is respected when there is no unprintable character.
|
|
|
+ Args("", SingleQuoted).Rets(`''`, SingleQuoted),
|
|
|
+ Args("a", SingleQuoted).Rets(`'a'`, SingleQuoted),
|
|
|
+ Args("\n", SingleQuoted).Rets(`"\n"`, DoubleQuoted),
|
|
|
+
|
|
|
+ // Bareword tested above in TestQuote.
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
func TestQuoteVariableName(t *testing.T) {
|
|
|
Test(t, Fn("QuoteVariableName", QuoteVariableName).ArgsFmt("(%q)").RetsFmt("%q"), Table{
|
|
|
Args("").Rets("''"),
|