From 8fb4dffd6b0e6833a66e8ada3132ea59a18a18cc Mon Sep 17 00:00:00 2001 From: Devin Jean Date: Thu, 19 Oct 2023 18:13:28 -0500 Subject: [PATCH] reshape changes --- src/process.rs | 8 ++------ src/test/blocks/list-reshape.xml | 2 +- src/test/process.rs | 5 +++-- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/process.rs b/src/process.rs index 9dc176c..ecf10b4 100644 --- a/src/process.rs +++ b/src/process.rs @@ -1379,13 +1379,9 @@ mod ops { Ok(res) } pub(super) fn reshape<'gc, C: CustomTypes, S: System>(mc: &Mutation<'gc>, src: &Value<'gc, C, S>, dims: &[usize]) -> Result, ErrorCause> { - if dims.iter().any(|&x| x == 0) { - return Ok(Gc::new(mc, RefLock::new(VecDeque::default())).into()) - } - - let mut src = ops::flatten(src)?; + let src = ops::flatten(src)?; if src.is_empty() { - src.push_back(empty_string().into()); + return Err(ErrorCause::EmptyList); } fn reshape_impl<'gc, C: CustomTypes, S: System>(mc: &Mutation<'gc>, src: &mut Cycle>>, dims: &[usize]) -> Value<'gc, C, S> { diff --git a/src/test/blocks/list-reshape.xml b/src/test/blocks/list-reshape.xml index c791327..a6dafec 100644 --- a/src/test/blocks/list-reshape.xml +++ b/src/test/blocks/list-reshape.xml @@ -1 +1 @@ -
\ No newline at end of file +
errerr
\ No newline at end of file diff --git a/src/test/process.rs b/src/test/process.rs index 6e88d56..c83a186 100644 --- a/src/test/process.rs +++ b/src/test/process.rs @@ -1561,11 +1561,12 @@ fn test_proc_list_reshape() { [["e", "l", "l", "1", "h"]], [["e", "l", "l", "gh", "3"]], ], - [], + [[], [], [], []], "3", "3", [[6, 6, 6], [6, 6, 6]], - [["", ""], ["", ""]], + "EmptyList", + "EmptyList", ])).unwrap(); assert_values_eq(&res.unwrap().0.unwrap(), &expect, 1e-5, "list reshape"); });