Merge branch 'functional-testing' into dev

This commit is contained in:
Gu://em_ 2026-01-24 17:19:50 +01:00
commit adc1bdc841

View file

@ -257,15 +257,192 @@ summarize() {
echo -e "\n\n""===$BGreen TestsuitatorX Ultra Pro Max+ 365 Premium Gris Sidéral" "\n\n"$Color_Off echo -e "\n\n""===$BGreen TestsuitatorX Ultra Pro Max+ 365 Premium Gris Sidéral" "\n\n"$Color_Off
#
echo -e "\n$BBlue=== Builtins ===$Color_Off"
# echo # echo
test_str "Hello" "echo Hello there" test_str "Hello" "echo Hello"
test_str "Hello;" "echo Hello there;" test_str "Hello there" "echo Hello there;"
test_str "Hello there;" "echo Hello there;"
test_str "Hello; there;" "echo Hello; echo there;"
test_str "'Hello'" "echo 'Hello there'" test_str "'Hello'" "echo 'Hello there'"
test_str "Hello;Hello" "echo Hello; echo Wesh attends quoi; echo pouquoi je suis une ligne en dessous" test_str "Hello;Hello" "echo Hello; echo Wesh attends quoi; echo pouquoi je suis une ligne en dessous"
test_str "Echo -n" "echo -n Hello"
test_str "Echo -e" "echo -e 'Hello\nThere'"
test_str "Empty echo" "echo"
test_str "Spaced echo" " echo spaced "
# programs test_str "Exit 0" "exit 0"
test_str "Exit 1" "exit 1"
test_str "True" "true"
test_str "False" "false"
test_str "cd basic" "cd /tmp; pwd"
test_str "cd maison" "cd; pwd"
test_str "Alias basic" "alias foo=echo; foo bar"
test_str "cat $0" "alias foo=echo; foo bar"
echo -e "\n$BBlue=== Programs ===$Color_Off"
test_str "LS" "ls" test_str "LS" "ls"
test_str "Le SS" "lss" test_str "Wrong ls" "sl"
test_str "IPA ma gueule" "ip a"
test_str "Wrong ls" "sl --bachibouzouk"
test_str "ls a b c" "ls a b c"
test_str "ls -a --best" "ls -a --best"
test_str "ls -a --help" "ls -a --help"
echo -e "\n$BBlue=== Quotes ===$Color_Off"
test_str "Single quotes" "echo 'Single Quote'"
test_str "Double quotes" "echo \"Double Quote\""
test_str "Mixed quotes 1" "echo \"Mixed 'Quotes'\""
test_str "Mixed quotes 2" "echo 'Mixed \"Quotes\"'"
test_str "Escaped double quote" "echo \"Escaped \\\"Quote\\\"\""
test_str "Variable in double quotes" "VAR=val; echo \"Variable \$VAR\""
test_str "Variable in single quotes" "VAR=val; echo 'Variable \$VAR'"
test_str "Backslash in double quotes" "echo \"Backslash \\\\\""
test_str "Newline in string" "echo \"New\nline\""
test_str "Empty quotes" "echo '' \"\""
test_str "Concatenated quotes" "echo 'a'\"b\"'c'"
echo -e "\n$BBlue=== Comments ===$Color_Off"
test_str "Hello commentaire" "echo Hello # Commentaire"
test_str "Comment only" "# Comment only"
test_str "Comment after space" "echo foo #bar"
test_str "Hash inside word" "echo foo#bar"
test_str "Comment with special chars" "# echo 'hidden' $PATH"
echo -e "\n$BBlue=== Pipelines ===$Color_Off"
test_str "Simple pipe" "echo Hello | cat"
test_str "Double pipe" "echo Hello | rev | rev" # Pas mal non ? c'est frenssé
test_str "Pipe with grep" "echo 'a\nb\nc' | grep b"
test_str "Pipe exit code (là c'est dur)" "true | false | true"
test_str "Pipe sequence" "echo a | echo b"
test_str "Pipe with chiottes" "ls | wc -l"
echo -e "\n$BBlue=== Redirections ===$Color_Off"
test_str "Redirect output" "echo hello > /tmp/test_redir; cat /tmp/test_redir; rm /tmp/test_redir"
test_str "Append output" "echo Hello > /tmp/test_redir; echo World >> /tmp/test_redir; cat /tmp/test_redir; rm /tmp/test_redir"
test_str "Redirect input" "echo Hello > /tmp/test_in; cat < /tmp/test_in; rm /tmp/test_in"
test_str "Redirect stderr" "echo Error >&2"
test_str "Redirect to null" "echo Hello > /dev/null"
test_str "Redirect both" "ls > /dev/null 2> /dev/null"
test_str "Redirect fd" "echo foo 2>&1"
test_str "Clobbering" "echo foo > file; echo bar > file; cat file; rm file"
test_str "Pipe and redirect" "echo foo | cat > file; cat file; rm file"
test_str "Heredoc basic" "cat << EOF\nhello\nEOF"
echo -e "\n$BBlue=== And/Or ===$Color_Off"
test_str "AND true" "true && echo Oui"
test_str "AND false" "false && echo Non"
test_str "OR true" "true || echo Non"
test_str "OR false" "false || echo Oui"
test_str "AND OR mixed 1" "true && false || echo Oui"
test_str "AND OR mixed 2" "false || true && echo Oui"
test_str "Sequence AND" "echo a && echo b"
test_str "Sequence OR" "echo a || echo b"
test_str "Negation true" "! true"
test_str "Negation false" "! false"
echo -e "\n$BBlue=== If ===$Color_Off"
test_str "If true" "if true; then echo Yes; fi"
test_str "If false else" "if false; then echo No; else echo Yes; fi"
test_str "If elif" "if false; then echo No; elif true; then echo Yes; fi"
test_str "Nested if" "if true; then if true; then echo Nested; fi; fi"
test_str "If multiple commands" "if true; then echo a; echo b; fi"
test_str "If complex condition" "if true && true; then echo Yes; fi"
test_str "If with negation" "if ! false; then echo Yes; fi"
test_str "If faut aller niquer sa mere" "if false; ! false; then echo Embrasse moi; fi"
echo -e "\n$BBlue=== For/While ===$Color_Off"
test_str "While loop" "i=0; while [ \$i -lt 3 ]; do echo \$i; i=\$((i+1)); done"
test_str "Until loop" "i=0; until [ \$i -ge 3 ]; do echo \$i; i=\$((i+1)); done"
test_str "While break" "while true; do echo break; break; done"
test_str "While continue" "i=0; while [ \$i -lt 3 ]; do i=\$((i+1)); if [ \$i -eq 2 ]; then continue; fi; echo \$i; done"
test_str "For loop basic" "for i in a b c; do echo \$i; done"
test_str "For loop glob" "for i in *; do echo \$i; done"
test_str "For loop break" "for i in 1 2 3; do break; done"
test_str "Azy continue la con de ta mère" "for i in 1 2 3; do continue; done"
test_str "For loop empty" "for i in; do echo \$i; done"
test_str "For loop variable" "VAR='a b'; for i in \$VAR; do echo \$i; done"
echo -e "\n$BBlue=== Case ===$Color_Off"
test_str "Case simple" "case a in a) echo Yes;; esac"
test_str "Case basique" "case z in a) echo No;; *) echo Default;; esac"
test_str "Case multiple patterns" "case a in a|b) echo Yes;; esac"
test_str "Case no match (c pcq t'es moche)" "case z in a) echo No;; esac"
test_str "Case with variable" "v=foo; case \$v in foo) echo Yes;; esac"
test_str "Case nested" "case a in a) case b in b) echo Nested;; esac;; esac"
echo -e "\n$BBlue=== Variables ===$Color_Off"
test_str "Set and get" "var=value; echo \$var"
test_str "Braces" "var=value; echo \${var}"
test_str "Multi-word value" "var='a b'; echo \$var"
test_str "Unset" "var=value; unset var; echo \$var"
test_str "Export" "export VAR=val; env | grep VAR"
test_str "Assignment return" "a=1"
test_str "Multiple assignment (ouais askip c possible)" "a=1 b=2; echo \$a \$b"
test_str "Default value" "unset v; echo \${v:-default}"
test_str "Assign default" "unset v; echo \${v:=default}; echo \$v"
test_str "Alternative value" "v=val; echo \${v:+alt}"
test_str "Use default if unset" "echo \${unset_var-default}"
test_str "\$@" "echo \$@"
test_str "\$*" "echo \$*"
test_str "\$?" "echo \$?"
test_str "\$$" "echo \$$"
test_str "\$1" "echo \$1"
test_str "\$2" "echo \$2"
test_str "\${10}" "echo \${10}"
test_str "\$#" "echo \$#"
test_str "\$RANDOM" "echo \$RANDOM"
test_str "\$UID" "echo \$UID"
test_str "\$OLDPWD" "echo \$OLDPWD"
test_str "\$PWD" "echo \$PWD"
test_str "\$IFS" "echo \$IFS"
test_str "Default exit status" "echo \$?"
test_str "Exit status" "true; echo \$?"
test_str "PID" "echo \$\$"
test_str "Arg count" "echo \$#"
echo -e "\n$BBlue=== Arithmetic expansions de fou furieux ===$Color_Off"
test_str "Arithmetic add" "echo \$((1 + 1))"
test_str "Arithmetic mul" "echo \$((2 * 3))"
test_str "Arithmetic div" "echo \$((10 / 2))"
test_str "Arithmetic nested" "echo \$(( (1+2) * 3 ))"
test_str "Arithmetic mod" "echo \$(( 5 % 2 ))"
test_str "Arithmetic var" "var=1; echo \$(( var + 1 ))"
test_str "Command subst" "echo \$(echo command)"
test_str "Backticks" "echo \`echo backticks\`"
test_str "Tilde" "echo ~"
test_str "Length" "v=abc; echo \${#v}"
echo -e "\n$BBlue=== Subshells du démon ===$Color_Off"
test_str "Subshell basic" "(echo a; echo b)"
test_str "Subshell isolation" "var=1; (var=2; echo \$var); echo \$var"
test_str "Subshell exit" "(exit 1); echo \$?"
test_str "Grouping basic" "{ echo a; echo b; }"
test_str "Grouping side effect" "var=1; { var=2; }; echo \$var"
test_str "Nested subshells" "( ( echo nested ) )"
test_str "Subshell redirect" "(echo a) > /tmp/sub; cat /tmp/sub; rm /tmp/sub"
test_str "Group redirect" "{ echo a; } > /tmp/grp; cat /tmp/grp; rm /tmp/grp"
summarize summarize