diff --git a/crates/nu-command/tests/commands/math/mod.rs b/crates/nu-command/tests/commands/math/mod.rs index 8de67777c5..a9b8075df6 100644 --- a/crates/nu-command/tests/commands/math/mod.rs +++ b/crates/nu-command/tests/commands/math/mod.rs @@ -498,11 +498,3 @@ fn append_binary_values() { )); assert_eq!(actual.out, "0x[01020304]"); } - -#[test] -fn int_multiple_string() { - let actual = nu!(pipeline(r#"3 * "ab""#)); - assert_eq!(actual.out, "ababab"); - let actual = nu!(pipeline(r#""ab" * 3"#)); - assert_eq!(actual.out, "ababab"); -} diff --git a/crates/nu-command/tests/commands/parse.rs b/crates/nu-command/tests/commands/parse.rs index f8ec08bf63..e01f26d1a8 100644 --- a/crates/nu-command/tests/commands/parse.rs +++ b/crates/nu-command/tests/commands/parse.rs @@ -214,14 +214,16 @@ mod regex { #[test] fn parse_handles_external_stream_chunking() { - Playground::setup("parse_test_streaming_1", |dirs, _sandbox| { + Playground::setup("parse_test_streaming_1", |dirs, sandbox| { + let data: String = std::iter::repeat("abcdefghijklmnopqrstuvwxyz") + .take(1000) + .collect(); + sandbox.with_files(vec![Stub::FileWithContent("data.txt", &data)]); + let actual = nu!( - cwd: dirs.test(), pipeline( - r#" - "abcdefghijklmnopqrstuvwxyz" * 1000 | save --force data.txt; - open data.txt | parse --regex "(abcdefghijklmnopqrstuvwxyz)" | length - "# - )); + cwd: dirs.test(), + r#"open data.txt | parse --regex "(abcdefghijklmnopqrstuvwxyz)" | length"# + ); assert_eq!(actual.out, "1000"); }) diff --git a/crates/nu-parser/src/type_check.rs b/crates/nu-parser/src/type_check.rs index 3e43bf40b4..00cbc67ba4 100644 --- a/crates/nu-parser/src/type_check.rs +++ b/crates/nu-parser/src/type_check.rs @@ -239,8 +239,6 @@ pub fn math_result_type( (Type::Int, Type::Duration) => (Type::Duration, None), (Type::Duration, Type::Float) => (Type::Duration, None), (Type::Float, Type::Duration) => (Type::Duration, None), - (Type::Int, Type::String) => (Type::String, None), - (Type::String, Type::Int) => (Type::String, None), (Type::Custom(a), Type::Custom(b)) if a == b => (Type::Custom(a.to_string()), None), (Type::Custom(a), _) => (Type::Custom(a.to_string()), None), diff --git a/crates/nu-protocol/src/eval_const.rs b/crates/nu-protocol/src/eval_const.rs index 4ca2129e4e..ca8297f146 100644 --- a/crates/nu-protocol/src/eval_const.rs +++ b/crates/nu-protocol/src/eval_const.rs @@ -415,16 +415,6 @@ pub fn eval_constant( } } Operator::Math(math) => { - match (&math, &lhs.expr, &rhs.expr) { - // Multiple may generate super long string - // and stop the whole shell while highlighting - // e.g. '2 ** 60 * a' - (Math::Multiply, Expr::String(..), _) - | (Math::Multiply, _, Expr::String(..)) => { - return Err(ShellError::NotAConstant(expr.span)) - } - _ => {} - } let lhs = eval_constant(working_set, lhs)?; let rhs = eval_constant(working_set, rhs)?; diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 5ed0f3e81e..0cebaecb1b 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -2649,20 +2649,6 @@ impl Value { (Value::CustomValue { val: lhs, .. }, rhs) => { lhs.operation(self.span(), Operator::Math(Math::Multiply), op, rhs) } - (Value::Int { val: lhs, .. }, Value::String { val: rhs, .. }) => { - let mut res = String::new(); - for _ in 0..*lhs { - res.push_str(rhs) - } - Ok(Value::string(res, span)) - } - (Value::String { val: lhs, .. }, Value::Int { val: rhs, .. }) => { - let mut res = String::new(); - for _ in 0..*rhs { - res.push_str(lhs) - } - Ok(Value::string(res, span)) - } _ => Err(ShellError::OperatorMismatch { op_span: op, lhs_ty: self.get_type().to_string(), diff --git a/crates/nu-std/std/testing.nu b/crates/nu-std/std/testing.nu index 16b7f41007..24e3dffb16 100644 --- a/crates/nu-std/std/testing.nu +++ b/crates/nu-std/std/testing.nu @@ -134,7 +134,7 @@ def show-pretty-test [indent: int = 4] { let test = $in [ - (" " * $indent) + (1..$indent | map {" "} | str join) (match $test.result { "pass" => { ansi green }, "skip" => { ansi yellow }, diff --git a/tests/const_/mod.rs b/tests/const_/mod.rs index cc35d5f6f4..07383845ee 100644 --- a/tests/const_/mod.rs +++ b/tests/const_/mod.rs @@ -142,7 +142,6 @@ fn const_binary_operator(#[case] inp: &[&str], #[case] expect: &str) { #[case(&["const x = 10 ** 10000000", "$x"], "pow operation overflowed")] #[case(&["const x = 2 ** 62 * 2", "$x"], "multiply operation overflowed")] #[case(&["const x = 1 ++ 0", "$x"], "doesn't support this value")] -#[case(&["const x = 20 * a", "$x"], "Value is not a parse-time constant")] fn const_operator_error(#[case] inp: &[&str], #[case] expect: &str) { let actual = nu!(&inp.join("; ")); assert!(actual.err.contains(expect));