Loading spec/aggregator_cfgs_and_properties_spec.rb +54 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,60 @@ describe JsDuck::Aggregator do it_should_behave_like "cfg or property default type" end shared_examples_for "auto type" do it "should imply correct type" do @doc[:type].should == @type end end describe "@property with number in code" do before do @doc = parse("/** @property */ foo: 123")[0] @type = "Number" end it_should_behave_like "auto type" end describe "@property with regex in code" do before do @doc = parse("/** @property */ foo: /foo/i")[0] @type = "RegExp" end it_should_behave_like "auto type" end describe "@property with true in code" do before do @doc = parse("/** @property */ foo: true")[0] @type = "Boolean" end it_should_behave_like "auto type" end describe "@property with false in code" do before do @doc = parse("/** @property */ foo: false")[0] @type = "Boolean" end it_should_behave_like "auto type" end describe "@property with function in code" do before do @doc = parse("/** @property */ function foo() {}")[0] @type = "Function" end it_should_behave_like "auto type" end describe "@property with lambda in code" do before do @doc = parse("/** @property */ foo = function() {}")[0] @type = "Function" end it_should_behave_like "auto type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] Loading test/tc_jsduck.rbdeleted 100644 → 0 +0 −29 Original line number Diff line number Diff line require "jsduck" require "test/unit" class TestJsDuck < Test::Unit::TestCase def test_implicit_property_type comment = " /** * @property */ " docs = JsDuck.parse(comment + "foo: 'haha',") assert_equal("String", docs[0][:type]) docs = JsDuck.parse(comment + "foo: 123,") assert_equal("Number", docs[0][:type]) docs = JsDuck.parse(comment + "foo: /^123/,") assert_equal("RegExp", docs[0][:type]) docs = JsDuck.parse(comment + "foo: true,") assert_equal("Boolean", docs[0][:type]) docs = JsDuck.parse(comment + "foo: false,") assert_equal("Boolean", docs[0][:type]) docs = JsDuck.parse(comment + "foo: function(){},") assert_equal("Function", docs[0][:type]) docs = JsDuck.parse(comment + "function foo(){},") assert_equal("Function", docs[0][:type]) end end Loading
spec/aggregator_cfgs_and_properties_spec.rb +54 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,60 @@ describe JsDuck::Aggregator do it_should_behave_like "cfg or property default type" end shared_examples_for "auto type" do it "should imply correct type" do @doc[:type].should == @type end end describe "@property with number in code" do before do @doc = parse("/** @property */ foo: 123")[0] @type = "Number" end it_should_behave_like "auto type" end describe "@property with regex in code" do before do @doc = parse("/** @property */ foo: /foo/i")[0] @type = "RegExp" end it_should_behave_like "auto type" end describe "@property with true in code" do before do @doc = parse("/** @property */ foo: true")[0] @type = "Boolean" end it_should_behave_like "auto type" end describe "@property with false in code" do before do @doc = parse("/** @property */ foo: false")[0] @type = "Boolean" end it_should_behave_like "auto type" end describe "@property with function in code" do before do @doc = parse("/** @property */ function foo() {}")[0] @type = "Function" end it_should_behave_like "auto type" end describe "@property with lambda in code" do before do @doc = parse("/** @property */ foo = function() {}")[0] @type = "Function" end it_should_behave_like "auto type" end describe "@property with @type" do before do @doc = parse(<<-EOS)[0] Loading
test/tc_jsduck.rbdeleted 100644 → 0 +0 −29 Original line number Diff line number Diff line require "jsduck" require "test/unit" class TestJsDuck < Test::Unit::TestCase def test_implicit_property_type comment = " /** * @property */ " docs = JsDuck.parse(comment + "foo: 'haha',") assert_equal("String", docs[0][:type]) docs = JsDuck.parse(comment + "foo: 123,") assert_equal("Number", docs[0][:type]) docs = JsDuck.parse(comment + "foo: /^123/,") assert_equal("RegExp", docs[0][:type]) docs = JsDuck.parse(comment + "foo: true,") assert_equal("Boolean", docs[0][:type]) docs = JsDuck.parse(comment + "foo: false,") assert_equal("Boolean", docs[0][:type]) docs = JsDuck.parse(comment + "foo: function(){},") assert_equal("Function", docs[0][:type]) docs = JsDuck.parse(comment + "function foo(){},") assert_equal("Function", docs[0][:type]) end end