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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [ifc_def_spec.rb] - Diff between revs 3 and 10

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 10
###############################################################
###############################################################
#
#
#  File:      ifc_spc_spec.rb
#  File:      ifc_spc_spec.rb
#
#
#  Author:    Christian Hättich
#  Author:    Christian Hättich
#
#
#  Project:   System-On-Chip Maker
#  Project:   System-On-Chip Maker
#
#
#  Target:    Linux / Windows / Mac
#  Target:    Linux / Windows / Mac
#
#
#  Language:  ruby
#  Language:  ruby
#
#
#
#
###############################################################
###############################################################
#
#
#
#
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
#
#
#   This program is free software: you can redistribute it and/or modify
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#   (at your option) any later version.
#
#
#   This program is distributed in the hope that it will be useful,
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#   GNU General Public License for more details.
#
#
#   You should have received a copy of the GNU General Public License
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see .
#   along with this program.  If not, see .
#
#
#
#
###############################################################
###############################################################
#
#
#   Description:
#   Description:
#     Test specification for SOCMaker::IfcDef
#     Test specification for SOCMaker::IfcDef
#
#
#
#
#
#
#
#
###############################################################
###############################################################
require_relative( 'spec_helper' )
require_relative( 'spec_helper' )
describe SOCMaker::IfcDef, "verification" do
describe SOCMaker::IfcDef, "verification" do
  tmp_port = SOCMaker::IfcPort.new( "abc" )
  tmp_port = SOCMaker::IfcPort.new( "abc" )
  it "should return a SOCMaker::IfcDef object when creating with new" do
  it "should return a SOCMaker::IfcDef object when creating with new" do
    s = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port  } )
    s = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port  } )
    s.class.should be SOCMaker::IfcDef
    s.class.should be SOCMaker::IfcDef
  end
  end
  it "should raise an error if the name is not a string" do
  it "should raise an error if the name is not a string" do
     expect{ SOCMaker::IfcDef.new( 4, "v1", 1, { test: tmp_port  } )  }.
     expect{ SOCMaker::IfcDef.new( 4, "myifc,v1", 1, { test: tmp_port  } )  }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
  it "should raise an error if the direction is neither 0 nor 1 " do
  it "should raise an error if the direction is neither 0 nor 1 " do
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { test: tmp_port  } )  }.
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { test: tmp_port  } )  }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
  it "should raise an error if no ports are given " do
  it "should raise an error if no ports are given " do
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { } )  }.
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { } )  }.
        to raise_error( SOCMaker::ERR::StructureError )
        to raise_error( SOCMaker::ERR::StructureError )
  end
  end
  it "should raise an error if a ports is nil " do
  it "should raise an error if a ports is nil " do
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: nil} )  }.
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: nil} )  }.
        to raise_error( SOCMaker::ERR::StructureError )
        to raise_error( SOCMaker::ERR::StructureError )
  end
  end
  it "should raise an error if a ports is not of type SOCMaker::IfcPort " do
  it "should raise an error if a ports is not of type SOCMaker::IfcPort " do
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: "string-type"} )  }.
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: "string-type"} )  }.
        to raise_error( SOCMaker::ERR::StructureError )
        to raise_error( SOCMaker::ERR::StructureError )
  end
  end
  it "should raise an error if no ports are given (nil)" do
  it "should raise an error if no ports are given (nil)" do
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, nil )  }.
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, nil )  }.
        to raise_error( SOCMaker::ERR::StructureError )
        to raise_error( SOCMaker::ERR::StructureError )
  end
  end
 
 
  it "should auto-convert a numerical version to string version" do
 
    s = SOCMaker::IfcDef.new( "myifc", 1, 1, { test: tmp_port  } )
 
    s.version.should be == "1"
 
  end
 
end
end
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
  tmp_port = SOCMaker::IfcPort.new( "abc" )
  tmp_port = SOCMaker::IfcPort.new( "abc" )
  it "should return false for two non-equal objects" do
  it "should return false for two non-equal objects" do
    o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port  } )
    o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port  } )
    o2 = Marshal::load(Marshal.dump(o1))
    o2 = Marshal::load(Marshal.dump(o1))
    o2.version = "v2"
    o2.id = "myifc,v2"
    ( o2 == o1 ).should be == false
    ( o2 == o1 ).should be == false
  end
  end
  it "should be possible to encode and decode a interface definition" do
  it "should be possible to encode and decode a interface definition" do
    o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port  } )
    o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port  } )
    yaml_str = o1.to_yaml
    yaml_str = o1.to_yaml
    o2 = YAML::load( yaml_str )
    o2 = YAML::load( yaml_str )
    o1.should be == o2
    o1.should be == o2
  end
  end
end
end
# vim: noai:ts=2:sw=2
# vim: noai:ts=2:sw=2
 
 

powered by: WebSVN 2.1.0

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