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 pattern > | error ("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) |
!test !__test_a | ( | 2 | ) |
!error<wrong pattern> c !demo !assert | ( | exist("a") | ) |
!assert | ( | isempty([]) | ) |
!assert | ( | z | , | |
9 | ||||
) |
!assert | ( | x | , | |
6 | ||||
) |
!assert | ( | __test_a(2) | , | |
4 | ||||
) |
pi* A !assert | ( | kron([1;2;3], A) | ) |
!assert | ( | size(kron(A, zeros(3, 0))) | ) |
!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' | ||||
) |
!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)) | , | |
1 | ||||
) |
!test !lastwarn | ( | ) |
!plot | ( | t | , | |
x | ||||
) |
!test | ( | "nonexistent file" | ) |
!function __test_a | ( | y | ) |
assert | ( | ) |
!shared c !test assert | ( | isempty(a) | ) |
!test assert | ( | isempty(b) | ) |
shared test assert | ( | ! | exist"a" | ) |
!test assert | ( | a | , | |
3 | ||||
) |
!demo !test assert | ( | isempty(kron([],[])) | ) |
!test assert | ( | toeplitz([1, 2, 3],[1, 4]) | ) |
elseif | ( | strcmp(__block(1:1),"#") | ) | [pure virtual] |
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" | ) |
eval | ( | sprintf("%s__test__(%s);", __shared_r, __shared) | ) |
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 | , | |
"# case an error will be | reported | |||
) |
fprintf | ( | __fid | ) |
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) | , | |
2 | ||||
) |
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 | ) |
if | ( | isempty(__body) | ) |
if | ( | nargout | , | |
0 | ||||
) |
if | ( | isempty(__file) | ) |
if | ( | __close_fid | ) |
endif if | ( | strcmp(__flag,"normal") | ) | [pure virtual] |
if | ( | __batch | ) |
endif if | ( | isempty(__name)&&(nargin!=3||!strcmp(__flag,"explain")) | ) |
if | ( | ) |
input | ( | "Press <enter> to continue: " | , | |
"s" | ||||
) |
!demo rand | ( | 3 | , | |
4 | ||||
) |
!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 | ( | 1 | , | |
2 | , | |||
3 | , | |||
4 | ||||
) |
bogus error toeplitz | ( | ) |
!warning<warning message> warning | ( | 'warning message' | ) |
zeros | ( | 0 | , | |
3 | ||||
) |
!shared !test c !a = 1 |
!demo !test B !test !A = [1, 2, 3 |
!B = [1, -1 |
!fftn = 2^nextpow2(window) |
!test[x, z] = __test_a(3) |
!window = fix(40*Fs/1000) |
!z = 3*y |
endif __all_success = 1 |
s s __block |
__blockidx = __lineidx(find (! isspace (__body(__lineidx+1))))+1 |
__clear = "" |
endif __close_fid = 0 |
else __demo_code = "" |
__demo_idx = 1 |
Initial value:
1:length(__blockidx)-1 __block = __body(__blockidx(__i):__blockidx(__i+1)-2)
__msg = [] |
__ret2 = [] |
__rundemo = 0 |
endif __shared_r = " " |
s s __signal_block = " ***** " |
persistent __signal_empty = "????? " |
persistent __signal_file = ">>>>> " |
persistent __signal_skip = "----- " |
__success = 1 |
__tests = __successes = 0 |
__xfail = 0 |
__xskip = 0 |
pi* A A |
!error<wrong pattern> b = 2 |
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")) |
leading = find (idx == 1:length(idx)) |
s s n |
pos |
Initial value:
function_name (def) pos = []
rest = str |
endif return |
endfunction function str = trimleft (str) |