(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'Test diff/status color escape codes'>)} spids: [13] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: color body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:actual) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<git>} {<config>} {<--get-color>} {<no.such.slot>} {(DQ ($ Id.VSub_Number '$1'))} ) ) } spids: [30] ) ] ) (C {<test>} {(DQ ($ Id.VSub_DollarName '$actual'))} {<Id.Lit_Equals '='>} {(DQ <'\x1b'> ($ Id.VSub_Number '$2'))} ) ] ) ] ) ) (command.ShFunction name: invalid_color body: (BraceGroup children: [ (C {<test_must_fail>} {<git>} {<config>} {<--get-color>} {<no.such.slot>} {(DQ ($ Id.VSub_Number '$1'))} ) ] ) ) (C {<test_expect_success>} {(SQ <reset>)} {(SQ <'\n'> <'\tcolor "reset" "[m"\n'>)}) (C {<test_expect_success>} {(SQ <'attribute before color name'>)} {(SQ <'\n'> <'\tcolor "bold red" "[1;31m"\n'>)} ) (C {<test_expect_success>} {(SQ <'color name before attribute'>)} {(SQ <'\n'> <'\tcolor "red bold" "[1;31m"\n'>)} ) (C {<test_expect_success>} {(SQ <'attr fg bg'>)} {(SQ <'\n'> <'\tcolor "ul blue red" "[4;34;41m"\n'>)} ) (C {<test_expect_success>} {(SQ <'fg attr bg'>)} {(SQ <'\n'> <'\tcolor "blue ul red" "[4;34;41m"\n'>)} ) (C {<test_expect_success>} {(SQ <'fg bg attr'>)} {(SQ <'\n'> <'\tcolor "blue red ul" "[4;34;41m"\n'>)} ) (C {<test_expect_success>} {(SQ <'fg bg attr...'>)} {(SQ <'\n'> <'\tcolor "blue bold dim ul blink reverse" "[1;2;4;5;7;34m"\n'>)} ) (C {<test_expect_success>} {(SQ <'attr negation'>)} {(SQ <'\n'> <'\tcolor "nobold nodim noul noblink noreverse" "[22;24;25;27m"\n'>)} ) (C {<test_expect_success>} {(SQ <'"no-" variant of negation'>)} {(SQ <'\n'> <'\tcolor "no-bold no-blink" "[22;25m"\n'>)} ) (C {<test_expect_success>} {(SQ <'long color specification'>)} {(SQ <'\n'> <'\tcolor "254 255 bold dim ul blink reverse" "[1;2;4;5;7;38;5;254;48;5;255m"\n'>)} ) (C {<test_expect_success>} {(SQ <'absurdly long color specification'>)} { (SQ <'\n'> <'\tcolor \\\n'> <'\t "#ffffff #ffffff bold nobold dim nodim italic noitalic\n'> <'\t ul noul blink noblink reverse noreverse strike nostrike" \\\n'> <'\t "[1;2;3;4;5;7;9;22;23;24;25;27;29;38;2;255;255;255;48;2;255;255;255m"\n'> ) } ) (C {<test_expect_success>} {(SQ <'0-7 are aliases for basic ANSI color names'>)} {(SQ <'\n'> <'\tcolor "0 7" "[30;47m"\n'>)} ) (C {<test_expect_success>} {(SQ <'256 colors'>)} {(SQ <'\n'> <'\tcolor "254 bold 255" "[1;38;5;254;48;5;255m"\n'>)} ) (C {<test_expect_success>} {(SQ <'24-bit colors'>)} {(SQ <'\n'> <'\tcolor "#ff00ff black" "[38;2;255;0;255;40m"\n'>)} ) (C {<test_expect_success>} {(SQ <'"normal" yields no color at all"'>)} {(SQ <'\n'> <'\tcolor "normal black" "[40m"\n'>)} ) (C {<test_expect_success>} {(SQ <'-1 is a synonym for "normal"'>)} {(SQ <'\n'> <'\tcolor "-1 black" "[40m"\n'>)} ) (C {<test_expect_success>} {(SQ <'color too small'>)} {(SQ <'\n'> <'\tinvalid_color "-2"\n'>)}) (C {<test_expect_success>} {(SQ <'color too big'>)} {(SQ <'\n'> <'\tinvalid_color "256"\n'>)}) (C {<test_expect_success>} {(SQ <'extra character after color number'>)} {(SQ <'\n'> <'\tinvalid_color "3X"\n'>)} ) (C {<test_expect_success>} {(SQ <'extra character after color name'>)} {(SQ <'\n'> <'\tinvalid_color "redX"\n'>)} ) (C {<test_expect_success>} {(SQ <'extra character after attribute'>)} {(SQ <'\n'> <'\tinvalid_color "dimX"\n'>)} ) (C {<test_expect_success>} {(SQ <'unknown color slots are ignored (diff)'>)} { (SQ <'\n'> <'\tgit config color.diff.nosuchslotwilleverbedefined white &&\n'> <'\tgit diff --color\n'> ) } ) (C {<test_expect_success>} {(SQ <'unknown color slots are ignored (branch)'>)} { (SQ <'\n'> <'\tgit config color.branch.nosuchslotwilleverbedefined white &&\n'> <'\tgit branch -a\n'> ) } ) (C {<test_expect_success>} {(SQ <'unknown color slots are ignored (status)'>)} { (SQ <'\n'> <'\tgit config color.status.nosuchslotwilleverbedefined white &&\n'> <'\t{ git status; ret=$?; } &&\n'> <'\tcase $ret in 0|1) : ok ;; *) false ;; esac\n'> ) } ) (C {<test_done>}) ] )