Commit 7143f498 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Fix serializing of empty return statement.

parent 5f43cebf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ module JsDuck
        to_s(ast["label"]) + ": " + to_s(ast["body"])

      when "ReturnStatement"
        "return " + to_s(ast["argument"]) + ";"
        arg = ast["argument"] ? to_s(ast["argument"]) : ""
        "return " + arg + ";"

      when "SwitchStatement"
        "switch (" + to_s(ast["discriminant"]) + ") {" + ast["cases"].map {|c| to_s(c) }.join + "}"
+4 −0
Original line number Diff line number Diff line
@@ -112,6 +112,10 @@ describe JsDuck::Serializer do
      test("switch (foo) {case 1: case 2: alert(1);break;default: alert(2);}")
    end

    it "empty return statement" do
      test("function foo() {return ;}")
    end

    it "for statement" do
      test("for (var i = 0; i < 10; i++) {}")
    end