Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quote retuned text values #104

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/modules/function/invocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ impl SyntaxModule<ParserMetadata> for FunctionInvocation {
impl FunctionInvocation {
fn get_variable(&self, meta: &TranslateMetadata, name: &str, dollar_override: bool) -> String {
let dollar = dollar_override.then_some("$").unwrap_or_else(|| meta.gen_dollar());
let quote = meta.gen_quote();
if matches!(self.kind, Type::Array(_)) {
let quote = meta.gen_quote();
format!("{quote}{dollar}{{{name}[@]}}{quote}")
} else if matches!(self.kind, Type::Text) {
format!("{quote}{dollar}{{{name}}}{quote}")
} else {
format!("{dollar}{name}")
}
Expand Down
8 changes: 7 additions & 1 deletion src/tests/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,10 @@ fn test_std_library() {
loop word in words(\"hello world ciao mondo\") {
echo word
}
// Split a joined string into a list of string
loop word in words(join([\"hello\", \"world\"], \" \")) {
echo word
}
// Join a list of strings into a string
echo join(split(\"hello world\", \"l\"), \"l\")
// Transform string into a lowercase string
Expand Down Expand Up @@ -798,6 +802,8 @@ fn test_std_library() {
"world",
"ciao",
"mondo",
"hello",
"world",
"hello world",
"hello world",
"HELLO WORLD",
Expand Down Expand Up @@ -1120,5 +1126,5 @@ fn variable_ref_function_invocation() {
unsafe foo(a)
echo a
";
test_amber!(code, "sram");
test_amber!(code, "\"sram\"");
}