(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'basic tests for the SHA1 array implementation'>)} spids: [4] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: echo20 body: (BraceGroup children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:prefix) op: assign_op.Equal rhs: { (DQ (braced_var_sub token: <Id.VSub_Number 1> suffix_op: (suffix_op.Unary tok: <Id.VTest_ColonPlus ':+'> arg_word: {($ Id.VSub_Number '$1') <' '>} ) ) ) } spids: [22] ) ] ) (C {<shift>}) (command.WhileUntil keyword: <Id.KW_While while> cond: (condition.Shell commands:[(C {<test>} {($ Id.VSub_Pound '$#')} {<-gt>} {<0>})]) body: (command.DoGroup children: [ (C {<echo>} { (DQ ($ Id.VSub_DollarName '$prefix') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ($ Id.VSub_Number '$1') ) } ) (C {<shift>}) ] ) ) ] ) ) (C {<test_expect_success>} {(SQ <'ordered enumeration'>)} { (SQ <'\n'> <'\techo20 "" 44 55 88 aa >expect &&\n'> <'\t{\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo for_each_unique\n'> <'\t} | test-sha1-array >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'ordered enumeration with duplicate suppression'>)} { (SQ <'\n'> <'\techo20 "" 44 55 88 aa >expect &&\n'> <'\t{\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo for_each_unique\n'> <'\t} | test-sha1-array >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <lookup>)} { (SQ <'\n'> <'\t{\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 lookup 55\n'> <'\t} | test-sha1-array >actual &&\n'> <'\tn=$(cat actual) &&\n'> <'\ttest "$n" -eq 1\n'> ) } ) (C {<test_expect_success>} {(SQ <'lookup non-existing entry'>)} { (SQ <'\n'> <'\t{\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 lookup 33\n'> <'\t} | test-sha1-array >actual &&\n'> <'\tn=$(cat actual) &&\n'> <'\ttest "$n" -lt 0\n'> ) } ) (C {<test_expect_success>} {(SQ <'lookup with duplicates'>)} { (SQ <'\n'> <'\t{\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 lookup 55\n'> <'\t} | test-sha1-array >actual &&\n'> <'\tn=$(cat actual) &&\n'> <'\ttest "$n" -ge 2 &&\n'> <'\ttest "$n" -le 3\n'> ) } ) (C {<test_expect_success>} {(SQ <'lookup non-existing entry with duplicates'>)} { (SQ <'\n'> <'\t{\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 append 88 44 aa 55 &&\n'> <'\t\techo20 lookup 66\n'> <'\t} | test-sha1-array >actual &&\n'> <'\tn=$(cat actual) &&\n'> <'\ttest "$n" -lt 0\n'> ) } ) (C {<test_expect_success>} {(SQ <'lookup with almost duplicate values'>)} { (SQ <'\n'> <'\t{\n'> <'\t\techo "append 5555555555555555555555555555555555555555" &&\n'> <'\t\techo "append 555555555555555555555555555555555555555f" &&\n'> <'\t\techo20 lookup 55\n'> <'\t} | test-sha1-array >actual &&\n'> <'\tn=$(cat actual) &&\n'> <'\ttest "$n" -eq 0\n'> ) } ) (C {<test_expect_success>} {(SQ <'lookup with single duplicate value'>)} { (SQ <'\n'> <'\t{\n'> <'\t\techo20 append 55 55 &&\n'> <'\t\techo20 lookup 55\n'> <'\t} | test-sha1-array >actual &&\n'> <'\tn=$(cat actual) &&\n'> <'\ttest "$n" -ge 0 &&\n'> <'\ttest "$n" -le 1\n'> ) } ) (C {<test_done>}) ] )