mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-25 20:51:43 +03:00
[ fix #1626 ] Empty lines are still lines
This commit is contained in:
parent
b16a1297b6
commit
8fde63396e
@ -572,12 +572,13 @@ mutual
|
||||
|
||||
trimLeft : Nat -> List PStr -> Core (List PStr)
|
||||
trimLeft indent [] = pure []
|
||||
trimLeft indent [(StrLiteral fc str)]
|
||||
trimLeft indent [StrLiteral fc str]
|
||||
= let (trimed, rest) = splitAt indent (fastUnpack str) in
|
||||
if any (not . isSpace) trimed
|
||||
then throw $ BadMultiline fc "Line is less indented than the closing delimiter"
|
||||
else pure $ [StrLiteral fc (fastPack rest)]
|
||||
trimLeft indent ((StrLiteral fc str)::xs)
|
||||
else let str = if null rest then "\n" else fastPack rest in
|
||||
pure [StrLiteral fc str]
|
||||
trimLeft indent (StrLiteral fc str :: xs)
|
||||
= let (trimed, rest) = splitAt indent (fastUnpack str) in
|
||||
if any (not . isSpace) trimed || length trimed < indent
|
||||
then throw $ BadMultiline fc "Line is less indented than the closing delimiter"
|
||||
|
@ -42,7 +42,8 @@ idrisTestsBasic = MkTestPool "Fundamental language features" [] Nothing
|
||||
"basic051", "basic052", "basic053", "basic054", "basic055",
|
||||
"basic056", "basic057", "basic058", "basic059", "basic060",
|
||||
"basic061", "basic062", "basic063",
|
||||
"interpolation001", "interpolation002", "interpolation003"]
|
||||
"interpolation001", "interpolation002", "interpolation003",
|
||||
"interpolation004"]
|
||||
|
||||
idrisTestsCoverage : TestPool
|
||||
idrisTestsCoverage = MkTestPool "Coverage checking" [] Nothing
|
||||
|
20
tests/idris2/interpolation004/StringLiteral.idr
Normal file
20
tests/idris2/interpolation004/StringLiteral.idr
Normal file
@ -0,0 +1,20 @@
|
||||
module StringLiteral
|
||||
|
||||
Str : String
|
||||
Str = """
|
||||
First line
|
||||
|
||||
Third line
|
||||
"""
|
||||
|
||||
Str2NL : String
|
||||
Str2NL = "First line\n\nThird line"
|
||||
|
||||
sss : Str === Str2NL
|
||||
sss = Refl
|
||||
|
||||
Str1NL : String
|
||||
Str1NL = "First line\nThird line"
|
||||
|
||||
sss' : (Str == Str1NL) === False
|
||||
sss' = Refl
|
1
tests/idris2/interpolation004/expected
Normal file
1
tests/idris2/interpolation004/expected
Normal file
@ -0,0 +1 @@
|
||||
1/1: Building StringLiteral (StringLiteral.idr)
|
3
tests/idris2/interpolation004/run
Executable file
3
tests/idris2/interpolation004/run
Executable file
@ -0,0 +1,3 @@
|
||||
rm -rf build
|
||||
|
||||
$1 --no-color --console-width 0 --no-banner --check StringLiteral.idr
|
Loading…
Reference in New Issue
Block a user