Sha256: cb2c42f4c9c7fdbdcc8d53ac559e291ba30d27310b39cf1fd5d1e1c37cb6dc3e

Contents?: true

Size: 491 Bytes

Versions: 1

Compression:

Stored size: 491 Bytes

Contents

module Nanotest
  extend self

  @@failures, @@dots = [], []

  def assert(msg=nil, file=nil, line=nil, stack=caller, &block)
    unless block.call
      f,l = stack.first.match(/(.*):(\d+)/)[1..2]
      @@failures << "(%s:%0.3d) %s" % [file || f, line || l, msg || "assertion failed"]
      @@dots << 'F'
    else
      @@dots << '.'
    end
  end

  def self.results #:nodoc:
    @@dots.join + "\n" + @@failures.join("\n")
  end

  at_exit { puts results unless results.strip.empty? }
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanotest-0.9.4.1 lib/nanotest.rb