Loading lib/jsduck/serializer.rb +2 −1 Original line number Diff line number Diff line Loading @@ -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 + "}" Loading spec/serializer_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
lib/jsduck/serializer.rb +2 −1 Original line number Diff line number Diff line Loading @@ -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 + "}" Loading
spec/serializer_spec.rb +4 −0 Original line number Diff line number Diff line Loading @@ -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 Loading