diff --git a/src/Install/Library.elm b/src/Install/Library.elm index d98db17..a0779a8 100644 --- a/src/Install/Library.elm +++ b/src/Install/Library.elm @@ -348,6 +348,9 @@ expressionToString (Node _ expression) = RecordAccess child field -> expressionToString child ++ "." ++ Node.value field + Literal str -> + "\"" ++ str ++ "\"" + -- CaseExpression caseBlock -> -- "case " ++ expressionToString caseBlock.expression ++ " of " ++ String.join " " (List.map caseToString caseBlock.cases) -- LambdaExpression lambda -> diff --git a/tests/Install/ElementToListTest.elm b/tests/Install/ElementToListTest.elm index 1a06340..f218515 100644 --- a/tests/Install/ElementToListTest.elm +++ b/tests/Install/ElementToListTest.elm @@ -11,6 +11,7 @@ all = [ Run.testFix test1 , Run.expectNoErrorsTest "should not report error when the field already exists" src0 rule1 , Run.testFix test2 + , Run.testFix test4 ] @@ -127,3 +128,51 @@ contributors : List Contributors contributors = [ Jxx, Matt, Laozi ] """ + + + +-- TEST 4 + + +test4 = + { description = "should add an element to a list of tuples in project" + , src = src4 + , rule = rule4 + , under = under4 + , fixed = fixed4 + , message = "Add 2 elements to the list" + } + + +src4 = + """module Routes exposing (..) + +type Route + = HomepageRoute + | Quotes + +routesAndNames : List (Route, String) +routesAndNames = + [(HomepageRoute, "homepage")] +""" + + +rule4 = + makeRule "Routes" "routesAndNames" [ "(Quotes, \"quotes\")" ] + + +under4 = + """[(HomepageRoute, "homepage")]""" + + +fixed4 = + """module Routes exposing (..) + +type Route + = HomepageRoute + | Quotes + +routesAndNames : List (Route, String) +routesAndNames = + [(HomepageRoute, "homepage"), (Quotes, "quotes")] +"""