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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [ypp_spec.rb] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 feddischso
###############################################################
2
#
3
#  File:      ypp_spec.rb
4
#
5
#  Author:    Christian Hättich
6
#
7
#  Project:   System-On-Chip Maker
8
#
9
#  Target:    Linux / Windows / Mac
10
#
11
#  Language:  ruby
12
#
13
#
14
###############################################################
15
#
16
#
17
#   Copyright (C) 2014  Christian Hättich  - feddischson [ at ] opencores.org
18
#
19
#   This program is free software: you can redistribute it and/or modify
20
#   it under the terms of the GNU General Public License as published by
21
#   the Free Software Foundation, either version 3 of the License, or
22
#   (at your option) any later version.
23
#
24
#   This program is distributed in the hope that it will be useful,
25
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
26
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27
#   GNU General Public License for more details.
28
#
29
#   You should have received a copy of the GNU General Public License
30
#   along with this program.  If not, see .
31
#
32
#
33
###############################################################
34
#
35
#   Description:
36
#
37
#
38
#
39
#
40
###############################################################
41
require_relative( 'spec_helper' )
42
 
43
 
44
 
45
 
46
 
47
describe SOCMaker::YPP, "pre-processing to yaml" do
48
 
49
  [ "testSOCM_COREtest",
50
    "test SOCM CORE test",
51
    "SOCM CORE test",
52
    "SOCM CORE",
53
    "SOCM_CORE3",
54
    "5SOCM_CORE test",
55
    "abc SOCM_CORE1 test" ].each do |w|
56
    it "should not replace our tokens in these examples" do
57
      SOCMaker::YPP.to_yaml( w ).should == w
58
    end
59
  end
60
 
61
  [ [ "test abcd SOCM_CORE xyz 234", "test abcd --- !ruby/object:SOCMaker::CoreDef xyz 234" ],
62
    [ "abc\n\tSOCM_CORE\n\n\tabc\n", "abc\n\t--- !ruby/object:SOCMaker::CoreDef\n\n\tabc\n" ],
63
    [ "a b c SOCM_IFC_SPC x y z", "a b c --- !ruby/object:SOCMaker::IfcSpc x y z"       ],
64
    [ "a b c SOCM_IFC x y z", "a b c !ruby/object:SOCMaker::IfcDef x y z"       ],
65
    [ "a b c SOCM_PORT x y z", "a b c !ruby/object:SOCMaker::IfcPort x y z"     ],
66
    [ "a b c SOCM_HDL_FILE x y z", "a b c !ruby/object:SOCMaker::HDLFile x y z" ],
67
    [ "a b c SOCM_SENTRY x y z", "a b c !ruby/object:SOCMaker::SParameterEntry x y z" ],
68
    [ "a b c SOCM_INCLUDE x y z", "a b c --- !ruby/object:SOCMaker::LibInc x y z" ],
69
    [ "a b c SOCM_CONF x y z", "a b c --- !ruby/object:SOCMaker::Conf x y z" ]
70
     ].each do |w|
71
    it "should replace a single token" do
72
      SOCMaker::YPP.to_yaml( w[0] ).should == w[1]
73
    end
74
  end
75
 
76
 
77
  [ [ "a b SOCM_CORE 234\n\tSOCM_SOC ab\n\t",
78
      "a b --- !ruby/object:SOCMaker::CoreDef 234\n\t--- !ruby/object:SOCMaker::SOCDef ab\n\t" ],
79
    [ " a b SOCM_CORE SOCM_SOC SOCM_CORE\n\tSOCM_CORE abc",
80
      " a b --- !ruby/object:SOCMaker::CoreDef --- !ruby/object:SOCMaker::SOCDef --- !ruby/object:SOCMaker::CoreDef\n\t--- !ruby/object:SOCMaker::CoreDef abc" ] ].each do |w|
81
    it "should replace multiple tokens" do
82
      SOCMaker::YPP.to_yaml( w[0] ).should == w[1]
83
    end
84
  end
85
 
86
end
87
 
88
 
89
describe SOCMaker::YPP, "post-processing from yaml" do
90
 
91
  %w[ CoreDef
92
      SOCDef
93
      IfcSpc ].each do |w|
94
    it "should replace a YAML object string part" do
95
      tmp = "--- !ruby/object:SOCMaker::" + w + "\nsomemoretext"
96
      SOCMaker::YPP.from_yaml( tmp ).should ==  SOCMaker::conf[ :YPP_INV_LUT ][ w ] + "\nsomemoretext"
97
    end
98
  end
99
 
100
  %w[ Conf
101
      IfcDef
102
      IfcPort
103
      HDLFile
104
      Parameter
105
      SParameter
106
      SParameterEntry
107
      LibInc ].each do |w|
108
    it "should replace a YAML object string part" do
109
      tmp = "!ruby/object:SOCMaker::" + w + "\nsomemoretext"
110
      SOCMaker::YPP.from_yaml( tmp ).should == SOCMaker::conf[ :YPP_INV_LUT ][ w ] + "\nsomemoretext"
111
    end
112
  end
113
 
114
end
115
 
116
describe SOCMaker::YPP, "multiple ojbects from yaml" do
117
 
118
  tmp = """SOCM_CORE
119
a
120
b
121
c
122
d
123
SOCM_INCLUDE
124
e
125
f
126
g
127
"""
128
  it "should pass to strings to a block" do
129
    cnt = 0
130
    result = []
131
    SOCMaker::YPP.to_yaml( tmp ) do |substr|
132
      cnt+=1
133
      result << substr
134
    end
135
    result[ 0 ].should be == """--- !ruby/object:SOCMaker::CoreDef
136
a
137
b
138
c
139
d
140
"""
141
    result[ 1 ].should be == """--- !ruby/object:SOCMaker::LibInc
142
e
143
f
144
g
145
"""
146
    cnt.should be == 2
147
  end
148
 
149
end
150
 
151
 
152
# 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.