Module: Origen::Tests

Defined in:
lib/origen/tests.rb,
lib/origen/tests/test.rb

Defined Under Namespace

Classes: Test

Instance Method Summary collapse

Instance Method Details

#add_test(id, options = {}, &block) ⇒ Object


22
23
24
25
26
27
28
29
# File 'lib/origen/tests.rb', line 22

def add_test(id, options = {}, &block)
  @_tests ||= {}
  if @_tests.include?(id)
    Origen.log.error("Cannot create test '#{id}', it already exists!")
    fail
  end
  @_tests[id] = Test.new(id, options, &block)
end

#tests(expr = nil) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/origen/tests.rb', line 4

def tests(expr = nil)
  if expr.nil?
    if @_tests.nil?
      @_tests = {}
    elsif @_tests.is_a? Hash
      if @_tests.empty?
        @_tests
      else
        @_tests.ids
      end
    else
      @_tests = {}
    end
  else
    @_tests.recursive_find_by_key(expr)
  end
end