#!/bin/bash # Tests current namespace application on absent namespace # # Copyright (C) 2014 Mike Gerwitz # # This file is part of pkgsh. # # pkgsh is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # If no namespace exists on the function in which `@::` is used, then the # command should be invoked normally, without any namespace prefix. ## source src/ns.sh declare -a expected=("o n e" two three) declare -a given=() # attempts to invoke `next` within the same namespace try() { # SUT @:: next "$@" } next() { given=("$@") } try "${expected[@]}" set -- "${given[@]}" assert $# -eq "${#expected[@]}" # all arguments should be passed, properly quoted declare -i i=0 while true; do assert "$1" == "${expected[i]}" shift || break ((++i)) done