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

Testsuite: cleaned up basic varibles test case.

parent a4faba00
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,11 @@ Testing variables... ...@@ -10,7 +10,11 @@ Testing variables...
. .
; ;
test "ASSIGNMENT-1" { /*
* Variable assignments
*/
test "Basic assignment" {
set "test" "Value"; set "test" "Value";
if not string :is "${test}" "Value" { if not string :is "${test}" "Value" {
...@@ -22,7 +26,7 @@ test "ASSIGNMENT-1" { ...@@ -22,7 +26,7 @@ test "ASSIGNMENT-1" {
} }
} }
test "ASSIGNMENT-2" { test "Assignment overwritten" {
set "test" "Value"; set "test" "Value";
set "test" "More"; set "test" "More";
...@@ -31,11 +35,15 @@ test "ASSIGNMENT-2" { ...@@ -31,11 +35,15 @@ test "ASSIGNMENT-2" {
} }
if string :is "${test}" "Value" { if string :is "${test}" "Value" {
test_fail "value not overwritten";
}
if string :is "${test}" "nonsense" {
test_fail "string test failed"; test_fail "string test failed";
} }
} }
test "ASSIGNMENT-3" { test "Two assignments" {
set "test" "Value"; set "test" "Value";
set "test2" "More"; set "test2" "More";
...@@ -44,121 +52,125 @@ test "ASSIGNMENT-3" { ...@@ -44,121 +52,125 @@ test "ASSIGNMENT-3" {
} }
if string :is "${test}" "More" { if string :is "${test}" "More" {
test_fail "assignments to different variables overlap";
}
if string :is "${test}" "nonsense" {
test_fail "string test failed"; test_fail "string test failed";
} }
} }
test "MODIFIER-lower" { /*
* Modifiers
*/
test "Modifier :lower" {
set :lower "test" "VaLuE"; set :lower "test" "VaLuE";
if not string :is "${test}" "value" { if not string :is "${test}" "value" {
test_fail "variable modified assignment failed"; test_fail "modified variable assignment failed";
}
if string :is "${test}" "VALUE" {
test_fail "string test failed";
} }
} }
test "MODIFIER-lower-upperfirst" { test "Modifiers :lower :upperfirst" {
set :lower :upperfirst "test" "vAlUe"; set :lower :upperfirst "test" "vAlUe";
if string :is "${test}" "value" {
test_fail "modifiers applied with wrong precedence";
}
if not string :is "${test}" "Value" { if not string :is "${test}" "Value" {
test_fail "variable modified assignment failed"; test_fail "modified variable assignment failed";
} }
}
test "Modifiers :upperfirst :lower" {
set :upperfirst :lower "test" "vAlUe";
if string :is "${test}" "value" { if string :is "${test}" "value" {
test_fail "string test failed"; test_fail "modifiers applied with wrong precedence";
}
if not string :is "${test}" "Value" {
test_fail "modified variable assignment failed";
} }
} }
test "MODIFIER-upper" { test "Modifier :upper" {
set :upper "test" "vAlUe"; set :upper "test" "vAlUe";
if not string :is "${test}" "VALUE" { if not string :is "${test}" "VALUE" {
test_fail "variable modified assignment failed"; test_fail "modified variable assignment failed";
}
if string :is "${test}" "value" {
test_fail "string test failed";
} }
} }
test "MODIFIER-upper-lowerfirst" { test "Modifiers :upper :lowerfirst" {
set :lowerfirst :upper "test" "VaLuE"; set :upper :lowerfirst "test" "VaLuE";
if not string :is "${test}" "vALUE" { if string :is "${test}" "VALUE" {
test_fail "variable modified assignment failed"; test_fail "modifiers applied with wrong precedence";
} }
if string :is "${test}" "value" { if not string :is "${test}" "vALUE" {
test_fail "string test failed"; test_fail "modified variable assignment failed";
} }
} }
test "MODIFIER-upper-lowerfirst" { test "Modifiers :lowerfirst :upper" {
set :lowerfirst :upper "test" "VaLuE"; set :lowerfirst :upper "test" "VaLuE";
if not string :is "${test}" "vALUE" { if string :is "${test}" "VALUE" {
test_fail "variable modified assignment failed"; test_fail "modifiers applied with wrong precedence";
} }
if string :is "${test}" "value" { if not string :is "${test}" "vALUE" {
test_fail "string test failed"; test_fail "modified variable assignment failed";
} }
} }
test "MODIFIER-length-1" { test "Modifier :length" {
set :length "test" "VaLuE"; set :length "test" "VaLuE";
if not string :is "${test}" "5" { if not string :is "${test}" "5" {
test_fail "variable modified assignment failed"; test_fail "modified variable assignment failed";
}
if string :is "${test}" "value" {
test_fail "string test failed";
} }
} }
test "MODIFIER-length-2" { test "Modifier :length (elaborate)" {
set "a" "abcdefghijklmnopqrstuvwxyz"; set "a" "abcdefghijklmnopqrstuvwxyz";
set "b" "1234567890"; set "b" "1234567890";
set :length "test" " ${a}:${b} "; set :length "test" " ${a}:${b} ";
if not string :is "${test}" "40" { if not string :is "${test}" "40" {
test_fail "variable modified assignment failed"; test_fail "modified variable assignment failed";
}
if string :is "${test}" "41" {
test_fail "string test failed";
} }
} }
test "MODIFIER-quotewildcard-1" { test "Modifier :quotewildcard" {
set :quotewildcard "test" "^^***??**^^"; set :quotewildcard "test" "^^***??**^^";
if not string :is "${test}" "^^\\*\\*\\*\\?\\?\\*\\*^^" { if not string :is "${test}" "^^\\*\\*\\*\\?\\?\\*\\*^^" {
test_fail "variable modified assignment failed"; test_fail "modified variable assignment failed";
}
if string :is "${test}" "^^***??**^^" {
test_fail "string test failed";
} }
} }
test "MODIFIER-quotewildcard-2" { test "Modifier :length :quotewildcard" {
set :length :quotewildcard "test" "^^***??**^^"; set :length :quotewildcard "test" "^^***??**^^";
if not string :is "${test}" "18" { if string :is "${test}" "11" {
test_fail "variable modified assignment failed"; test_fail "modifiers applied with wrong precedence";
} }
if string :is "${test}" "17" { if not string :is "${test}" "18" {
test_fail "string test failed"; test_fail "modified variable assignment failed";
} }
} }
test "MULTI-variable" { /*
* Variable substitution
*/
test "Multiple substitutions" {
set "a" "the monkey"; set "a" "the monkey";
set "b" "a nut"; set "b" "a nut";
set "c" "the fish"; set "c" "the fish";
...@@ -167,21 +179,19 @@ test "MULTI-variable" { ...@@ -167,21 +179,19 @@ test "MULTI-variable" {
set "f" "is"; set "f" "is";
if not string :is "${a} ${e} ${b}" "the monkey eats a nut" { if not string :is "${a} ${e} ${b}" "the monkey eats a nut" {
test_fail "variable composition failed (1)"; test_fail "variable substitution failed (1)";
} }
if not string :is "${c} ${f} ${d}" "the fish is on fire" { if not string :is "${c} ${f} ${d}" "the fish is on fire" {
test_fail "variable composition failed (2)"; test_fail "variable substitution failed (2)";
}
if string :is "${a} ${f} ${c}" "the monkey eats a nut" {
test_fail "string test failed";
} }
set :upperfirst "sentence" "${a} ${e} ${b}"; set :upperfirst "sentence" "${a} ${e} ${b}";
if not string :is "${sentence}" "The monkey eats a nut" { if not string :is "${sentence}" "The monkey eats a nut" {
test_fail "modified variable composition failed"; test_fail "modified variable substitution failed";
} }
} }
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.