vhdl_doctest 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vhdl_doctest/test_parser.rb +14 -1
- data/lib/vhdl_doctest/version.rb +1 -1
- data/spec/test_parser_spec.rb +14 -0
- metadata +4 -4
@@ -52,7 +52,10 @@ module VhdlDoctest
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_definitions(vhdl)
|
55
|
-
lines = vhdl.match(/-- TEST\n(.*)-- \/TEST/m)[1].
|
55
|
+
lines = vhdl.match(/-- TEST\n(.*)-- \/TEST/m)[1].
|
56
|
+
gsub(/\#.*$/, ''). # remove comments
|
57
|
+
gsub(/--\s*\n/m, ''). # remove blank lines
|
58
|
+
split("\n")
|
56
59
|
lines.partition { |l| l.include? 'alias' }
|
57
60
|
rescue
|
58
61
|
raise "Test definition not found"
|
@@ -85,6 +88,16 @@ module VhdlDoctest
|
|
85
88
|
port_names << port_name
|
86
89
|
prev = ''
|
87
90
|
radix = radix(attr)
|
91
|
+
body.select! do |l|
|
92
|
+
if l.empty?
|
93
|
+
false
|
94
|
+
elsif ! l[idx]
|
95
|
+
warn l.join(" | ") + " does not have enough columns"
|
96
|
+
false
|
97
|
+
else
|
98
|
+
true
|
99
|
+
end
|
100
|
+
end
|
88
101
|
body.each do |l|
|
89
102
|
if l[idx].empty?
|
90
103
|
l[idx] = prev
|
data/lib/vhdl_doctest/version.rb
CHANGED
data/spec/test_parser_spec.rb
CHANGED
@@ -139,6 +139,7 @@ module VhdlDoctest
|
|
139
139
|
-- TEST
|
140
140
|
-- a | b | control | zero # header
|
141
141
|
-- 10 | -10 | 2 | 1 # case1
|
142
|
+
-- # whole comment line
|
142
143
|
-- 10 | | 2 | 1 # case2 # important
|
143
144
|
-- /TEST
|
144
145
|
}}
|
@@ -151,6 +152,7 @@ module VhdlDoctest
|
|
151
152
|
let(:input) { %q{
|
152
153
|
-- TEST
|
153
154
|
-- alias TRUE 1
|
155
|
+
-- # comment between alias
|
154
156
|
-- alias FALSE 0
|
155
157
|
-- a | b | control | zero
|
156
158
|
-- 10 | -10 | 2 | TRUE
|
@@ -161,5 +163,17 @@ module VhdlDoctest
|
|
161
163
|
specify { cases.first.should assert(zero: 1) }
|
162
164
|
specify { cases.last.should assert(zero: 0) }
|
163
165
|
end
|
166
|
+
|
167
|
+
describe 'not enough fields' do
|
168
|
+
let(:input) { %q{
|
169
|
+
-- TEST
|
170
|
+
-- a | b | control | zero
|
171
|
+
-- 10 | -10 | 2 | 0
|
172
|
+
-- 10 | 10
|
173
|
+
-- /TEST
|
174
|
+
}}
|
175
|
+
|
176
|
+
specify { cases.should have(1).item }
|
177
|
+
end
|
164
178
|
end
|
165
179
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vhdl_doctest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
91
|
version: '0'
|
92
92
|
segments:
|
93
93
|
- 0
|
94
|
-
hash: -
|
94
|
+
hash: -47820915
|
95
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
96
|
none: false
|
97
97
|
requirements:
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
segments:
|
102
102
|
- 0
|
103
|
-
hash: -
|
103
|
+
hash: -47820915
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
106
|
rubygems_version: 1.8.24
|