diff --git a/src/macros.rs b/src/macros.rs index 36c1aa2170..ed7408db13 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -1,3 +1,5 @@ +#![allow(unused_imports)] + #[doc(hidden)] #[macro_export] macro_rules! count { @@ -479,6 +481,19 @@ macro_rules! assert_deep_ne { }}; } +pub(crate) use array; +pub(crate) use assert_deep_eq; +pub(crate) use assert_deep_ne; +pub(crate) use bad_slot; +pub(crate) use count; +pub(crate) use jcatch; +pub(crate) use jpanic; +#[cfg(feature = "std")] +pub(crate) use jtry; +pub(crate) use structs; +pub(crate) use table; +pub(crate) use tuple; + #[cfg(all(test, any(feature = "amalgation", feature = "link-system")))] mod tests { // use super::*; diff --git a/src/types/array.rs b/src/types/array.rs index 44a3f88d7a..950761b8f5 100644 --- a/src/types/array.rs +++ b/src/types/array.rs @@ -669,7 +669,7 @@ impl<'data> JanetArray<'data> { /// ``` #[cfg_attr(feature = "inline-more", inline)] pub fn insert(&mut self, index: i32, element: impl Into) { - if index < 0 || index > self.len() + 1 { + if index < 0 || index > self.len() { crate::jpanic!( "insertion index (is {}) should be >= 0 and <= {})", index, @@ -3704,6 +3704,7 @@ mod tests { assert_eq!(array.len(), 4); assert_eq!(array[1], &Janet::integer(2)); assert_eq!(array[2], &Janet::integer(3)); + assert_eq!(array[3], &Janet::integer(4)); array.insert(1, 10); @@ -3711,6 +3712,8 @@ mod tests { assert_eq!(array[1], &Janet::integer(10)); assert_eq!(array[2], &Janet::integer(2)); assert_eq!(array[3], &Janet::integer(3)); + assert_eq!(array[4], &Janet::integer(4)); + Ok(()) }