Sha256: 45f156acd13ef894593bb2ef730ca35f94827cf7b3702ea7224b5d7ffe025d88

Contents?: true

Size: 1.99 KB

Versions: 5

Compression:

Stored size: 1.99 KB

Contents

module OrigenTesters::ATP
  module FlowAPI
    def atp=(atp)
      @atp = atp
    end

    def atp
      @atp
    end

    ([:test, :bin, :pass, :continue, :cz, :log, :sub_test, :volatile, :add_global_flag, :set_flag, :unset_flag, :add_flag, :set, :enable, :disable, :render,
      :context_changed?, :ids, :describe_bin, :describe_softbin, :describe_soft_bin, :add_auxiliary_flow] +
      OrigenTesters::ATP::Flow::CONDITION_KEYS.keys + OrigenTesters::ATP::Flow::RELATIONAL_OPERATORS).each do |method|
      define_method method do |*args, &block|
        options = args.pop if args.last.is_a?(Hash)
        options ||= {}
        add_meta!(options) if respond_to?(:add_meta!, true)
        add_description!(options) if respond_to?(:add_description!, true)
        args << options
        atp.send(method, *args, &block)
      end
    end

    alias_method :logprint, :log

    def loop(*args, &block)
      if args.empty?
        super(&block)
      else
        options = args.pop if args.last.is_a?(Hash)
        options ||= {}
        add_meta!(options) if respond_to?(:add_meta!, true)
        add_description!(options) if respond_to?(:add_description!, true)
        args << options
        atp.send(:loop, *args, &block)
      end
    end

    def lo_limit(value, options)
      {
        value:    value,
        rule:     options[:rule] || :gte,
        units:    options[:units],
        selector: options[:selector] || options[:test_mode]
      }
    end

    def hi_limit(value, options)
      {
        value:    value,
        rule:     options[:rule] || :lte,
        units:    options[:units],
        selector: options[:selector] || options[:test_mode]
      }
    end

    def limit(value, options)
      unless options[:rule]
        fail 'You must supply option :rule (e.g. rule: :gt) when calling the limit helper'
      end
      {
        value:    value,
        rule:     options[:rule] || :lt,
        units:    options[:units],
        selector: options[:selector] || options[:test_mode]
      }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
origen_testers-0.52.8 lib/origen_testers/atp/flow_api.rb
origen_testers-0.52.7 lib/origen_testers/atp/flow_api.rb
origen_testers-0.52.6 lib/origen_testers/atp/flow_api.rb
origen_testers-0.52.5 lib/origen_testers/atp/flow_api.rb
origen_testers-0.52.4 lib/origen_testers/atp/flow_api.rb