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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [ifc_spc_spec.rb] - Blame information for rev 10

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 feddischso
###############################################################
2
#
3
#  File:      ifc_spc_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
#     Test specification for SOCMaker::IfcSpc
37
#
38
#
39
#
40
#
41
###############################################################
42
require_relative( 'spec_helper' )
43
 
44
 
45
 
46
 
47
describe SOCMaker::IfcSpc, "verification" do
48
 
49
  IFC_YAML_VALID = """
50
SOCM_IFC_SPC
51
name: core_ifc
52 10 feddischso
id: 'core_ifc,1'
53 3 feddischso
ports:
54 8 feddischso
  :sig_a:
55
    :dir: 1
56
  :sig_b:
57
    :dir: 1
58
  :sig_c:
59
    :dir: 0
60 3 feddischso
"""
61
 
62
  IFC_YAML_INVALID = """
63
SOCM_IFC_SPC
64
:name: core_ifc
65 10 feddischso
:id: 'core_ifc,1'
66 3 feddischso
:ports:
67
  :sig_a: '12'
68
  :sig_b: 1
69
  :sig_c: 0
70
"""
71
 
72
  IFC_YAML_INVALID2 = """
73
SOCM_IFC_SPC
74
:name: core_ifc
75 10 feddischso
:id: 'core_ifc,1'
76 3 feddischso
:ports:
77
  :sig_a:
78
  :sig_b: 1
79
  :sig_c: 0
80
"""
81
 
82
  it "should return a SOCMaker::IfcSpc object when creating with new" do
83
    s = SOCMaker::IfcSpc.new( "myifc", "v1" )
84
    s.class.should be SOCMaker::IfcSpc
85
  end
86
 
87
  it "should raise an error if the name is not a string" do
88
     expect{  SOCMaker::IfcSpc.new( 1234, "v1", { :p1 => "a-string" } ) }.
89
        to raise_error( SOCMaker::ERR::ValueError )
90
  end
91
 
92
  it "should raise an error if the name is an empty string" do
93
     expect{  SOCMaker::IfcSpc.new( "", "v1", { :p1 => "a-string" } ) }.
94
        to raise_error( SOCMaker::ERR::ValueError )
95
  end
96
 
97 10 feddischso
  it "should raise an error if the id is not a string" do
98 3 feddischso
     expect{  SOCMaker::IfcSpc.new( "myifc", 234, { :p1 => "a-string" } ) }.
99
        to raise_error( SOCMaker::ERR::ValueError )
100
  end
101
 
102 10 feddischso
  it "should raise an error if the id is an a empty string" do
103 3 feddischso
     expect{  SOCMaker::IfcSpc.new( "myifc", "", { :p1 => "a-string" } ) }.
104
        to raise_error( SOCMaker::ERR::ValueError )
105
  end
106
 
107
 
108
  it "should raise an error if a port direction is neither 0 nor 1" do
109 10 feddischso
     expect{  SOCMaker::IfcSpc.new( "myifc", "myifc,v1", 'ports' => { :p1 => "a-string" } ) }.
110 3 feddischso
        to raise_error( SOCMaker::ERR::ValueError )
111
  end
112
 
113
  it "should load from yaml" do
114
     c = SOCMaker::from_s( IFC_YAML_VALID )
115
     c.class.should be == SOCMaker::IfcSpc
116
  end
117
 
118
 
119
  it "should raise an error if a port direction is neither 0 nor 1" do
120
     expect{  SOCMaker::from_s( IFC_YAML_INVALID ) }.
121
        to raise_error( SOCMaker::ERR::ValueError )
122
  end
123
 
124
  it "should raise an error if a port direction is nil" do
125
     expect{  SOCMaker::from_s( IFC_YAML_INVALID2 ) }.
126
        to raise_error( SOCMaker::ERR::ValueError )
127
  end
128
 
129
 
130
 
131
end
132
 
133
 
134
# 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.