Break out eval-okay-ind-string into separate tests
This commit is contained in:
parent
bac581a183
commit
375e6025d3
|
@ -0,0 +1,19 @@
|
|||
let
|
||||
|
||||
s1 = ''
|
||||
This is an indented multi-line string
|
||||
literal. An amount of whitespace at
|
||||
the start of each line matching the minimum
|
||||
indentation of all lines in the string
|
||||
literal together will be removed. Thus,
|
||||
in this case four spaces will be
|
||||
stripped from each line, even though
|
||||
THIS LINE is indented six spaces.
|
||||
|
||||
Also, empty lines don't count in the
|
||||
determination of the indentation level (the
|
||||
previous empty line has indentation 0, but
|
||||
it doesn't matter).
|
||||
'';
|
||||
|
||||
in s1
|
|
@ -0,0 +1,9 @@
|
|||
let
|
||||
|
||||
s2 = '' If the string starts with whitespace
|
||||
followed by a newline, it's stripped, but
|
||||
that's not the case here. Two spaces are
|
||||
stripped because of the " " at the start.
|
||||
'';
|
||||
|
||||
in s2
|
|
@ -0,0 +1,8 @@
|
|||
let
|
||||
|
||||
s3 = ''
|
||||
This line is indented
|
||||
a bit further.
|
||||
''; # indentation of last line doesn't count if it's empty
|
||||
|
||||
in s3
|
|
@ -0,0 +1,8 @@
|
|||
let
|
||||
|
||||
s4 = ''
|
||||
Anti-quotations, like ${if true then "so" else "not so"}, are
|
||||
also allowed.
|
||||
'';
|
||||
|
||||
in s4
|
|
@ -0,0 +1,11 @@
|
|||
let
|
||||
|
||||
s5 = ''
|
||||
The \ is not special here.
|
||||
' can be followed by any character except another ', e.g. 'x'.
|
||||
Likewise for $, e.g. $$ or $varName.
|
||||
But ' followed by ' is special, as is $ followed by {.
|
||||
If you want them, use anti-quotations: ${"''"}, ${"\${"}.
|
||||
'';
|
||||
|
||||
in s5
|
|
@ -0,0 +1,10 @@
|
|||
let
|
||||
|
||||
s6 = ''
|
||||
Tabs are not interpreted as whitespace (since we can't guess
|
||||
what tab settings are intended), so don't use them.
|
||||
This line starts with a space and a tab, so only one
|
||||
space will be stripped from each line.
|
||||
'';
|
||||
|
||||
in s6
|
|
@ -0,0 +1,8 @@
|
|||
let
|
||||
|
||||
s7 = ''
|
||||
Also note that if the last line (just before the closing ' ')
|
||||
consists only of whitespace, it's ignored. But here there is
|
||||
some non-whitespace stuff, so the line isn't removed. '';
|
||||
|
||||
in s7
|
|
@ -0,0 +1,9 @@
|
|||
let
|
||||
|
||||
s8 = '' ${""}
|
||||
This shows a hacky way to preserve an empty line after the start.
|
||||
But there's no reason to do so: you could just repeat the empty
|
||||
line.
|
||||
'';
|
||||
|
||||
in s8
|
|
@ -0,0 +1,9 @@
|
|||
let
|
||||
|
||||
s9 = ''
|
||||
${""} Similarly you can force an indentation level,
|
||||
in this case to 2 spaces. This works because the anti-quote
|
||||
is significant (not whitespace).
|
||||
'';
|
||||
|
||||
in s9
|
|
@ -0,0 +1,6 @@
|
|||
let
|
||||
|
||||
s10 = ''
|
||||
'';
|
||||
|
||||
in s10
|
|
@ -0,0 +1,5 @@
|
|||
let
|
||||
|
||||
s11 = '''';
|
||||
|
||||
in s11
|
|
@ -0,0 +1,5 @@
|
|||
let
|
||||
|
||||
s12 = '' '';
|
||||
|
||||
in s12
|
|
@ -0,0 +1,36 @@
|
|||
let
|
||||
|
||||
s13 = ''
|
||||
start on network-interfaces
|
||||
|
||||
start script
|
||||
|
||||
rm -f /var/run/opengl-driver
|
||||
${if true
|
||||
then "ln -sf 123 /var/run/opengl-driver"
|
||||
else if true
|
||||
then "ln -sf 456 /var/run/opengl-driver"
|
||||
else ""
|
||||
}
|
||||
|
||||
rm -f /var/log/slim.log
|
||||
|
||||
end script
|
||||
|
||||
env SLIM_CFGFILE=${"abc"}
|
||||
env SLIM_THEMESDIR=${"def"}
|
||||
env FONTCONFIG_FILE=/etc/fonts/fonts.conf # !!! cleanup
|
||||
env XKB_BINDIR=${"foo"}/bin # Needed for the Xkb extension.
|
||||
env LD_LIBRARY_PATH=${"libX11"}/lib:${"libXext"}/lib:/usr/lib/ # related to xorg-sys-opengl - needed to load libglx for (AI)GLX support (for compiz)
|
||||
|
||||
${if true
|
||||
then "env XORG_DRI_DRIVER_PATH=${"nvidiaDrivers"}/X11R6/lib/modules/drivers/"
|
||||
else if true
|
||||
then "env XORG_DRI_DRIVER_PATH=${"mesa"}/lib/modules/dri"
|
||||
else ""
|
||||
}
|
||||
|
||||
exec ${"slim"}/bin/slim
|
||||
'';
|
||||
|
||||
in s13
|
|
@ -0,0 +1,9 @@
|
|||
let
|
||||
|
||||
s14 = ''
|
||||
Escaping of ' followed by ': '''
|
||||
Escaping of $ followed by {: ''${
|
||||
And finally to interpret \n etc. as in a string: ''\n, ''\r, ''\t.
|
||||
'';
|
||||
|
||||
in s14
|
|
@ -0,0 +1,10 @@
|
|||
let
|
||||
|
||||
# Regression test: antiquotation in '${x}' should work, but didn't.
|
||||
s15 = let x = "bla"; in ''
|
||||
foo
|
||||
'${x}'
|
||||
bar
|
||||
'';
|
||||
|
||||
in s15
|
|
@ -0,0 +1,8 @@
|
|||
let
|
||||
|
||||
# Regression test: accept $'.
|
||||
s16 = ''
|
||||
cut -d $'\t' -f 1
|
||||
'';
|
||||
|
||||
in s16
|
|
@ -0,0 +1,6 @@
|
|||
let
|
||||
|
||||
# Accept dollars at end of strings
|
||||
s17 = ''ending dollar $'' + ''$'' + "\n";
|
||||
|
||||
in s17
|
Loading…
Reference in New Issue