[ fix #1626 ] Empty lines are still lines

This commit is contained in:
Guillaume ALLAIS 2021-10-18 23:12:48 +01:00 committed by G. Allais
parent b16a1297b6
commit 8fde63396e
5 changed files with 35 additions and 9 deletions

View File

@ -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"

View File

@ -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

View 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

View File

@ -0,0 +1 @@
1/1: Building StringLiteral (StringLiteral.idr)

View File

@ -0,0 +1,3 @@
rm -rf build
$1 --no-color --console-width 0 --no-banner --check StringLiteral.idr