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 3

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::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
    s = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port  } )
50
    s.class.should be SOCMaker::IfcDef
51
  end
52
 
53
  it "should raise an error if the name is not a string" do
54
     expect{ SOCMaker::IfcDef.new( 4, "v1", 1, { test: tmp_port  } )  }.
55
        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
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { test: tmp_port  } )  }.
60
        to raise_error( SOCMaker::ERR::ValueError )
61
  end
62
 
63
 
64
  it "should raise an error if no ports are given " do
65
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { } )  }.
66
        to raise_error( SOCMaker::ERR::StructureError )
67
  end
68
 
69
 
70
  it "should raise an error if a ports is nil " do
71
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: nil} )  }.
72
        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
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, { a_port: "string-type"} )  }.
77
        to raise_error( SOCMaker::ERR::StructureError )
78
  end
79
 
80
  it "should raise an error if no ports are given (nil)" do
81
     expect{ SOCMaker::IfcDef.new( "myifc", "v1", 4, nil )  }.
82
        to raise_error( SOCMaker::ERR::StructureError )
83
  end
84
 
85
  it "should auto-convert a numerical version to string version" do
86
    s = SOCMaker::IfcDef.new( "myifc", 1, 1, { test: tmp_port  } )
87
    s.version.should be == "1"
88
  end
89
end
90
 
91
describe SOCMaker::IfcDef, "object handling, en-decoding:" do
92
  tmp_port = SOCMaker::IfcPort.new( "abc" )
93
 
94
  it "should return false for two non-equal objects" do
95
    o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port  } )
96
    o2 = Marshal::load(Marshal.dump(o1))
97
    o2.version = "v2"
98
    ( o2 == o1 ).should be == false
99
  end
100
 
101
  it "should be possible to encode and decode a interface definition" do
102
    o1 = SOCMaker::IfcDef.new( "myifc", "v1", 1, { test: tmp_port  } )
103
    yaml_str = o1.to_yaml
104
    o2 = YAML::load( yaml_str )
105
    o1.should be == o2
106
  end
107
 
108
 
109
 
110
 
111
 
112
end
113
 
114
 
115
# vim: noai:ts=2:sw=2
116
 

powered by: WebSVN 2.1.0

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