Sha256: 715c203c40f57da5b8f372f0ac7c3ccb74754f0dc55d3504310d1e7c46639b63

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

require 'ae/assertion'

class AE
  # Given that x is "tom" then we can assert it
  # is using an asseretion pipe.
  #
  #  x = "tom"
  #
  #  T x == "tom"
  #
  # We can assert the opposite using F.
  #
  #  F x == "tom"
  #
  # These can be used at any point of return.
  #
  #  T case x
  #     when 'tom' then true
  #     else false
  #     end
  #
  module Detest

    # Test for true.
    #
    #   T 1 == 1
    #
    def T(x=nil, &b)
      Assertion.test(x || b.call, :backtrace=>caller)
    end

    # Test for not.
    #
    #   F 1 == 2
    #
    def F(x=nil, &b)
      Assertion.test(!(x || b.call), :backtrace=>caller)
    end

    # Test for nil?.
    #
    #   N nil
    #
    def N(x=nil,&b)
      Assertion.test(nil == (x || b.call), :backtrace=>caller)
    end

    # Expect and error.
    #
    #   E { raise }
    #
    # Unless #T, #F and #N, the #E method only supports block notation.
    def E(&b)
      expect(Exception, &b)
    end

    # Catch a symbol.
    #def C
    #end
  end

  module World
    include AE::Detest
  end

end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ae-1.7.0 lib/ae/detest.rb
ae-1.6.1 lib/ae/detest.rb
ae-1.6.0 lib/ae/detest.rb