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

Subversion Repositories soc_maker

[/] [soc_maker/] [trunk/] [spec/] [ifc_def_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::IfcDef
37
#
38
#
39
#
40
#
41
###############################################################
42
require_relative( 'spec_helper' )
43
 
44
describe SOCMaker::IfcDef, "verification" do
45
 
46
  tmp_port = SOCMaker::IfcPort.new( "abc" )
47
 
48
  it "should return a SOCMaker::IfcDef object when creating with new" do
49 10 feddischso
    s = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port  } )
50 3 feddischso
    s.class.should be SOCMaker::IfcDef
51
  end
52
 
53
  it "should raise an error if the name is not a string" do
54 10 feddischso
     expect{ SOCMaker::IfcDef.new( 4, "myifc,v1", 1, { test: tmp_port  } )  }.
55 3 feddischso
        to raise_error( SOCMaker::ERR::ValueError )
56
  end
57
 
58
  it "should raise an error if the direction is neither 0 nor 1 " do
59 10 feddischso
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { test: tmp_port  } )  }.
60 3 feddischso
        to raise_error( SOCMaker::ERR::ValueError )
61
  end
62
 
63
 
64
  it "should raise an error if no ports are given " do
65 10 feddischso
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { } )  }.
66 3 feddischso
        to raise_error( SOCMaker::ERR::StructureError )
67
  end
68
 
69
 
70
  it "should raise an error if a ports is nil " do
71 10 feddischso
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: nil} )  }.
72 3 feddischso
        to raise_error( SOCMaker::ERR::StructureError )
73
  end
74
 
75
  it "should raise an error if a ports is not of type SOCMaker::IfcPort " do
76 10 feddischso
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, { a_port: "string-type"} )  }.
77 3 feddischso
        to raise_error( SOCMaker::ERR::StructureError )
78
  end
79
 
80
  it "should raise an error if no ports are given (nil)" do
81 10 feddischso
     expect{ SOCMaker::IfcDef.new( "myifc", "myifc,v1", 4, nil )  }.
82 3 feddischso
        to raise_error( SOCMaker::ERR::StructureError )
83
  end
84
 
85
end
86
 
87
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
88
  tmp_port = SOCMaker::IfcPort.new( "abc" )
89
 
90
  it "should return false for two non-equal objects" do
91 10 feddischso
    o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port  } )
92 3 feddischso
    o2 = Marshal::load(Marshal.dump(o1))
93 10 feddischso
    o2.id = "myifc,v2"
94 3 feddischso
    ( o2 == o1 ).should be == false
95
  end
96
 
97
  it "should be possible to encode and decode a interface definition" do
98 10 feddischso
    o1 = SOCMaker::IfcDef.new( "myifc", "myifc,v1", 1, { test: tmp_port  } )
99 3 feddischso
    yaml_str = o1.to_yaml
100
    o2 = YAML::load( yaml_str )
101
    o1.should be == o2
102
  end
103
 
104
 
105
 
106
 
107
 
108
end
109
 
110
 
111
# vim: noai:ts=2:sw=2
112
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.