ruby: added unified assert script
This commit is contained in:
parent
803cf3b434
commit
a06cfa199f
1 changed files with 18 additions and 0 deletions
18
src/mem/ruby/config/assert.rb
Normal file
18
src/mem/ruby/config/assert.rb
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
class AssertionFailure < RuntimeError
|
||||||
|
attr_reader :msg, :output
|
||||||
|
def initialize(message, out=nil)
|
||||||
|
@msg = message
|
||||||
|
@output = out
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class NotImplementedException < Exception
|
||||||
|
end
|
||||||
|
|
||||||
|
def assert(condition,message)
|
||||||
|
unless condition
|
||||||
|
raise AssertionFailure.new(message), "\n\nAssertion failed: \n\n #{message}\n\n"
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue