#!/usr/local/bin/bash
clear
export PS4='\e[90m+${LINENO} in ${#BASH_SOURCE[@]}>${FUNCNAME[0]}:${BASH_SOURCE[@]##*/} \e[0m'
#set -x

level=$1
if [ -z "$level" ]; then
  level=3
fi
echo "starting: $0 <LOG_LEVEL=$1>"

echo "sourcing init"
source init

#log.level 5


important.log "
now in $0
"

console.log   "can you see console.log"
important.log "can you see important.log"
warn.log      "can you see warn.log"

echo "switching log level back to 4"
log.level 6
this.isSourced

important.log "
now starting init
"
init
warn.log      "done with starting init"


log.level 3
source test.suite

expect.error 127
test.case - "error cannot be catched: re-call mycmd feature3 produces an error because it was one time sourced and " 
  mycmd.feature3 hello world
expect 127 "*"


test.call.recall() 
{
  #expect.error 127
  mycmd.feature3 hello world
}
test.case - "error catched correctly: re-call mycmd feature3 produces an error because it was one time sourced" \
  test.call.recall
expect 127 "*"

test.call.recall.suppressed() 
{
  expect.error 127
  mycmd.feature3 hello world
}
test.case - "error catched and suppressed: re-call mycmd feature3 produces an error because it was one time sourced" \
  test.call.recall.suppressed
expect 127 "*"