#!/bin/bash # -*- shell-script -*- proc test_set0 { if ! enable -f $(abs_top_builddir)/builtin/set0 set0 >/dev/null !2 > !1 { echo 'set0 tests skipped because you do not have the builtin' startSkipping return } typeset oldname=$0 set0 'newname' 'bar' !2 >/dev/null assertFalse "set0 should fail." "$Status" set0 'newname' assertTrue "set0 should work this time." "$Status" assertEquals 'newname' $0 [[ $oldname != $0 ]] assertTrue "old $oldname should not equal new $0" "$Status" } if test '/src/external-vcs/sourceforge/bashdb' = '' { echo "Something is wrong: abs_top_srcdir is not set." exit 1 } global abs_top_builddir := '/src/external-vcs/sourceforge/bashdb' global abs_top_builddir := "$(abs_top_builddir%%/)/" global abs_top_srcdir := '/src/external-vcs/sourceforge/bashdb' # Make sure $abs_top_srcdir has a trailing slash global abs_top_srcdir := "$(abs_top_srcdir%%/)/" source ${abs_top_srcdir}test/unit/helper.sh set -- # reset $# so shunit2 doesn't get confused. [[ $0 == ${BASH_SOURCE} ]] && source ${shunit_file} (CommandList children: [ (FuncDef name: test_set0 body: (BraceGroup children: [ (If arms: [ (if_arm cond: [ (Sentence child: (Pipeline children: [ (SimpleCommand words: [ {(enable)} {(-f)} {(${ VSub_Name abs_top_builddir) (/builtin/set0)} {(set0)} ] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [29] ) (Redir op_id: Redir_GreatAnd fd: 2 arg_word: {(1)} spids: [32] ) ] ) ] negated: True ) terminator: ) ] action: [ (C {(echo)} {(SQ <"set0 tests skipped because you do not have the builtin">)}) (C {(startSkipping)}) (ControlFlow token:) ] spids: [-1 37] ) ] spids: [-1 53] ) (C {(typeset)} {(Lit_VarLike "oldname=") ($ VSub_Number "$0")}) (SimpleCommand words: [{(set0)} {(SQ )} {(SQ )}] redirects: [(Redir op_id:Redir_Great fd:2 arg_word:{(/dev/null)} spids:[72])] ) (C {(assertFalse)} {(DQ ("set0 should fail."))} {(DQ ($ VSub_QMark "$?"))}) (C {(set0)} {(SQ )}) (C {(assertTrue)} {(DQ ("set0 should work this time."))} {(DQ ($ VSub_QMark "$?"))}) (C {(assertEquals)} {(SQ )} {(DQ ($ VSub_Number "$0"))}) (DBracket expr: (BoolBinary op_id: BoolBinary_GlobNEqual left: {($ VSub_Name "$oldname")} right: {($ VSub_Number "$0")} ) ) (C {(assertTrue)} { (DQ ("old ") ($ VSub_Name "$oldname") (" should not equal new ") ($ VSub_Number "$0")) } {(DQ ($ VSub_QMark "$?"))} ) ] spids: [11] ) spids: [7 10] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(Lit_Other "[")} {(SQ )} {(Lit_Other "=")} {(SQ )} {(Lit_Other "]")} ) terminator: ) ] action: [ (C {(echo)} {(DQ ("Something is wrong: abs_top_srcdir is not set."))}) (C {(exit)} {(1)}) ] spids: [-1 161] ) ] spids: [-1 175] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:abs_top_builddir) op: Equal rhs: {(/src/external-vcs/sourceforge/bashdb)} spids: [177] ) ] spids: [177] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:abs_top_builddir) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{(Lit_Slash /)}) spids: [181 185] ) (/) } spids: [180] ) ] spids: [180] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:abs_top_srcdir) op: Equal rhs: {(/src/external-vcs/sourceforge/bashdb)} spids: [188] ) ] spids: [188] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:abs_top_srcdir) op: Equal rhs: { (BracedVarSub token: suffix_op: (StringUnary op_id:VOp1_DPercent arg_word:{(Lit_Slash /)}) spids: [195 199] ) (/) } spids: [194] ) ] spids: [194] ) (C {(.)} {(${ VSub_Name abs_top_srcdir) (test/unit/helper.sh)}) (C {(set)} {(--)}) (AndOr children: [ (DBracket expr: (BoolBinary op_id: BoolBinary_GlobDEqual left: {($ VSub_Number "$0")} right: {(${ VSub_Name BASH_SOURCE)} ) ) (C {(.)} {(${ VSub_Name shunit_file)}) ] op_id: Op_DAmp ) ] )