File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,9 @@ printExpression expression =
32
32
intercalate
33
33
" "
34
34
[printExpression a, printOperator operator, printExpression b]
35
+ String' string -> show string
36
+ Call name args ->
37
+ s name ++ " (" ++ intercalate " , " (map printExpression args) ++ " )"
35
38
_ -> error $ " not implemented " ++ show expression
36
39
37
40
printOperator :: OperatorExpr -> String
Original file line number Diff line number Diff line change @@ -52,6 +52,26 @@ javaScriptSyntaxSpecs =
52
52
]
53
53
expected = " function test(a, b) { return a + b }"
54
54
in printModule code `shouldBe` expected
55
+ it " prints a function that returns a string" $ do
56
+ let code =
57
+ Module
58
+ [Function $ Declaration Nothing (ne " test" ) [] (String' " hey" )]
59
+ expected = " function test() { return \" hey\" }"
60
+ in printModule code `shouldBe` expected
61
+ it " prints a function call with arguments" $ do
62
+ let code =
63
+ Module
64
+ [ Function $
65
+ Declaration
66
+ Nothing
67
+ (ne " test" )
68
+ [ne " a" , ne " b" ]
69
+ (Call
70
+ (ne " func" )
71
+ [(Identifier (ne " a" )), (Identifier (ne " b" ))])
72
+ ]
73
+ expected = " function test(a, b) { return func(a, b) }"
74
+ in printModule code `shouldBe` expected
55
75
56
76
ne :: String -> Ident
57
77
ne = Ident . NonEmptyString . NE. fromList
You can’t perform that action at this time.
0 commit comments