mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 16:56:29 +03:00
test for dissalow multiline string without newline
This commit is contained in:
parent
a8514bd7d7
commit
dda71684bb
@ -196,7 +196,8 @@ data CustomType
|
||||
-- EXPRESSIONS
|
||||
|
||||
data Expr
|
||||
= Let Let Row Col
|
||||
= ExpressionBadEnd Row Col
|
||||
| Let Let Row Col
|
||||
| Case Case Row Col
|
||||
| If If Row Col
|
||||
| Parenthesized Parenthesized Row Col
|
||||
@ -2598,6 +2599,8 @@ isWithin desiredNode context =
|
||||
toExprReport :: Code.Source -> Context -> Expr -> Row -> Col -> Report.Report
|
||||
toExprReport source context expr startRow startCol =
|
||||
case expr of
|
||||
ExpressionBadEnd row col ->
|
||||
toWeirdEndReport source row col
|
||||
Let let_ row col ->
|
||||
toLetReport source context let_ row col
|
||||
Case case_ row col ->
|
||||
|
@ -7,9 +7,14 @@ import Data.ByteString qualified as BS
|
||||
import Data.Utf8 qualified as Utf8
|
||||
import Helpers.Instances ()
|
||||
import Helpers.Parse qualified as Helpers
|
||||
import Parse.Expression qualified as Expression
|
||||
import Parse.Pattern qualified as Pattern
|
||||
import Parse.Primitives qualified as P
|
||||
import Repl (Input (Help))
|
||||
import Reporting.Error.Syntax (Expr (ExpressionBadEnd))
|
||||
import Reporting.Error.Syntax qualified as Error.Syntax
|
||||
import Test.Hspec (Spec, describe, it)
|
||||
import Test.Hspec qualified as Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
@ -17,12 +22,12 @@ spec = do
|
||||
it "regression test" $
|
||||
parse
|
||||
"normal string"
|
||||
"\"\"\"normal string\"\"\""
|
||||
"\"\"\"\nnormal string\"\"\""
|
||||
|
||||
it "mixing quotes work" $ do
|
||||
parse
|
||||
"string with \" in it"
|
||||
"\"\"\"string with \" in it\"\"\""
|
||||
"\"\"\"\nstring with \" in it\"\"\""
|
||||
|
||||
it "first newline, and leading whitespace, is dropped" $ do
|
||||
parse
|
||||
@ -39,6 +44,11 @@ spec = do
|
||||
"this is\\na test"
|
||||
"\"\"\"\n this is\n a test\n\"\"\""
|
||||
|
||||
it "does not allow non-newline characters on the first line" $ do
|
||||
let isCorrectError ((Error.Syntax.String Error.Syntax.StringMultilineWithoutLeadingNewline _ _)) = True
|
||||
isCorrectError _ = False
|
||||
Helpers.checkParseError Expression.expression ExpressionBadEnd isCorrectError "\"\"\"this is not allowed\"\"\""
|
||||
|
||||
parse :: String -> BS.ByteString -> IO ()
|
||||
parse expectedStr =
|
||||
let isExpectedString :: Src.Pattern_ -> Bool
|
||||
|
Loading…
Reference in New Issue
Block a user