Skip to content

Commit 564f985

Browse files
committed
Add new test and remove invalidArgType
1 parent 60c08c3 commit 564f985

File tree

3 files changed

+2
-8
lines changed

3 files changed

+2
-8
lines changed

dsc/tests/dsc_functions.tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ Describe 'tests for function expressions' {
386386

387387
It 'indexOf function works for: <expression>' -TestCases @(
388388
@{ expression = "[indexOf(createArray('apple', 'banana', 'cherry'), 'banana')]"; expected = 1 }
389+
@{ expression = "[indexOf(createArray('apple', 'banana', 'cherry'), 'cherry')]"; expected = 2 }
389390
@{ expression = "[indexOf(createArray(10, 20, 30), 20)]"; expected = 1 }
390391
@{ expression = "[indexOf(createArray('a', 'b', 'a', 'c'), 'a')]"; expected = 0 }
391392
@{ expression = "[indexOf(createArray('apple', 'banana'), 'orange')]"; expected = -1 }

dsc_lib/locales/en-us.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ invoked = "and function"
220220
[functions.array]
221221
description = "Convert the value to an array"
222222
invoked = "array function"
223-
invalidArgType = "Invalid argument type, only int, string, array, or object are accepted"
224223

225224
[functions.base64]
226225
description = "Encodes a string to Base64 format"

dsc_lib/src/functions/array.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ impl Function for Array {
3030
fn invoke(&self, args: &[Value], _context: &Context) -> Result<Value, DscError> {
3131
debug!("{}", t!("functions.array.invoked"));
3232

33-
let value = &args[0];
34-
35-
if value.is_number() || value.is_string() || value.is_array() || value.is_object() {
36-
Ok(Value::Array(vec![value.clone()]))
37-
} else {
38-
Err(DscError::Parser(t!("functions.array.invalidArgType").to_string()))
39-
}
33+
Ok(Value::Array(vec![args[0].clone()]))
4034
}
4135
}
4236

0 commit comments

Comments
 (0)