URL
https://opencores.org/ocsvn/soc_maker/soc_maker/trunk
Subversion Repositories soc_maker
[/] [soc_maker/] [trunk/] [spec/] [core_inst_spec.rb] - Rev 3
Go to most recent revision | Compare with Previous | Blame | View Log
################################################################# File: core_inst_spec.rb## Author: Christian Hättich## Project: System-On-Chip Maker## Target: Linux / Windows / Mac## Language: ruby#################################################################### Copyright (C) 2014 Christian Hättich - feddischson [ at ] opencores.org## 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# the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program. If not, see <http://www.gnu.org/licenses/>.################################################################### Description:###################################################################require_relative( 'spec_helper' )describe SOCMaker::CoreInst, "structure and auto-completion functionallity" doit "should raise an error, if parameters are not given as hash" dofile = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )SOCMaker::lib.add_core( core )expect{ SOCMaker::CoreInst.new( "mycorerel1", "not a hash" ) }.to raise_error( SOCMaker::ERR::StructureError )SOCMaker::lib.rm_core( core )endit "should raise an error, if parameters are given, which doesn't exist in the definition" dofile = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )SOCMaker::lib.add_core( core )expect{ SOCMaker::CoreInst.new( "mycorerel1", { "aparameter".to_sym => 4 } ) }.to raise_error( SOCMaker::ERR::ValueError )SOCMaker::lib.rm_core( core )endit "should auto-complete generics with default values" do# create core with one file and one instance parameterfile = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" ) }core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )core.inst_parameters = parametersSOCMaker::lib.add_core( core )inst = SOCMaker::CoreInst.new( "mycorerel1", {} )inst.params[ :param1 ].should be == 0SOCMaker::lib.rm_core( core )endenddescribe SOCMaker::CoreDef, "object handling, en-decoding:" doit "should be possible to encode and decode a core instance" dofile = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" ) }core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )core.inst_parameters = parametersSOCMaker::lib.add_core( core )o1 = SOCMaker::CoreInst.new( "mycorerel1", {} )yaml_str = o1.to_yamlo2 = YAML::load( yaml_str )o1.should be == o2endit "should return false for two non-equal objects" dofile = { "file.vhd".to_sym => SOCMaker::HDLFile.new( "./file.vhd" ) }parameters = { "param1".to_sym => SOCMaker::Parameter.new( "integer" ) }core = SOCMaker::CoreDef.new( "mycore", "rel1", file, "top" )core.inst_parameters = parametersSOCMaker::lib.add_core( core )o1 = SOCMaker::CoreInst.new( "mycorerel1" )o2 = Marshal::load(Marshal.dump(o1))o2.type << "X"( o2 == o1 ).should be == falseo2 = Marshal::load(Marshal.dump(o1))o2.params[ :param1 ] = 1( o2 == o1 ).should be == falseendend
Go to most recent revision | Compare with Previous | Blame | View Log
