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 4

Go to most recent revision | 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
version: '1'
53
ports:
54
  :sig_a: 1
55
  :sig_b: 1
56
  :sig_c: 0
57
"""
58
 
59
  IFC_YAML_INVALID = """
60
SOCM_IFC_SPC
61
:name: core_ifc
62
:version: '1'
63
:ports:
64
  :sig_a: '12'
65
  :sig_b: 1
66
  :sig_c: 0
67
"""
68
 
69
  IFC_YAML_INVALID2 = """
70
SOCM_IFC_SPC
71
:name: core_ifc
72
:version: '1'
73
:ports:
74
  :sig_a:
75
  :sig_b: 1
76
  :sig_c: 0
77
"""
78
 
79
  it "should return a SOCMaker::IfcSpc object when creating with new" do
80
    s = SOCMaker::IfcSpc.new( "myifc", "v1" )
81
    s.class.should be SOCMaker::IfcSpc
82
  end
83
 
84
  it "should raise an error if the name is not a string" do
85
     expect{  SOCMaker::IfcSpc.new( 1234, "v1", { :p1 => "a-string" } ) }.
86
        to raise_error( SOCMaker::ERR::ValueError )
87
  end
88
 
89
  it "should raise an error if the name is an empty string" do
90
     expect{  SOCMaker::IfcSpc.new( "", "v1", { :p1 => "a-string" } ) }.
91
        to raise_error( SOCMaker::ERR::ValueError )
92
  end
93
 
94
  it "should raise an error if the version is not a string" do
95
     expect{  SOCMaker::IfcSpc.new( "myifc", 234, { :p1 => "a-string" } ) }.
96
        to raise_error( SOCMaker::ERR::ValueError )
97
  end
98
 
99
  it "should raise an error if the version is an a empty string" do
100
     expect{  SOCMaker::IfcSpc.new( "myifc", "", { :p1 => "a-string" } ) }.
101
        to raise_error( SOCMaker::ERR::ValueError )
102
  end
103
 
104
 
105
  it "should raise an error if a port direction is neither 0 nor 1" do
106
     expect{  SOCMaker::IfcSpc.new( "myifc", "v1", 'ports' => { :p1 => "a-string" } ) }.
107
        to raise_error( SOCMaker::ERR::ValueError )
108
  end
109
 
110
  it "should load from yaml" do
111
     c = SOCMaker::from_s( IFC_YAML_VALID )
112
     c.class.should be == SOCMaker::IfcSpc
113
  end
114
 
115
 
116
  it "should raise an error if a port direction is neither 0 nor 1" do
117
     expect{  SOCMaker::from_s( IFC_YAML_INVALID ) }.
118
        to raise_error( SOCMaker::ERR::ValueError )
119
  end
120
 
121
  it "should raise an error if a port direction is nil" do
122
     expect{  SOCMaker::from_s( IFC_YAML_INVALID2 ) }.
123
        to raise_error( SOCMaker::ERR::ValueError )
124
  end
125
 
126
 
127
 
128
end
129
 
130
 
131
# 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.