Loading lib/jsduck/ast.rb +1 −1 Original line number Diff line number Diff line Loading @@ -383,7 +383,7 @@ module JsDuck end def make_default(ast) ast && to_value(ast) ? to_s(ast) : nil ast && to_value(ast) != nil ? to_s(ast) : nil end def make_value_type(ast) Loading spec/aggregator_default_values_spec.rb +14 −1 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ describe JsDuck::Aggregator do end end describe "cfg with explicit boolean default value" do describe "cfg with explicit boolean true default value" do before do @doc = parse(<<-EOS)[0] /** Loading @@ -187,6 +187,19 @@ describe JsDuck::Aggregator do end end describe "cfg with explicit boolean false default value" do before do @doc = parse(<<-EOS)[0] /** * @cfg {Number} [foo=false] Something */ EOS end it "has default value" do @doc[:default].should == "false" end end describe "cfg with explicit array default value" do before do @doc = parse(<<-EOS)[0] Loading spec/ast_property_spec.rb +12 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,18 @@ describe "JsDuck::Ast detects property with" do detect("/** */ foo = 15;")[:default].should == "15" end it "assignment with number 0" do detect("/** */ foo = 0;")[:default].should == "0" end it "assignment with boolean true" do detect("/** */ foo = true;")[:default].should == "true" end it "assignment with boolean false" do detect("/** */ foo = false;")[:default].should == "false" end it "assignment with regex" do detect("/** */ foo = /abc/;")[:default].should == "/abc/" end Loading Loading
lib/jsduck/ast.rb +1 −1 Original line number Diff line number Diff line Loading @@ -383,7 +383,7 @@ module JsDuck end def make_default(ast) ast && to_value(ast) ? to_s(ast) : nil ast && to_value(ast) != nil ? to_s(ast) : nil end def make_value_type(ast) Loading
spec/aggregator_default_values_spec.rb +14 −1 Original line number Diff line number Diff line Loading @@ -174,7 +174,7 @@ describe JsDuck::Aggregator do end end describe "cfg with explicit boolean default value" do describe "cfg with explicit boolean true default value" do before do @doc = parse(<<-EOS)[0] /** Loading @@ -187,6 +187,19 @@ describe JsDuck::Aggregator do end end describe "cfg with explicit boolean false default value" do before do @doc = parse(<<-EOS)[0] /** * @cfg {Number} [foo=false] Something */ EOS end it "has default value" do @doc[:default].should == "false" end end describe "cfg with explicit array default value" do before do @doc = parse(<<-EOS)[0] Loading
spec/ast_property_spec.rb +12 −0 Original line number Diff line number Diff line Loading @@ -109,6 +109,18 @@ describe "JsDuck::Ast detects property with" do detect("/** */ foo = 15;")[:default].should == "15" end it "assignment with number 0" do detect("/** */ foo = 0;")[:default].should == "0" end it "assignment with boolean true" do detect("/** */ foo = true;")[:default].should == "true" end it "assignment with boolean false" do detect("/** */ foo = false;")[:default].should == "false" end it "assignment with regex" do detect("/** */ foo = /abc/;")[:default].should == "/abc/" end Loading