Navigation

Operators and Keywords

Function List:

C++ API

test.m File Reference


Functions

 if (nargin< 2||isempty(__flag)) __flag
endif if (nargin< 1||nargin > 3||(!ischar(__name)&&!isempty(__name))||!ischar(__flag)) print_usage()
endif if (isempty(__name)&&(nargin!=3||!strcmp(__flag,"explain"))) print_usage()
 if (__batch) if(ischar(__fid)) __fid
endif fprintf (__fid,"%sprocessing %s\n", __signal_file, __name)
 fflush (__fid)
endif if (strcmp(__flag,"normal")) __grabdemo=0
 elseif (strcmp(__flag,"quiet")) __grabdemo=0
 elseif (strcmp(__flag,"verbose")) __grabdemo=0
 elseif (strcmp(__flag,"grabdemo")) __grabdemo
 elseif (strcmp(__flag,"explain")) fprintf(__fid
 fprintf (__fid,"# %s no tests in file\n", __signal_empty)
 fprintf (__fid,"# %s test had an unexpected result\n", __signal_fail)
 fprintf (__fid,"# %s code for the test\n", __signal_block)
 fprintf (__fid,"# Search for the unexpected results in the file\n")
 fprintf (__fid,"# then page back to find the file name which caused it.\n")
 fprintf (__fid,"# The result may be an unexpected failure (in which\n")
 fprintf (__fid,"# case an error will be reported) or an unexpected\n")
 fprintf (__fid,"# success (in which case no error will be reported).\n")
 if (__close_fid) fclose(__fid)
else error ("test unknown flag '%s'", __flag)
 if (isempty(__file)) __file
endif if (iscell(__file)) if(isempty(__file)) __file
else fprintf (__fid,"%s%s does not exist in path\n", __signal_empty, __name)
 if (nargout > 0) __ret1
 if (isempty(__body)) if(__grabdemo) __ret1
else fprintf (__fid,"%s%s has no tests available\n", __signal_empty, __file)
else if (__body(length(__body))=="\n") __body
 if (__verbose) disp(cstrcat(__signal_file
 if (isempty(__idx)) __type
 if (__grabdemo||__isdemo) __istest=0
 if (__grabdemo &&__isdemo) if(isempty(__demo_code)) __demo_code
endif elseif (__rundemo &&__isdemo) eval(sprintf("function __test__()\n%s\nendfunction"
 input ("Press <enter> to continue: ","s")
endif elseif (strcmp(__type,"test")||strcmp(__type,"xtest")) __istest
 elseif (strcmp(__block(1:1),"#")) __istest=0
endif if (!isempty(__code)) eval(sprintf("function %s__test__(%s)\n%s\nendfunction"
 eval (sprintf("%s__test__(%s);", __shared_r, __shared))
 if (isempty(right)) return
 if (isempty(left)) return
 if (!isempty(str)&&str(1)=="<") close
 if (close) pattern
 if (!isempty(leading)) str
 if (fid >=0) while(!feof(fid)) ln
 if (length(ln) >=2 &&strcmp(ln(1:2),"%!")) body
 if (length(ln) > 2) body
endif endif endwhile fclose (fid)
endif endfunction!testif
OCTAVE_SOURCE 
!assert (true)
!testif HAVE_FOOBAR !error ("Failed missing feature test")
!xtest error ("This test is known to fail")%!shared msg%!msg
 !fail ('toeplitz([])', msg)
 !fail ('toeplitz([1, 2],[])', msg)
 !fail ('toeplitz([1, 2;3, 4])', msg)
 !fail ('toeplitz([1, 2],[1, 2;3, 4])', msg)
 !fail ('toeplitz([1, 2;3, 4],[1, 2])', msg)
 !fail ('toeplitz','usage:toeplitz')
 !fail ('toeplitz(1, 2, 3)', 'usage:toeplitz')
!test assert (toeplitz([1, 2, 3],[1, 4]),[1, 4;2, 1;3, 2])
!demo toeplitz ([1, 2, 3, 4],[1, 5, 6])%!%!%!test assert(isempty(kron([]
!demo rand (3, 4))))%!test assert(isempty(kron(rand(3
!demo!test assert (isempty(kron([],[])))%!shared A
 !assert (size(kron(zeros(3, 0), A)),[3 *rows(A), 0])%!assert(size(kron(zeros(0
 !assert (size(kron(A, zeros(3, 0))),[3 *rows(A), 0])%!assert(size(kron(A
 zeros (0, 3)))
 !assert (kron(pi, e), pi *e)%!assert(kron(pi
pi *A !assert (kron(A, e), e *A)%!assert(kron([1
pi *A !assert (kron([1;2;3], A),[A;2 *A;3 *A])%!assert(kron([1
 !assert (kron(A, B), res)%!%!%![x
 !imagesc (flipud(20 *log10(S)), 1)
you should now see a
spectrogram in the image
window 
!fail ('test','usage.*test')%!fail('test(1
you should now see a
spectrogram in the image
window usage *test 
!fail ('test("test","bogus")','unknown flag')%!fail('garbage'
you should now see a
spectrogram in the image
window usage *test garbage
*undefined!error test!error 
test (1, 2, 3, 4)%!error< unknown flag > test("test"
!error< garbage'undefined >
garbage!error 
test ("test", 'bogus')
!test !lastwarn ()
!warning< warning message > warning ('warning message')
!test assert (a, 3)%!shared b
!test c!test assert (!exist("a"))
!test assert (isempty(b))
!shared c!test assert (isempty(a))
!test assert ([a, b, c],[1, 2, 3])
 !assert (__test_a(2), 4)
!function __test_a (y)%!x
!test !__test_a (2)
 !assert (x, 6)
 !assert (z, 9)
 !assert (isempty([]))%!%!demo%!t
 !plot (t, x)
!error< wrong patternerror ("message")%!demo with syntax error%!shared a
!error< wrong pattern > c!demo !assert (exist("a"))%!error%!test('/etc/passwd')
 !test ("nonexistent file")

Variables

 function [__ret1, __ret2, __ret3, __ret4]
persistent __signal_empty = "????? "
persistent __signal_block = " ***** "
persistent __signal_file = ">>>>> "
persistent __signal_skip = "----- "
 __xfail = 0
 __xskip = 0
endif __batch = (! isempty (__fid))
 __close_fid = 0
else __fid = stdout
 __rundemo = 0
 __verbose = __batch
 __demo_code = ""
 __demo_idx = 1
endif return
endif __file = file_in_loadpath (__name, "all")
 __ret2 = []
endif __body = __extract_test_code (__file)
endif endif __lineidx = find (__body == "\n")
 __blockidx = __lineidx(find (! isspace (__body(__lineidx+1))))+1
endif __all_success = 1
 __tests = __successes = 0
 __shared = " "
 __shared_r = " "
 __clear = ""
for __i
s s n
s s __block
endif __idx = find (! isletter (__block))
 __code = ""
else __type = __block(1:__idx(1)-1)
endif __success = 1
 __msg = []
 __isdemo = strcmp (__type, "demo")
 __test__
 __istest = 0
endfor endfunction function pos
 right = find (def == "(", 1)
 left
 rest = str
 str = trimleft (str)
endif endif endfunction function msg
 leading = find (idx == 1:length(idx))
endif endfunction function s
endfor endfunction function body
!demo!test B!test !A = [1, 2, 3
 !B = [1, -1
 A
pi *A!test !res = [1,-1,2,-2,3,-3
 Fs = auload(file_in_loadpath("sample.wav"))
 !step = fix(5*Fs/1000)
 !window = fix(40*Fs/1000)
 !fftn = 2^nextpow2(window)
 !S = specgram(x, fftn, Fs, window, window-step) abs(S(2:fftn*4000/Fs,:))
you should now see a
spectrogram in the image
window usage *test garbage
*undefined!error test!error 
bogus
!shared a!test a = 3
!shared b = 2
 c = 3
!shared!test c !a = 1
!function x
 !function [x, z]
 !z = 3*y
 !test [x, z] = __test_a(3)

Function Documentation

!test !__test_a (  ) 

!error<wrong pattern> c !demo !assert ( exist("a")   ) 

Type Constraints

!assert ( isempty([])   ) 

!assert ( ,
 
)

!assert ( ,
 
)

!assert ( __test_a(2)  ,
 
)

!assert ( kron(A, B ,
res   
)

pi* A !assert ( kron([1;2;3], A)   ) 

Type Constraints

pi* A !assert ( kron(A, e ,
e A 
)

Type Constraints

!assert ( kron(pi, e ,
pi e 
)

!assert ( size(kron(A, zeros(3, 0)))   ) 

Type Constraints

!assert ( size(kron(zeros(3, 0), A))   ) 

endif endfunction !testif OCTAVE_SOURCE !assert ( true   ) 

!testif HAVE_FOOBAR !error ( "Failed missing feature test"   ) 

you should now see a spectrogram in the image window usage* test !fail ( 'test("test","bogus")'  ,
'unknown flag  
)

you should now see a spectrogram in the image window !fail ( 'test'  ,
'usage.*test'   
)

!fail ( 'toeplitz(1, 2, 3)'  ,
'usage:toeplitz'   
)

!fail ( 'toeplitz'  ,
'usage:toeplitz'   
)

!fail ( 'toeplitz([1, 2;3, 4],[1, 2])'  ,
msg   
)

!fail ( 'toeplitz([1, 2],[1, 2;3, 4])'  ,
msg   
)

!fail ( 'toeplitz([1, 2;3, 4])'  ,
msg   
)

!fail ( 'toeplitz([1, 2],[])'  ,
msg   
)

!fail ( 'toeplitz([])'  ,
msg   
)

!imagesc ( flipud(20 *log10(S))  ,
 
)

!test !lastwarn (  ) 

!plot ( ,
 
)

!test ( "nonexistent file  ) 

!function __test_a (  ) 

assert (  ) 

!shared c !test assert ( isempty(a)   ) 

Type Constraints

!test assert ( isempty(b)   ) 

shared test assert ( exist"a"  ) 

!test assert ( ,
 
)

!demo !test assert ( isempty(kron([],[]))   ) 

!test assert ( toeplitz([1, 2, 3],[1, 4])   ) 

elseif ( strcmp(__block(1:1),"#")   )  [pure virtual]

endif elseif ( strcmp(__type,"test")||strcmp(__type,"xtest")   ) 

endif elseif ( __rundemo &&  __isdemo  ) 

elseif ( strcmp(__flag,"explain")   ) 

elseif ( strcmp(__flag,"grabdemo")   ) 

elseif ( strcmp(__flag,"verbose")   )  [pure virtual]

elseif ( strcmp(__flag,"quiet")   )  [pure virtual]

!error<wrong pattern> error ( "message"    ) 

!xtest error ( "This test is known to fail"   ) 

else error ( "test unknown flag '%s'"  ,
__flag   
)

eval ( sprintf("%s__test__(%s);", __shared_r, __shared  ) 

endif endif endwhile fclose ( fid   ) 

fflush ( __fid   ) 

else fprintf ( __fid  ,
"%s%s has no tests available\n"  ,
__signal_empty  ,
__file   
)

else fprintf ( __fid  ,
"%s%s does not exist in path\n"  ,
__signal_empty  ,
__name   
)

fprintf ( __fid  ,
"# success (in which case no error will be reported).\n"   
)

fprintf ( __fid  ,
"# case an error will be   reported 
)

fprintf ( __fid   ) 

fprintf ( __fid  ,
"# then page back to find the file name which caused it.\n"   
)

fprintf ( __fid  ,
"# Search for the unexpected results in the file\n"   
)

fprintf ( __fid  ,
"# %s code for the test\n"  ,
__signal_block   
)

fprintf ( __fid  ,
"# %s test had an unexpected result\n"  ,
__signal_fail   
)

fprintf ( __fid  ,
"# %s no tests in file\n"  ,
__signal_empty   
)

endif fprintf ( __fid  ,
"%sprocessing %s\n"  ,
__signal_file  ,
__name   
)

if ( length(ln)  ,
 
)

if ( length(ln) >=2 &&strcmp(ln(1:2),"%!")   ) 

if ( fid >=  0  ) 

if ( isemptyleading  ) 

if ( close   ) 

if ( isemptystr)&&str(1 = ="<"  ) 

if ( isempty(left  ) 

if ( isempty(right  ) 

endif if ( isempty__code  ) 

if ( __grabdemo &&  __isdemo  ) 

if ( __grabdemo||  __isdemo  )  [pure virtual]

if ( isempty(__idx  ) 

if ( __verbose   ) 

else if ( __body(length(__body))  = ="\n"  ) 

if ( isempty(__body  ) 

if ( nargout  ,
 
)

endif if ( iscell(__file  ) 

if ( isempty(__file  ) 

if ( __close_fid   ) 

endif if ( strcmp(__flag,"normal")   )  [pure virtual]

if ( __batch   ) 

endif if ( isempty(__name)&&(nargin!=3||!strcmp(__flag,"explain"))   ) 

endif if ( nargin< 1||nargin > 3||  !ischar(__name)&&!isempty(__name))||!ischar(__flag  ) 

if (  ) 

input ( "Press <enter> to continue: "  ,
"s"   
)

!demo rand ( ,
 
)

!error<garbage' undefined> garbage !error test ( "test"  ,
'bogus  
)

you should now see a spectrogram in the image window usage* test garbage* undefined !error test !error test ( ,
,
,
 
)

bogus error toeplitz (  ) 

!warning<warning message> warning ( 'warning message'   ) 

zeros ( ,
 
)


Variable Documentation

!shared !test c !a = 1

!demo !test B !test !A = [1, 2, 3

!B = [1, -1

!fftn = 2^nextpow2(window)

!function[x, z]

Initial value:

 __test_a (y)
%! x = 2*y

pi* A !test !res = [1,-1,2,-2,3,-3

!S = specgram(x, fftn, Fs, window, window-step) abs(S(2:fftn*4000/Fs,:))

!step = fix(5*Fs/1000)

!test[x, z] = __test_a(3)

!window = fix(40*Fs/1000)

!z = 3*y

endif __batch = (! isempty (__fid))

s s __block

__blockidx = __lineidx(find (! isspace (__body(__lineidx+1))))+1

else __body = __extract_test_code (__file)

__clear = ""

endif __code = ""

else __fid = stdout

else __file = file_in_loadpath (__name, "all")

endif __idx = find (! isletter (__block))

__isdemo = strcmp (__type, "demo")

endif endif __lineidx = find (__body == "\n")

__msg = []

__ret2 = []

__rundemo = 0

endif __shared = " "

s s __signal_block = " ***** "

persistent __signal_empty = "????? "

persistent __signal_file = ">>>>> "

persistent __signal_skip = "----- "

__success = 1

__tests = __successes = 0

else __type = __block(1:__idx(1)-1)

__xfail = 0

__xskip = 0

you should now see a sine wave in your figure window !demo a = 3

pi* A A

!error<wrong pattern> b = 2

Initial value:

 __extract_test_code (nm)
  fid = fopen (nm, "rt")

you should now see a spectrogram in the image window usage* test garbage* undefined !error test !error bogus

c = 3

Fs = auload(file_in_loadpath("sample.wav"))

Initial value:

 test (__name, __flag, __fid)

  persistent __signal_fail =  "!!!!! "

leading = find (idx == 1:length(idx))

Initial value:

 max ([find(def(1:right)==" ", 1, "last"), ...
               find(def(1:right)=="=", 1, "last")])

if (idx > 0) msg(1 endif msg

Initial value:

 trimerr (msg, prefix)
  idx = index (msg, cstrcat (prefix, ":"))

s s n

pos

Initial value:

 function_name (def)
  pos = []

rest = str

endif return

endif right = find (def == "(", 1)

Initial value:

 bundle (varargin)
  for i = 1:nargin
    s.(deblank (argn(i,:))) = varargin{i}

endfunction function str = trimleft (str)

x

Initial value:

 __test_a(y)
%! x = 2*y