URL
https://opencores.org/ocsvn/soc_maker/soc_maker/trunk
Subversion Repositories soc_maker
[/] [soc_maker/] [trunk/] [spec/] [ypp_spec.rb] - Rev 10
Go to most recent revision | Compare with Previous | Blame | View Log
################################################################# File: ypp_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::YPP, "pre-processing to yaml" do[ "testSOCM_COREtest","test SOCM CORE test","SOCM CORE test","SOCM CORE","SOCM_CORE3","5SOCM_CORE test","abc SOCM_CORE1 test" ].each do |w|it "should not replace our tokens in these examples" doSOCMaker::YPP.to_yaml( w ).should == wendend[ [ "test abcd SOCM_CORE xyz 234", "test abcd --- !ruby/object:SOCMaker::CoreDef xyz 234" ],[ "abc\n\tSOCM_CORE\n\n\tabc\n", "abc\n\t--- !ruby/object:SOCMaker::CoreDef\n\n\tabc\n" ],[ "a b c SOCM_IFC_SPC x y z", "a b c --- !ruby/object:SOCMaker::IfcSpc x y z" ],[ "a b c SOCM_IFC x y z", "a b c !ruby/object:SOCMaker::IfcDef x y z" ],[ "a b c SOCM_PORT x y z", "a b c !ruby/object:SOCMaker::IfcPort x y z" ],[ "a b c SOCM_HDL_FILE x y z", "a b c !ruby/object:SOCMaker::HDLFile x y z" ],[ "a b c SOCM_SENTRY x y z", "a b c !ruby/object:SOCMaker::SParameterEntry x y z" ],[ "a b c SOCM_INCLUDE x y z", "a b c --- !ruby/object:SOCMaker::LibInc x y z" ],[ "a b c SOCM_CONF x y z", "a b c --- !ruby/object:SOCMaker::Conf x y z" ]].each do |w|it "should replace a single token" doSOCMaker::YPP.to_yaml( w[0] ).should == w[1]endend[ [ "a b SOCM_CORE 234\n\tSOCM_SOC ab\n\t","a b --- !ruby/object:SOCMaker::CoreDef 234\n\t--- !ruby/object:SOCMaker::SOCDef ab\n\t" ],[ " a b SOCM_CORE SOCM_SOC SOCM_CORE\n\tSOCM_CORE abc"," a b --- !ruby/object:SOCMaker::CoreDef --- !ruby/object:SOCMaker::SOCDef --- !ruby/object:SOCMaker::CoreDef\n\t--- !ruby/object:SOCMaker::CoreDef abc" ] ].each do |w|it "should replace multiple tokens" doSOCMaker::YPP.to_yaml( w[0] ).should == w[1]endendenddescribe SOCMaker::YPP, "post-processing from yaml" do%w[ CoreDefSOCDefIfcSpc ].each do |w|it "should replace a YAML object string part" dotmp = "--- !ruby/object:SOCMaker::" + w + "\nsomemoretext"SOCMaker::YPP.from_yaml( tmp ).should == SOCMaker::conf[ :YPP_INV_LUT ][ w ] + "\nsomemoretext"endend%w[ ConfIfcDefIfcPortHDLFileParameterSParameterSParameterEntryLibInc ].each do |w|it "should replace a YAML object string part" dotmp = "!ruby/object:SOCMaker::" + w + "\nsomemoretext"SOCMaker::YPP.from_yaml( tmp ).should == SOCMaker::conf[ :YPP_INV_LUT ][ w ] + "\nsomemoretext"endendenddescribe SOCMaker::YPP, "multiple ojbects from yaml" dotmp = """SOCM_COREabcdSOCM_INCLUDEefg"""it "should pass to strings to a block" docnt = 0result = []SOCMaker::YPP.to_yaml( tmp ) do |substr|cnt+=1result << substrendresult[ 0 ].should be == """--- !ruby/object:SOCMaker::CoreDefabcd"""result[ 1 ].should be == """--- !ruby/object:SOCMaker::LibIncefg"""cnt.should be == 2endend# vim: noai:ts=2:sw=2
Go to most recent revision | Compare with Previous | Blame | View Log
