michael@0: # -*- makefile -*- michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: # You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ifdef VERBOSE michael@0: $(warning loading test) michael@0: endif michael@0: michael@0: michael@0: $(call requiredfunction,getargv) michael@0: $(call requiredfunction,subargv) michael@0: $(call requiredfunction,istype isval isvar) michael@0: michael@0: # arg_scalar = [scalar|literal] michael@0: arg_list = foo bar michael@0: arg_ref = arg_list michael@0: michael@0: ## Identify type of function argument(s) michael@0: ######################################## michael@0: ifneq (scalar,$(call istype,arg_scalar)) michael@0: $(error istype(arg_scalar)=scalar, found [$(call istype,arg_scalar)]) michael@0: endif michael@0: ifneq (list,$(call istype,arg_list)) michael@0: $(error istype(arg_list)=list, found [$(call istype,arg_list)]) michael@0: endif michael@0: ifneq (list,$(call istype,arg_ref)) michael@0: $(error istype(arg_ref)=list, found [$(call istype,arg_ref)]) michael@0: endif michael@0: michael@0: ## Type == scalar or a list of values michael@0: ##################################### michael@0: ifneq (true,$(call isval,scalar)) michael@0: $(error isval(scalar)=true, found [$(call isval,scalar)]) michael@0: endif michael@0: ifneq ($(NULL),$(call isval,arg_list)) michael@0: $(error isval(arg_list)=null, found [$(call isval,arg_list)]) michael@0: endif michael@0: michael@0: ## type == reference: macro=>macro => $($(1)) michael@0: ############################################# michael@0: ifneq ($(NULL),$(call isvar,scalar)) michael@0: $(error isvar(scalar)=$(NULL), found [$(call isvar,scalar)]) michael@0: endif michael@0: ifneq (true,$(call isvar,arg_list)) michael@0: $(error isvar(arg_list)=true, found [$(call isvar,arg_list)]) michael@0: endif michael@0: ifneq (true,$(call isvar,arg_ref)) michael@0: $(error isvar(arg_ref)=true, found [$(call isvar,arg_ref)]) michael@0: endif michael@0: michael@0: # Verify getargv expansion michael@0: ########################## michael@0: ifneq (scalar,$(call getargv,scalar)) michael@0: $(error getargv(scalar)=scalar, found [$(call getargv,scalar)]) michael@0: endif michael@0: ifneq ($(arg_list),$(call getargv,arg_list)) michael@0: $(error getargv(arg_list)=list, found [$(call getargv,arg_list)]) michael@0: endif michael@0: ifneq (arg_list,$(call getargv,arg_ref)) michael@0: $(error getargv(arg_ref)=list, found [$(call getargv,arg_ref)]) michael@0: endif michael@0: michael@0: ########################################################################### michael@0: ## michael@0: ########################################################################### michael@0: ifdef MANUAL_TEST #{ michael@0: # For automated testing a callback is needed that can set an external status michael@0: # variable that can be tested. Syntax is tricky to get correct functionality. michael@0: ifdef VERBOSE michael@0: $(info ) michael@0: $(info ===========================================================================) michael@0: $(info Running test: checkIfEmpty) michael@0: $(info ===========================================================================) michael@0: endif michael@0: michael@0: #status = michael@0: #setTRUE =status=true michael@0: #setFALSE =status=$(NULL) michael@0: #$(call checkIfEmpty,setFALSE NULL) michael@0: #$(if $(status),$(error checkIfEmpty(xyz) failed)) michael@0: #$(call checkIfEmpty,setTRUE xyz) michael@0: #$(if $(status),$(error checkIfEmpty(xyz) failed)) michael@0: xyz=abc michael@0: $(info STATUS: warnIfEmpty - two vars) michael@0: $(call warnIfEmpty,foo xyz bar) michael@0: $(info STATUS: errorIfEmpty - on first var) michael@0: $(call errorIfEmpty,foo xyz bar) michael@0: $(error TEST FAILED: processing should not reach this point) michael@0: endif #} michael@0: michael@0: # Verify subargv expansion michael@0: ########################## michael@0: subargs=foo bar tans fans michael@0: subargs_exp=tans fans michael@0: subargs_found=$(call subargv,4,$(subargs)) michael@0: ifneq ($(subargs_exp),$(subargs_found)) michael@0: $(error subargv(4,$(subargs)): expected [$(subargs_exp)] found [$(subargs_found)]) michael@0: endif