summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'include/ruby')
-rw-r--r--include/ruby/assert.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/ruby/assert.h b/include/ruby/assert.h
index ceab090427..e9edd9e640 100644
--- a/include/ruby/assert.h
+++ b/include/ruby/assert.h
@@ -282,6 +282,17 @@ RBIMPL_WARNING_IGNORED(-Wgnu-zero-variadic-macro-arguments)
#endif
/**
+ * A variant of #RUBY_ASSERT that asserts when either #RUBY_DEBUG or built-in
+ * type of `obj` is `type`.
+ *
+ * @param obj Object to check its built-in typue.
+ * @param type Built-in type constant, T_ARRAY, T_STRING, etc.
+ */
+#define RUBY_ASSERT_BUILTIN_TYPE(obj, type) \
+ RUBY_ASSERT(RB_TYPE_P(obj, type), \
+ "Actual type is %s", rb_builtin_type_name(BUILTIN_TYPE(obj)))
+
+/**
* This is either #RUBY_ASSERT or #RBIMPL_ASSUME, depending on #RUBY_DEBUG.
*
* @copydetails #RUBY_ASSERT