Class: OrigenTesters::ATP::Validators::DuplicateIDs

Inherits:
OrigenTesters::ATP::Validator show all
Defined in:
lib/origen_testers/atp/validators/duplicate_ids.rb

Instance Attribute Summary

Attributes inherited from OrigenTesters::ATP::Validator

#flow

Instance Method Summary collapse

Methods inherited from OrigenTesters::ATP::Validator

#error, #initialize, #process, #setup, #test_process, testing, testing=

Methods inherited from Processor

#clean_flag, #extract_volatiles, #handler_missing, #process, #process_all, #run, #volatile?, #volatile_flags

Constructor Details

This class inherits a constructor from OrigenTesters::ATP::Validator

Instance Method Details

#on_completionObject


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/origen_testers/atp/validators/duplicate_ids.rb', line 4

def on_completion
  if @duplicate_ids
    @duplicate_ids.each do |id, nodes|
      error "Test ID #{id} is defined more than once in flow #{flow.name}:"
      nodes.each do |node|
        error "  #{node.source}"
      end
    end
    true
  end
end

#on_id(node) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/origen_testers/atp/validators/duplicate_ids.rb', line 16

def on_id(node)
  @existing_ids ||= {}
  id = node.value
  if @existing_ids[id]
    @duplicate_ids ||= {}
    if @duplicate_ids[id]
      @duplicate_ids[id] << node
    else
      @duplicate_ids[id] = [@existing_ids[id], node]
    end
  else
    @existing_ids[id] = node
  end
end