ruby: added unified assert script
authorDerek Hower <drh5@cs.wisc.edu>
Tue, 15 Sep 2009 16:32:11 +0000 (11:32 -0500)
committerDerek Hower <drh5@cs.wisc.edu>
Tue, 15 Sep 2009 16:32:11 +0000 (11:32 -0500)
src/mem/ruby/config/assert.rb [new file with mode: 0644]

diff --git a/src/mem/ruby/config/assert.rb b/src/mem/ruby/config/assert.rb
new file mode 100644 (file)
index 0000000..cc3e432
--- /dev/null
@@ -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