Skip to content
Snippets Groups Projects
Commit 71e66c81 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Variables: fixed bug in variables substitution (RFC example failed during testing).

parent b29320f2
No related branches found
No related tags found
No related merge requests found
......@@ -299,11 +299,12 @@ static bool arg_variable_string_validate
strstart = p + 1;
substart = strstart;
p++;
}
/* Finished, reset for the next substitution */
state = ST_NONE;
p++;
}
}
......
......@@ -21,7 +21,14 @@ test "Unknown variables" {
set "qwer" "dddd";
set "qwert" "ccc";
if not string "[${qwerty}]" "[]" {
if anyof (
not string "[${qwerty}]" "[]",
not string "[${5000}]" "[]",
not string "[${qwerty.asdf}]" "[]",
not string "[${qwerty.asdf.0.1.34.5}]" "[]",
not string "[${qwerty.asdf.hokey.pokey}]" "[]",
not string "[${qwerty.asdf.0.frop}]" "[]"
) {
test_fail "unknown variable not substituted with empty string";
}
}
......@@ -48,12 +55,43 @@ test "Syntax errors" {
not string "${" "${s}{",
not string "${a" "${s}{a",
not string "${$}" "${s}{$}",
not string "${%%%%}" "${s}{%%%%}" )
not string "${%%%%}" "${s}{%%%%}",
not string "${0.s}" "${s}{0.s}",
not string "&%${}!" "&%${s}{}!",
not string "${doh!}" "${s}{doh!}" )
{
test_fail "variables substitution changed substring not matching variable-ref";
}
}
test "RFC syntax examples" {
# The variable "company" holds the value "ACME". No other variables
# are set.
set "company" "ACME";
# "${full}" => the empty string
if not string :is "${full}" "" {
test_fail "unknown variable did not yield empty string";
}
# "${company}" => "ACME"
if not string :is "${company}" "ACME" {
test_fail "assigned variable did not get substituted";
}
# "${BAD${Company}" => "${BADACME"
if not string :is "${BAD${Company}" "${BADACME" {
test_fail "'BADACME' test did not yield expected result";
}
#"${President, ${Company} Inc.}"
# => "${President, ACME Inc.}"
if not string "${President, ${Company} Inc.}"
"${President, ACME Inc.}" {
test_fail "'Company president' test did not yield expected result";
}
}
/*
* Variable assignments
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.