@@ -95,7 +95,11 @@ spec = do
9595 it "parses when all uppercase" caseUppercaseBool
9696 it "parses when titlecase" caseTitlecaseBool
9797 describe "empty input" $ do
98− it "doesn't crash" caseEmptyInput
98+ it "parses as Null" caseEmptyInput
99+ it "parses as Null from file" caseEmptyInputFile
100+ describe "comment only input" $ do
101+ it "parses as Null" caseCommentOnlyInput
102+ it "parses as Null from file" caseCommentOnlyInputFile
99103 describe "alias stripping" $ do
100104 it "works" caseStripAlias
101105 describe "nulls" $ do
@@ -457,7 +461,20 @@ caseUppercaseBool = D.decode "foo: FALSE\nbar: Y\nbaz: ON" @?= obj
457461caseTitlecaseBool = D.decode "foo: No\nbar: Yes\nbaz: True" @?= obj
458462
459463caseEmptyInput :: Assertion
460−caseEmptyInput = D.decode B8.empty @?= (Nothing :: Maybe D.Value)
464+caseEmptyInput = D.decodeEither B8.empty @?= Right D.Null
465+
466+caseEmptyInputFile :: Assertion
467+caseEmptyInputFile = do
468+ out <- D.decodeFileEither "test/resources/empty.yaml"
469+ either (Left . D.prettyPrintParseException) Right out @?= Right D.Null
470+
471+caseCommentOnlyInput :: Assertion
472+caseCommentOnlyInput = D.decodeEither "# comment\n" @?= Right D.Null
473+
474+caseCommentOnlyInputFile :: Assertion
475+caseCommentOnlyInputFile = do
476+ out <- D.decodeFileEither "test/resources/empty2.yaml"
477+ either (Left . D.prettyPrintParseException) Right out @?= Right D.Null
461478
462479checkNull :: T.Text -> Spec
463480checkNull x =