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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [ifc_spc_spec.rb] - Diff between revs 8 and 10

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

Rev 8 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::IfcSpc
#     Test specification for SOCMaker::IfcSpc
#
#
#
#
#
#
#
#
###############################################################
###############################################################
require_relative( 'spec_helper' )
require_relative( 'spec_helper' )
describe SOCMaker::IfcSpc, "verification" do
describe SOCMaker::IfcSpc, "verification" do
  IFC_YAML_VALID = """
  IFC_YAML_VALID = """
SOCM_IFC_SPC
SOCM_IFC_SPC
name: core_ifc
name: core_ifc
version: '1'
id: 'core_ifc,1'
ports:
ports:
  :sig_a:
  :sig_a:
    :dir: 1
    :dir: 1
  :sig_b:
  :sig_b:
    :dir: 1
    :dir: 1
  :sig_c:
  :sig_c:
    :dir: 0
    :dir: 0
"""
"""
  IFC_YAML_INVALID = """
  IFC_YAML_INVALID = """
SOCM_IFC_SPC
SOCM_IFC_SPC
:name: core_ifc
:name: core_ifc
:version: '1'
:id: 'core_ifc,1'
:ports:
:ports:
  :sig_a: '12'
  :sig_a: '12'
  :sig_b: 1
  :sig_b: 1
  :sig_c: 0
  :sig_c: 0
"""
"""
  IFC_YAML_INVALID2 = """
  IFC_YAML_INVALID2 = """
SOCM_IFC_SPC
SOCM_IFC_SPC
:name: core_ifc
:name: core_ifc
:version: '1'
:id: 'core_ifc,1'
:ports:
:ports:
  :sig_a:
  :sig_a:
  :sig_b: 1
  :sig_b: 1
  :sig_c: 0
  :sig_c: 0
"""
"""
  it "should return a SOCMaker::IfcSpc object when creating with new" do
  it "should return a SOCMaker::IfcSpc object when creating with new" do
    s = SOCMaker::IfcSpc.new( "myifc", "v1" )
    s = SOCMaker::IfcSpc.new( "myifc", "v1" )
    s.class.should be SOCMaker::IfcSpc
    s.class.should be SOCMaker::IfcSpc
  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::IfcSpc.new( 1234, "v1", { :p1 => "a-string" } ) }.
     expect{  SOCMaker::IfcSpc.new( 1234, "v1", { :p1 => "a-string" } ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
  it "should raise an error if the name is an empty string" do
  it "should raise an error if the name is an empty string" do
     expect{  SOCMaker::IfcSpc.new( "", "v1", { :p1 => "a-string" } ) }.
     expect{  SOCMaker::IfcSpc.new( "", "v1", { :p1 => "a-string" } ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
 
 
  it "should raise an error if the version is not a string" do
  it "should raise an error if the id is not a string" do
     expect{  SOCMaker::IfcSpc.new( "myifc", 234, { :p1 => "a-string" } ) }.
     expect{  SOCMaker::IfcSpc.new( "myifc", 234, { :p1 => "a-string" } ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
 
 
  it "should raise an error if the version is an a empty string" do
  it "should raise an error if the id is an a empty string" do
     expect{  SOCMaker::IfcSpc.new( "myifc", "", { :p1 => "a-string" } ) }.
     expect{  SOCMaker::IfcSpc.new( "myifc", "", { :p1 => "a-string" } ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
  it "should raise an error if a port direction is neither 0 nor 1" do
  it "should raise an error if a port direction is neither 0 nor 1" do
     expect{  SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { :p1 => "a-string" } ) }.
     expect{  SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { :p1 => "a-string" } ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
  it "should load from yaml" do
  it "should load from yaml" do
     c = SOCMaker::from_s( IFC_YAML_VALID )
     c = SOCMaker::from_s( IFC_YAML_VALID )
     c.class.should be == SOCMaker::IfcSpc
     c.class.should be == SOCMaker::IfcSpc
  end
  end
  it "should raise an error if a port direction is neither 0 nor 1" do
  it "should raise an error if a port direction is neither 0 nor 1" do
     expect{  SOCMaker::from_s( IFC_YAML_INVALID ) }.
     expect{  SOCMaker::from_s( IFC_YAML_INVALID ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  end
  end
  it "should raise an error if a port direction is nil" do
  it "should raise an error if a port direction is nil" do
     expect{  SOCMaker::from_s( IFC_YAML_INVALID2 ) }.
     expect{  SOCMaker::from_s( IFC_YAML_INVALID2 ) }.
        to raise_error( SOCMaker::ERR::ValueError )
        to raise_error( SOCMaker::ERR::ValueError )
  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.