OpenCores
URL https://opencores.org/ocsvn/soc_maker/soc_maker/trunk

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [component_spec.rb] - Diff between revs 9 and 10

Show entire file | Details | Blame | View Log

Rev 9 Rev 10
Line 64... Line 64...
  it "should raise an error, if the name is not of type string" do
  it "should raise an error, if the name is not of type string" do
    expect{ SOCMaker::Component.new( 3, "v1", "top" ) }.
    expect{ SOCMaker::Component.new( 3, "v1", "top" ) }.
      to raise_error( SOCMaker::ERR::ValueError )
      to raise_error( SOCMaker::ERR::ValueError )
  end
  end
 
 
  it 'should raise an error, if the name doesnt start with [a-zA-Z]' do
  # test the id
    expect{ SOCMaker::Component.new( "4abc", "v1", "top" ) }.
  it "should raise an error, if the id is nil" do
      to raise_error( SOCMaker::ERR::ValueError )
 
  end
 
 
 
  it 'should raise an error, if the name conatins invalid symbols' do
 
    expect{ SOCMaker::Component.new( "abc$abc", "v1", "top" ) }.
 
      to raise_error( SOCMaker::ERR::ValueError )
 
  end
 
 
 
 
 
 
 
 
 
 
 
  # test the version
 
  it "should raise an error, if the version is nil" do
 
    expect{ SOCMaker::Component.new( "acore", nil, "top" ) }.
    expect{ SOCMaker::Component.new( "acore", nil, "top" ) }.
      to raise_error( SOCMaker::ERR::StructureError )
      to raise_error( SOCMaker::ERR::StructureError )
  end
  end
 
 
  it "should raise an error, if the version has zero-length" do
  it "should raise an error, if the id has zero-length" do
    expect{ SOCMaker::Component.new( "acore", "", "top" ) }.
    expect{ SOCMaker::Component.new( "acore", "", "top" ) }.
      to raise_error( SOCMaker::ERR::StructureError )
      to raise_error( SOCMaker::ERR::StructureError )
  end
  end
 
 
  it "should raise an error, if the version is not of type string neither of type Numerical" do
  it "should raise an error, if the id is not of type string " do
    expect{ SOCMaker::Component.new( "acore", [ 1, 2, 3 ], "top" ) }.
    expect{ SOCMaker::Component.new( "acore", [ 1, 2, 3 ], "top" ) }.
      to raise_error( SOCMaker::ERR::ValueError )
      to raise_error( SOCMaker::ERR::ValueError )
  end
  end
 
 
  it "should cast a numerical version to a string version" do
 
    c = SOCMaker::Component.new( "acore", 3, "top" )
 
    c.class.should be == SOCMaker::Component
 
    c.version = "3"
 
  end
 
 
 
 
 
  %w[ description date license licensefile
  %w[ description date license licensefile
      author authormail vccmd ].each do |m|
      author authormail vccmd ].each do |m|
    it "should auto-set #{m} to an empty string" do
    it "should auto-set #{m} to an empty string" do
      c = SOCMaker::Component.new( "acore", "v1", "top" )
      c = SOCMaker::Component.new( "acore", "v1", "top" )
Line 148... Line 128...
 
 
 
 
 
 
  it 'should iterate over all generics (inst. parameters)' do
  it 'should iterate over all generics (inst. parameters)' do
 
 
 
 
    p1 = SOCMaker::Parameter.new( "integer" )
    p1 = SOCMaker::Parameter.new( "integer" )
    p2 = SOCMaker::Parameter.new( "string" )
    p2 = SOCMaker::Parameter.new( "string" )
    p3 = SOCMaker::Parameter.new( "integer" )
    p3 = SOCMaker::Parameter.new( "integer" )
    p4 = SOCMaker::Parameter.new( "string" )
    p4 = SOCMaker::Parameter.new( "string" )
 
 
Line 178... Line 159...
 
 
 
 
  it 'should iterate over all ports' do
  it 'should iterate over all ports' do
 
 
    SOCMaker::lib.clear
    SOCMaker::lib.clear
    ifc_s1 = SOCMaker::IfcSpc.new( "i1", "v1", 'ports' => { p1:{dir:1}, p2:{dir:1}, p3:{dir:0} } )
    ifc_s1 = SOCMaker::IfcSpc.new( "Interface 1", "i1,v1", 'ports' => { p1:{dir:1}, p2:{dir:1}, p3:{dir:0} } )
    ifc_s2 = SOCMaker::IfcSpc.new( "i2", "v1", 'ports' => { x1:{dir:1}, x2:{dir:0} } )
    ifc_s2 = SOCMaker::IfcSpc.new( "Interface 2", "i2,v1", 'ports' => { x1:{dir:1}, x2:{dir:0} } )
    SOCMaker::lib.add_ifc( ifc_s1 )
    SOCMaker::lib.add_ifc( ifc_s1 )
    SOCMaker::lib.add_ifc( ifc_s2 )
    SOCMaker::lib.add_ifc( ifc_s2 )
 
 
    p1 = SOCMaker::IfcPort.new( "p1", 1 )
    p1 = SOCMaker::IfcPort.new( "p1", 1 )
    p2 = SOCMaker::IfcPort.new( "p2", 2 )
    p2 = SOCMaker::IfcPort.new( "p2", 2 )
    p3 = SOCMaker::IfcPort.new( "p3", 3 )
    p3 = SOCMaker::IfcPort.new( "p3", 3 )
    x1 = SOCMaker::IfcPort.new( "x1", 1 )
    x1 = SOCMaker::IfcPort.new( "x1", 1 )
    x2 = SOCMaker::IfcPort.new( "x2", 2 )
    x2 = SOCMaker::IfcPort.new( "x2", 2 )
 
 
    ifc_d1 = SOCMaker::IfcDef.new( "i1", "v1", 0, { m_p1: p1, m_p2: p2, m_p3: p3 } )
    ifc_d1 = SOCMaker::IfcDef.new( "i1", "i1,v1", 0, { m_p1: p1, m_p2: p2, m_p3: p3 } )
    ifc_d2 = SOCMaker::IfcDef.new( "i2", "v1", 0, { m_x1: x1, m_x2: x2           } )
    ifc_d2 = SOCMaker::IfcDef.new( "i2", "i2,v1", 0, { m_x1: x1, m_x2: x2           } )
 
 
 
 
    c = SOCMaker::Component.new( "acore", "v1", "top",
    c = SOCMaker::Component.new( "A core", "acore,v1", "top",
      { 'interfaces' =>  { i1: ifc_d1, i2: ifc_d2 } } )
      { 'interfaces' =>  { i1: ifc_d1, i2: ifc_d2 } } )
 
 
    r_name    = []
    r_name    = []
    r_dir     = []
    r_dir     = []
    r_len     = []
    r_len     = []
Line 217... Line 198...
 
 
    #r_def     = []
    #r_def     = []
    r_name    = []
    r_name    = []
    r_dir     = []
    r_dir     = []
 
 
    p c.interfaces
 
    c.ports( "i1" ) do |arg_name,arg_dir, arg_default, arg_is_last|
    c.ports( "i1" ) do |arg_name,arg_dir, arg_default, arg_is_last|
      #r_def     << arg_def
      #r_def     << arg_def
      r_name    << arg_name
      r_name    << arg_name
      r_dir     << arg_dir
      r_dir     << arg_dir
    end
    end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.