Skip to content

Commit

Permalink
tests fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro committed May 30, 2024
1 parent c34f2ed commit 7f4876a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
2 changes: 1 addition & 1 deletion corelib/src/array.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl ArrayIntoSpan<T, +Drop<T>> of Into<Array<T>, Span<T>> {

impl ArraySnapIntoSpan<T> of Into<@Array<T>, Span<T>> {
fn into(self: @Array<T>) -> Span<T> {
self.span()
ArrayTrait::span(self)
}
}

Expand Down
49 changes: 14 additions & 35 deletions corelib/src/test/array_test.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -199,42 +199,21 @@ fn test_array_iterator() {
}
}

mod into_trait_impls {
#[test]
fn array_into_span() {
let array = array![1, 2, 3];

let span: Span<_> = array.into();

assert_eq!(span, array![1, 2, 3].span())
}


#[test]
fn span_into_array() {
let span = array![1, 2, 3].span();

let array: Array<_> = span.into();

assert_eq!(array, array![1, 2, 3]);
}


#[test]
fn array_snap_into_span() {
let array_snap = @array![1, 2, 3];

let span: Span<_> = array_snap.into();

assert_eq!(span, array![1, 2, 3].span())
}
fn tets_array_into_span() {
assert_eq!(array![1, 2, 3].span(), array![1, 2, 3].into())
}

#[test]
fn span_into_array_snap() {
let span = array![1, 2, 3].span();
#[test]
fn tets_span_into_array() {
assert_eq!(array![1, 2, 3], array![1, 2, 3].span().into());
}

let array_snap: @Array<_> = span.into();
#[test]
fn tets_array_snap_into_span() {
assert_eq!(array![1, 2, 3].span(), (@array![1, 2, 3]).into());
}

assert_eq!(array_snap, @array![1, 2, 3]);
}
#[test]
fn tets_span_into_array_snap() {
assert_eq!(@array![1, 2, 3], array![1, 2, 3].span().into());
}

0 comments on commit 7f4876a

Please sign in to comment.