-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix bug with : #40
base: master
Are you sure you want to change the base?
Fix bug with : #40
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,7 +299,9 @@ recordOrString indent indent_ = | |
let | ||
withString string = | ||
P.oneOf | ||
[ P.succeed (Ast.fromString string) | ||
[ P.succeed (Ast.Record_ (Dict.singleton ":" Ast.Null_)) | ||
|. P.end | ||
, P.succeed (Ast.fromString string) | ||
|. P.end | ||
, recordProperty indent_ string | ||
, P.succeed (addRemaining string) | ||
|
@@ -312,24 +314,13 @@ recordOrString indent indent_ = | |
] | ||
|
||
addRemaining string remaining = | ||
Ast.fromString <| U.postProcessString (removeComment string ++ remaining) | ||
|
||
removeComment string = | ||
string | ||
|> String.split "#" | ||
|> List.head | ||
|> Maybe.withDefault "" | ||
Ast.String_ (string ++ remaining) | ||
Comment on lines
-315
to
+317
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unrelated? Why is |
||
in | ||
P.oneOf | ||
[ quotedString indent_ | ||
, P.succeed identity | ||
|. P.chompIf (U.neither U.isColon U.isNewLine) | ||
|. P.chompWhile (U.neither U.isColon U.isNewLine) | ||
|> P.getChompedString | ||
|> P.andThen withString | ||
[ P.succeed Ast.Null_ | ||
|. P.end | ||
, P.succeed identity | ||
|. P.chompWhile U.isColon | ||
|> P.getChompedString | ||
|= U.characters (not << U.isColon) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I see what you're going for here but |
||
|> P.andThen withString | ||
] | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -557,11 +557,10 @@ aaa: bbb""" | |
""" | ||
aaa: { key1: value1, key1: value2 } | ||
""" | ||
|
||
-- TODO: This is temporarily removed because it is a valid test case that should pass | ||
-- , Test.test "weird colon record" <| | ||
-- \_ -> | ||
-- expectValue "::" <| Ast.Record_ (Dict.singleton ":" Ast.Null_) | ||
, Test.test "colon as key" <| | ||
\_ -> | ||
expectValue "::" <| | ||
Ast.Record_ (Dict.singleton ":" Ast.Null_) | ||
Comment on lines
-560
to
+563
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! |
||
] | ||
|
||
|
||
|
@@ -573,12 +572,12 @@ expectRawAst subject expected = | |
|
||
expectValue : String -> Ast.Value -> Expect.Expectation | ||
expectValue subject expected = | ||
case ( Parser.fromString subject, expected ) of | ||
( Ok (Ast.Float_ got), Ast.Float_ want ) -> | ||
expectCloseTo got want | ||
case (Parser.fromString subject, expected) of | ||
(Ok got, _) -> | ||
Expect.equal got expected | ||
|
||
( got, _ ) -> | ||
Expect.equal got (Ok expected) | ||
(Err err, _) -> | ||
Expect.fail err | ||
Comment on lines
-576
to
+580
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is incorrect. Comparing floating point values for equality should be done more carefully. Also, such a change should be done in another PR since it is unrelated to colon keys. Once again, I think I see where you're going and, in principle, I would accept this function being cleaned up a bit but please do this in a separate RP. |
||
|
||
|
||
expectErr : String -> Expect.Expectation | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem right. Where is the parser consuming a ":" character?