Mercurial > hg > octave-lojdl
changeset 2742:eeb061f9cdbf
[project @ 1997-02-26 04:29:07 by jwe]
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/diag-1.m @@ -0,0 +1,31 @@ +d = [1; 2; 3]; + +d0 = [1, 0, 0; + 0, 2, 0; + 0, 0, 3]; + +d1 = [0, 1, 0, 0; + 0, 0, 2, 0; + 0, 0, 0, 3; + 0, 0, 0, 0]; + +d2 = [0, 0, 1, 0, 0; + 0, 0, 0, 2, 0; + 0, 0, 0, 0, 3; + 0, 0, 0, 0, 0; + 0, 0, 0, 0, 0]; + +dm1 = [0, 0, 0, 0; + 1, 0, 0, 0; + 0, 2, 0, 0; + 0, 0, 3, 0]; + +dm2 = [0, 0, 0, 0, 0; + 0, 0, 0, 0, 0; + 1, 0, 0, 0, 0; + 0, 2, 0, 0, 0; + 0, 0, 3, 0, 0]; + +(diag (d) == d0 && diag (d, 1) == d1 && diag (d, 2) == d2 + && diag (d, -1) == dm1 && diag (d, -2) == dm2 + && diag (d0) == d && diag (d1, 1) == d && diag (dm1, -1) == d)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/diag-3.m @@ -0,0 +1,1 @@ +diag (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/diff-1.m @@ -0,0 +1,5 @@ +(diff ([1, 2, 3, 4]) == [1, 1, 1] + && diff ([1, 3, 7, 19], 2) == [2, 8] + && diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1]) == [4, 2; 3, 3; 1, -1; -6, -5] + && diff ([1, 2; 5, 4; 8, 7; 9, 6; 3, 1], 3) == [-1, -5; -5, 0] + && isempty (diff (1)))
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/diff-2.m @@ -0,0 +1,1 @@ +diff ([1, 2; 3, 4], -1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/diff-3.m @@ -0,0 +1,1 @@ +diff ("foo")
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/diff-5.m @@ -0,0 +1,1 @@ +diff (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/find-1.m @@ -0,0 +1,3 @@ +(find ([1, 0, 1, 0, 1]) == [1, 3, 5] + && find ([1; 0; 3; 0; 1]) == [1; 3; 5] + && find ([0, 0, 2; 0, 3, 0; -1, 0, 0]) == [3; 5; 7])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/find-2.m @@ -0,0 +1,3 @@ +[i, j, v] = find ([0, 0, 2; 0, 3, 0; -1, 0, 0]); + +i == [3; 2; 1] && j == [1; 2; 3] && v == [-1; 3; 2]
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/find-4.m @@ -0,0 +1,1 @@ +find (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hadamard-1.m @@ -0,0 +1,2 @@ +(hadamard (1) == [1, 1; 1, -1] + && hadamard (2) == [1, 1, 1, 1; 1, -1, 1, -1; 1, 1, -1, -1; 1, -1, -1, 1])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hadamard-2.m @@ -0,0 +1,1 @@ +hadamard ([1, 2; 3, 4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hadamard-3.m @@ -0,0 +1,1 @@ +hadamard ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hadamard-4.m @@ -0,0 +1,1 @@ +hadamard (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hankel-1.m @@ -0,0 +1,2 @@ +(hankel (1) == 1 && hankel ([1, 2]) == [1, 2; 2, 0] + && hankel ([1, 2], [2; -1; -3]) == [1, 2, -1; 2, -1, -3])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hankel-2.m @@ -0,0 +1,1 @@ +hankel ([1, 2; 3, 4], [1, 2; 3, 4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hankel-3.m @@ -0,0 +1,1 @@ +hankel ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/hankel-4.m @@ -0,0 +1,1 @@ +hankel (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/invhilb-1.m @@ -0,0 +1,8 @@ +result4 = [16, -120, 240, -140; + -120, 1200, -2700, 1680; + 240, -2700, 6480, -4200; + -140, 1680, -4200, 2800]; + +(invhilb (1) == 1 && invhilb (2) == [4, -6; -6, 12] + && invhilb (4) == result4 + && abs (invhilb (7) * hilb (7) - eye (7)) < sqrt (eps))
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/invhilb-2.m @@ -0,0 +1,1 @@ +invhilb ([1, 2])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/invhilb-3.m @@ -0,0 +1,1 @@ +invhilb ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/invhilb-4.m @@ -0,0 +1,1 @@ +invhilb (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/linspace-1.m @@ -0,0 +1,6 @@ +x1 = linspace (1, 2); +x2 = linspace (1, 2, 10); +x3 = linspace (1, -2, 10); +(size (x1) == [1, 100] && x1(1) == 1 && x1(100) == 2 + && size (x2) == [1, 10] && x2(1) == 1 && x2(10) == 2 + && size (x3) == [1, 10] && x3(1) == 1 && x3(10) == -2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/linspace-2.m @@ -0,0 +1,1 @@ +linspace ([1, 2; 3, 4], 5, 6)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/linspace-3.m @@ -0,0 +1,1 @@ +linspace ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/linspace-4.m @@ -0,0 +1,1 @@ +linspace (1, 2, 3, 4)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/logspace-1.m @@ -0,0 +1,8 @@ +x1 = logspace (1, 2); +x2 = logspace (1, 2, 10); +x3 = logspace (1, -2, 10); +x4 = logspace (1, pi, 10); +(size (x1) == [1, 50] && x1(1) == 10 && x1(50) == 100 + && size (x2) == [1, 10] && x2(1) == 10 && x2(10) == 100 + && size (x3) == [1, 10] && x3(1) == 10 && x3(10) == 0.01 + && size (x4) == [1, 10] && x4(1) == 10 && x4(10) == pi)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/logspace-2.m @@ -0,0 +1,1 @@ +logspace ([1, 2; 3, 4], 5, 6)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/logspace-3.m @@ -0,0 +1,1 @@ +logspace ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/logspace-4.m @@ -0,0 +1,1 @@ +logspace (1, 2, 3, 4)
--- a/test/octave.test/matrix/matrix.exp +++ b/test/octave.test/matrix/matrix.exp @@ -22,8 +22,41 @@ set prog_output "\n... any:.*" do_test any-3.m -# diff -# find +set test diff-1 +set prog_output "ans = 1" +do_test diff-1.m + +set test diff-2 +set prog_output "error:.*" +do_test diff-2.m + +set test diff-3 +set prog_output "error:.*" +do_test diff-3.m + +set test diff-4 +set prog_output "usage:.*" +do_test diff-4.m + +set test diff-5 +set prog_output "usage:.*" +do_test diff-5.m + +set test find-1 +set prog_output "ans = 1" +do_test find-1.m + +set test find-2 +set prog_output "ans = 1" +do_test find-2.m + +set test find-3 +set prog_output "\n... find:.*" +do_test find-3.m + +set test find-4 +set prog_output "\n... find:.*" +do_test find-4.m set test fliplr-1 set prog_output "ans = 1" @@ -61,13 +94,93 @@ set prog_output "usage:.*" do_test rot90-3.m -# reshape -# shift -# sort -# tril -# triu -# vec -# vech +set test reshape-1 +set prog_output "ans = 1" +do_test reshape-1.m + +set test reshape-2 +set prog_output "error:.*" +do_test reshape-2.m + +set test reshape-3 +set prog_output "usage:.*" +do_test reshape-3.m + +set test reshape-4 +set prog_output "usage:.*" +do_test reshape-4.m + +set test shift-1 +set prog_output "ans = 1" +do_test shift-1.m + +set test shift-2 +set prog_output "usage:.*" +do_test shift-2.m + +set test shift-3 +set prog_output "usage:.*" +do_test shift-3.m + +set test sort-1 +set prog_output "ans = 1" +do_test sort-1.m + +set test sort-2 +set prog_output "\n... sort:.*" +do_test sort-2.m + +set test sort-3 +set prog_output "\n... sort:.*" +do_test sort-3.m + +set test tril-1 +set prog_output "ans = 1" +do_test tril-1.m + +set test tril-2 +set prog_output "usage:.*" +do_test tril-2.m + +set test tril-3 +set prog_output "usage:.*" +do_test tril-3.m + +set test triu-1 +set prog_output "ans = 1" +do_test triu-1.m + +set test triu-2 +set prog_output "usage:.*" +do_test triu-2.m + +set test triu-3 +set prog_output "usage:.*" +do_test triu-3.m + +set test vec-1 +set prog_output "ans = 1" +do_test vec-1.m + +set test vec-2 +set prog_output "usage:.*" +do_test vec-2.m + +set test vec-3 +set prog_output "usage:.*" +do_test vec-3.m + +set test vech-1 +set prog_output "ans = 1" +do_test vech-1.m + +set test vech-2 +set prog_output "usage:.*" +do_test vech-2.m + +set test vech-3 +set prog_output "usage:.*" +do_test vech-3.m set test eye-1 set prog_output "ans = 1" @@ -93,13 +206,97 @@ set prog_output "\n... zeros:.*" do_test zeros-2.m -# rand -# randn -# diag -# linspace -# logspace -# hadamard -# hankel +set test rand-1 +set prog_output "ans = 1" +do_test rand-1.m + +set test rand-2 +set prog_output "\n... rand:.*" +do_test rand-2.m + +set test randn-1 +set prog_output "ans = 1" +do_test randn-1.m + +set test randn-2 +set prog_output "\n... randn:.*" +do_test randn-2.m + +set test diag-1 +set prog_output "ans = 1" +do_test diag-1.m + +set test diag-2 +set prog_output "\n... diag:.*" +do_test diag-2.m + +set test diag-3 +set prog_output "\n... diag:.*" +do_test diag-3.m + +set test linspace-1 +set prog_output "ans = 1" +do_test linspace-1.m + +set test linspace-2 +set prog_output "error:.*" +do_test linspace-2.m + +set test linspace-3 +set prog_output "\n... linspace:.*" +do_test linspace-3.m + +set test linspace-4 +set prog_output "\n... linspace:.*" +do_test linspace-4.m + +set test logspace-1 +set prog_output "ans = 1" +do_test logspace-1.m + +set test logspace-2 +set prog_output "error:.*" +do_test logspace-2.m + +set test logspace-3 +set prog_output "usage:.*" +do_test logspace-3.m + +set test logspace-4 +set prog_output "usage:.*" +do_test logspace-4.m + +set test hadamard-1 +set prog_output "ans = 1" +do_test hadamard-1.m + +set test hadamard-2 +set prog_output "error:.*" +do_test hadamard-2.m + +set test hadamard-3 +set prog_output "usage:.*" +do_test hadamard-3.m + +set test hadamard-4 +set prog_output "usage:.*" +do_test hadamard-4.m + +set test hankel-1 +set prog_output "ans = 1" +do_test hankel-1.m + +set test hankel-2 +set prog_output "error:.*" +do_test hankel-2.m + +set test hankel-3 +set prog_output "usage:.*" +do_test hankel-3.m + +set test hankel-4 +set prog_output "usage:.*" +do_test hankel-4.m set test hilb-1 set prog_output "ans = 1" @@ -113,6 +310,50 @@ set prog_output "usage:.*" do_test hilb-3.m -# invhilb -# toeplitz -# vander +set test invhilb-1 +set prog_output "ans = 1" +do_test invhilb-1.m + +set test invhilb-2 +set prog_output "error:.*" +do_test invhilb-2.m + +set test invhilb-3 +set prog_output "usage:.*" +do_test invhilb-3.m + +set test invhilb-4 +set prog_output "usage:.*" +do_test invhilb-4.m + +set test toeplitz-1 +set prog_output "ans = 1" +do_test toeplitz-1.m + +set test toeplitz-2 +set prog_output "error:.*" +do_test toeplitz-2.m + +set test toeplitz-3 +set prog_output "usage:.*" +do_test toeplitz-3.m + +set test toeplitz-4 +set prog_output "usage:.*" +do_test toeplitz-4.m + +set test vander-1 +set prog_output "ans = 1" +do_test vander-1.m + +set test vander-2 +set prog_output "error:.*" +do_test vander-2.m + +set test vander-3 +set prog_output "usage:.*" +do_test vander-3.m + +set test vander-4 +set prog_output "usage:.*" +do_test vander-4.m
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/rand-1.m @@ -0,0 +1,5 @@ +rand ("seed", 0.5); +r1 = rand (100); +rand ("seed", 0.5); +r2 = rand (100); +rand (100) < 1 && rand (100) > 0 && r1 == r2
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/rand-2.m @@ -0,0 +1,1 @@ +rand (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/randn-1.m @@ -0,0 +1,5 @@ +randn ("seed", 0.5); +r1 = randn (100); +randn ("seed", 0.5); +r2 = randn (100); +all (all (r1 == r2))
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/randn-2.m @@ -0,0 +1,1 @@ +randn (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/reshape-1.m @@ -0,0 +1,4 @@ +(size (reshape (rand (4, 4), 2, 8)) == [2, 8] + && size (reshape (rand (4, 4), 8, 2)) == [8, 2] + && size (reshape (rand (15, 4), 1, 60)) == [1, 60] + && size (reshape (rand (15, 4), 60, 1)) == [60, 1])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/reshape-2.m @@ -0,0 +1,2 @@ +s.a = 1; +reshape (s, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/reshape-3.m @@ -0,0 +1,1 @@ +reshape ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/reshape-4.m @@ -0,0 +1,1 @@ +reshape (1, 2, 3, 4)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/shift-1.m @@ -0,0 +1,12 @@ +a = [1, 2, 3]; +b = [4, 5, 6]; +c = [7, 8, 9]; + +r = [a, b, c]; +m = [a; b; c]; + +(shift (r, 3) == [c, a, b] + && shift (r, -6) == [c, a, b] + && shift (r, -3) == [b, c, a] + && shift (m, 1) == [c; a; b] + && shift (m, -2) == [c; a; b])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/shift-2.m @@ -0,0 +1,1 @@ +shift ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/shift-3.m @@ -0,0 +1,1 @@ +shift (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/sort-1.m @@ -0,0 +1,5 @@ +a = [1, 2; 2, 3; 3, 1]; +s = [1, 1; 2, 2; 3, 3]; +i = [1, 3; 2, 1; 3, 2]; +[xs, xi] = sort (a); +sort (a) == s && xs == s && xi == i
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/sort-3.m @@ -0,0 +1,1 @@ +sort (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/toeplitz-1.m @@ -0,0 +1,3 @@ +(toeplitz (1) == 1 + && toeplitz ([1, 2, 3], [1; -3; -5]) == [1, -3, -5; 2, 1, -3; 3, 2, 1] + && toeplitz ([1, 2, 3], [1; -3i; -5i]) == [1, -3i, -5i; 2, 1, -3i; 3, 2, 1])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/toeplitz-2.m @@ -0,0 +1,1 @@ +toeplitz ([1, 2; 3, 4], 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/toeplitz-3.m @@ -0,0 +1,1 @@ +toeplitz ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/toeplitz-4.m @@ -0,0 +1,1 @@ +toeplitz (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/tril-1.m @@ -0,0 +1,13 @@ +a = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; + +l0 = [1, 0, 0; 4, 5, 0; 7, 8, 9; 10, 11, 12]; +l1 = [1, 2, 0; 4, 5, 6; 7, 8, 9; 10, 11, 12]; +l2 = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; +lm1 = [0, 0, 0; 4, 0, 0; 7, 8, 0; 10, 11, 12]; +lm2 = [0, 0, 0; 0, 0, 0; 7, 0, 0; 10, 11, 0]; +lm3 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 10, 0, 0]; +lm4 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 0, 0, 0]; + +(tril (a, -4) == lm4 && tril (a, -3) == lm3 + && tril (a, -2) == lm2 && tril (a, -1) == lm1 + && tril (a) == l0 && tril (a, 1) == l1 && tril (a, 2) == l2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/tril-3.m @@ -0,0 +1,1 @@ +tril (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/triu-1.m @@ -0,0 +1,13 @@ +a = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; + +u0 = [1, 2, 3; 0, 5, 6; 0, 0, 9; 0, 0, 0]; +u1 = [0, 2, 3; 0, 0, 6; 0, 0, 0; 0, 0, 0]; +u2 = [0, 0, 3; 0, 0, 0; 0, 0, 0; 0, 0, 0]; +u3 = [0, 0, 0; 0, 0, 0; 0, 0, 0; 0, 0, 0]; +um1 = [1, 2, 3; 4, 5, 6; 0, 8, 9; 0, 0, 12]; +um2 = [1, 2, 3; 4, 5, 6; 7, 8, 9; 0, 11, 12]; +um3 = [1, 2, 3; 4, 5, 6; 7, 8, 9; 10, 11, 12]; + +(triu (a, -3) == um3 && triu (a, -2) == um2 + && triu (a, -1) == um1 && triu (a) == u0 && triu (a, 1) == u1 + && triu (a, 2) == u2 && triu (a, 3) == u3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/triu-3.m @@ -0,0 +1,1 @@ +triu (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vander-1.m @@ -0,0 +1,3 @@ +(vander (1) == 1 && vander ([1, 2, 3]) == vander ([1; 2; 3]) + && vander ([1, 2, 3]) == [1, 1, 1; 4, 2, 1; 9, 3, 1] + && vander ([1, 2, 3]*i) == [-1, i, 1; -4, 2i, 1; -9, 3i, 1])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vander-2.m @@ -0,0 +1,1 @@ +vander ([1, 2; 3, 4])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vander-3.m @@ -0,0 +1,1 @@ +vander ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vander-4.m @@ -0,0 +1,1 @@ +vander (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vec-1.m @@ -0,0 +1,1 @@ +vec ([1, 2; 3, 4]) == [1; 3; 2; 4] && vec ([1, 3, 2, 4]) == [1; 3; 2; 4]
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vec-3.m @@ -0,0 +1,1 @@ +vec (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vech-1.m @@ -0,0 +1,1 @@ +all (vech ([1, 2, 3; 4, 5, 6; 7, 8, 9]) == [1; 4; 7; 5; 8; 9])
new file mode 100644 --- /dev/null +++ b/test/octave.test/matrix/vech-3.m @@ -0,0 +1,1 @@ +vech (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/asctime-1.m @@ -0,0 +1,2 @@ +t = time (); +strcmp (asctime (localtime (t)), ctime (t))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/asctime-2.m @@ -0,0 +1,1 @@ +asctime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/asctime-3.m @@ -0,0 +1,1 @@ +asctime (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/clock-1.m @@ -0,0 +1,3 @@ +t1 = clock; +t2 = str2num (strftime ("[%Y, %m, %e, %k, %M, %S]", localtime (time ()))); +etime (t1, t2) < 1
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/cputime-1.m @@ -0,0 +1,6 @@ +[t1, u1, s1] = cputime (); +for i = 1:200 + sin (i); +endfor +[t2, u2, s2] = cputime (); +t1 == u1 + s1 && t2 == u2 + s2 && t2 >= t1 && u2 >= u2 && s2 >= s2
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/ctime-1.m @@ -0,0 +1,2 @@ +t = time (); +strcmp (asctime (localtime (t)), ctime (t))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/ctime-2.m @@ -0,0 +1,1 @@ +ctime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/ctime-3.m @@ -0,0 +1,1 @@ +ctime (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/date-1.m @@ -0,0 +1,1 @@ +strcmp (date (), strftime ("%e-%b-%y", localtime (time ())))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/etime-1.m @@ -0,0 +1,8 @@ +t1 = [1993, 8, 20, 4, 56, 1]; +t2 = [1993, 8, 21, 4, 56, 1]; +t3 = [1993, 8, 20, 5, 56, 1]; +t4 = [1993, 8, 20, 4, 57, 1]; +t5 = [1993, 8, 20, 4, 56, 14]; + +(etime (t2, t1) == 86400 && etime (t3, t1) == 3600 + && etime (t4, t1) == 60 && etime (t5, t1) == 13)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/etime-2.m @@ -0,0 +1,1 @@ +etime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/etime-3.m @@ -0,0 +1,1 @@ +etime (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/file_in_path-1.m @@ -0,0 +1,1 @@ +isstr (file_in_path (LOADPATH, "date.m"))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/file_in_path-2.m @@ -0,0 +1,1 @@ +file_in_path ("foo", "bar", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/file_in_path-3.m @@ -0,0 +1,1 @@ +file_in_path ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/file_in_path-4.m @@ -0,0 +1,1 @@ +file_in_path ("foo", "bar", "baz")
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/fnmatch-1.m @@ -0,0 +1,6 @@ +string_fill_char = setstr (0); +(fnmatch ("a*a", ["aba"; "xxxba"; "aa"]) == [1; 0; 1] + && fnmatch (["a*a"; "b*b"], "bob") + && fnmatch ("x[0-5]*", ["x1"; "x6"]) == [1; 0] + && fnmatch ("x[0-5]*", ["x1"; "x6"; "x001"]) == [1; 0; 1] + && fnmatch ("x???y", ["xabcy"; "xy"]) == [1; 0])
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/fnmatch-2.m @@ -0,0 +1,1 @@ +fnmatch ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/fnmatch-3.m @@ -0,0 +1,1 @@ +fnmatch ("foo", "bar", 3) \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/glob-1.m @@ -0,0 +1,1 @@ +isstr (glob ("/*"))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/glob-3.m @@ -0,0 +1,1 @@ +glob ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/gmtime-1.m @@ -0,0 +1,13 @@ +ts = gmtime (time ()); +(is_struct (ts) + && struct_contains (ts, "usec") + && struct_contains (ts, "year") + && struct_contains (ts, "mon") + && struct_contains (ts, "mday") + && struct_contains (ts, "sec") + && struct_contains (ts, "zone") + && struct_contains (ts, "min") + && struct_contains (ts, "wday") + && struct_contains (ts, "hour") + && struct_contains (ts, "isdst") + && struct_contains (ts, "yday"))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/gmtime-2.m @@ -0,0 +1,1 @@ +gmtime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/gmtime-3.m @@ -0,0 +1,1 @@ +gmtime (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/is_leap_year-1.m @@ -0,0 +1,3 @@ +(is_leap_year (2000) == 1 && is_leap_year (1976) == 1 + && is_leap_year (1000) == 0 && is_leap_year (1800) == 0 + && is_leap_year (1600) == 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/is_leap_year-2.m @@ -0,0 +1,1 @@ +is_leap_year (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/localtime-1.m @@ -0,0 +1,13 @@ +ts = localtime (time ()) +(is_struct (ts) + && struct_contains (ts, "usec") + && struct_contains (ts, "year") + && struct_contains (ts, "mon") + && struct_contains (ts, "mday") + && struct_contains (ts, "sec") + && struct_contains (ts, "zone") + && struct_contains (ts, "min") + && struct_contains (ts, "wday") + && struct_contains (ts, "hour") + && struct_contains (ts, "isdst") + && struct_contains (ts, "yday"))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/localtime-2.m @@ -0,0 +1,1 @@ +localtime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/localtime-3.m @@ -0,0 +1,1 @@ +localtime (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/lstat-1.m @@ -0,0 +1,14 @@ +[s, err, msg] = lstat ("/"); +(err == 0 + && is_struct (s) + && struct_contains (s, "dev") + && struct_contains (s, "ino") + && struct_contains (s, "modestr") + && struct_contains (s, "nlink") + && struct_contains (s, "uid") + && struct_contains (s, "gid") + && struct_contains (s, "size") + && struct_contains (s, "atime") + && struct_contains (s, "mtime") + && struct_contains (s, "ctime") + && isstr (msg))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/lstat-2.m @@ -0,0 +1,1 @@ +lstat ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/lstat-3.m @@ -0,0 +1,1 @@ +lstat ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/mk-rm-dir-1.m @@ -0,0 +1,6 @@ +nm = tmpnam (); +e1 = mkdir (nm); +[s2, e2] = stat (nm); +e3 = rmdir (nm); +[s4, e4] = stat (nm); +(! e1 && strcmp (s2.modestr(1), "d") && ! e3 && e4 < 0)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/mkdir-1.m @@ -0,0 +1,1 @@ +mkdir ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/mkdir-2.m @@ -0,0 +1,1 @@ +mkdir ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/mktime-1.m @@ -0,0 +1,2 @@ +t = time (); +mktime (localtime (t)) == t
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/mktime-2.m @@ -0,0 +1,1 @@ +mktime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/mktime-3.m @@ -0,0 +1,1 @@ +mktime (1, 2, 3)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/pause-1.m @@ -0,0 +1,2 @@ +pause (0); +printf ("ok\n"); \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/pause-2.m @@ -0,0 +1,1 @@ +pause (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/readdir-1.m @@ -0,0 +1,2 @@ +[files, status, msg] = readdir ("/"); +isstr (files) && status == 0 && msg == ""
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/readdir-2.m @@ -0,0 +1,1 @@ +readdir ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/readdir-3.m @@ -0,0 +1,1 @@ +readdir ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/rename-1.m @@ -0,0 +1,16 @@ +from = tmpnam (); +to = tmpnam (); +id = fopen (from, "w"); +if (id > 0 && fclose (id) == 0) + [s, e] = stat (from); + if (! e) + if (rename (from, to) == 0) + [s, e] = stat (from); + if (e < 0) + [s, e] = stat (to); + e == 0 + unlink (to); + endif + endif + endif +endif
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/rename-2.m @@ -0,0 +1,1 @@ +rename ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/rename-3.m @@ -0,0 +1,1 @@ +rename ("foo", "bar", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/rmdir-1.m @@ -0,0 +1,1 @@ +rmdir ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/rmdir-2.m @@ -0,0 +1,1 @@ +rmdir ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/sleep-1.m @@ -0,0 +1,2 @@ +sleep (0); +printf ("ok\n");
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/sleep-2.m @@ -0,0 +1,1 @@ +sleep ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/sleep-3.m @@ -0,0 +1,1 @@ +sleep (1, 2) \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/stat-1.m @@ -0,0 +1,14 @@ +[s, err, msg] = stat ("/"); +(err == 0 + && is_struct (s) + && struct_contains (s, "dev") + && struct_contains (s, "ino") + && struct_contains (s, "modestr") + && struct_contains (s, "nlink") + && struct_contains (s, "uid") + && struct_contains (s, "gid") + && struct_contains (s, "size") + && struct_contains (s, "atime") + && struct_contains (s, "mtime") + && struct_contains (s, "ctime") + && isstr (msg))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/stat-3.m @@ -0,0 +1,1 @@ +stat ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/strftime-1.m @@ -0,0 +1,2 @@ +fmt = "%%%n%t%H%I%k%l%M%p%r%R%s%S%T%X%Z%a%A%b%B%c%C%d%e%D%h%j%m%U%w%W%x%y%Y"; +isstr (strftime (fmt, localtime (time ()))) \ No newline at end of file
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/strftime-2.m @@ -0,0 +1,1 @@ +strftime ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/strftime-3.m @@ -0,0 +1,1 @@ +strftime ("foo", localtime (time ()), 1)
--- a/test/octave.test/system/system.exp +++ b/test/octave.test/system/system.exp @@ -2,33 +2,292 @@ set prog_output "ans = 1" do_test time-1.m -# ctime -# gmtime -# localtime -# mktime -# asctime -# strftime -# clock -# date -# etime -# cputime -# is_leap_year -# tic-toc -# pause -# sleep -# usleep -# rename -# unlink -# readdir -# mkdir +set test ctime-1 +set prog_output "ans = 1" +do_test ctime-1.m + +set test ctime-2 +set prog_output "usage:.*" +do_test ctime-2.m + +set test ctime-3 +set prog_output "usage:.*" +do_test ctime-3.m + +set test gmtime-1 +set prog_output "ans = 1" +do_test gmtime-1.m + +set test gmtime-2 +set prog_output "\n... gmtime:.*" +do_test gmtime-2.m + +set test gmtime-3 +set prog_output "\n... gmtime:.*" +do_test gmtime-3.m + +set test localtime-1 +set prog_output "ans = 1" +do_test localtime-1.m + +set test localtime-2 +set prog_output "\n... localtime:.*" +do_test localtime-2.m + +set test localtime-3 +set prog_output "\n... localtime:.*" +do_test localtime-3.m + +set test mktime-1 +set prog_output "ans = 1" +do_test mktime-1.m + +set test mktime-2 +set prog_output "\n... mktime:.*" +do_test mktime-2.m + +set test mktime-3 +set prog_output "\n... mktime:.*" +do_test mktime-3.m + +set test asctime-1 +set prog_output "ans = 1" +do_test asctime-1.m + +set test asctime-2 +set prog_output "usage:.*" +do_test asctime-2.m + +set test asctime-3 +set prog_output "usage:.*" +do_test asctime-3.m + +set test strftime-1 +set prog_output "ans = 1" +do_test strftime-1.m + +set test strftime-2 +set prog_output "\n... strftime:.*" +do_test strftime-2.m + +set test strftime-3 +set prog_output "\n... strftime:.*" +do_test strftime-3.m + +set test clock-1 +set prog_output "ans = 1" +do_test clock-1.m + +set test date-1 +set prog_output "ans = 1" +do_test date-1.m + +set test etime-1 +set prog_output "ans = 1" +do_test etime-1.m + +set test etime-2 +set prog_output "usage:.*" +do_test etime-2.m + +set test etime-3 +set prog_output "usage:.*" +do_test etime-3.m + +set test cputime-1 +set prog_output "ans = 1" +do_test cputime-1.m + +set test is_leap_year-1 +set prog_output "ans = 1" +do_test is_leap_year-1.m + +set test is_leap_year-2 +set prog_output "usage:.*" +do_test is_leap_year-2.m + +set test tic-toc-1 +set prog_output "ans = 1" +do_test tic-toc-1.m + +set test pause-1 +set prog_output "ok" +do_test pause-1.m + +set test pause-2 +set prog_output "\n... pause:.*" +do_test pause-2.m + +set test sleep-1 +set prog_output "ok" +do_test sleep-1.m + +set test sleep-2 +set prog_output "\n... sleep:.*" +do_test sleep-2.m + +set test sleep-3 +set prog_output "\n... sleep:.*" +do_test sleep-3.m + +set test usleep-1 +set prog_output "ok" +do_test usleep-1.m + +set test usleep-2 +set prog_output "\n... usleep:.*" +do_test usleep-2.m + +set test usleep-3 +set prog_output "\n... usleep:.*" +do_test usleep-3.m + +set test rename-1 +set prog_output "ans = 1" +do_test rename-1.m + +set test rename-2 +set prog_output "\n... rename:.*" +do_test rename-2.m + +set test rename-3 +set prog_output "\n... rename:.*" +do_test rename-3.m + +set test unlink-1 +set prog_output "ans = 1" +do_test unlink-1.m + +set test unlink-2 +set prog_output "\n... unlink:.*" +do_test unlink-2.m + +set test unlink-3 +set prog_output "\n... unlink:.*" +do_test unlink-3.m + +set test readdir-1 +set prog_output "ans = 1" +do_test readdir-1.m + +set test readdir-2 +set prog_output "\n... readdir:.*" +do_test readdir-2.m + +set test readdir-3 +set prog_output "\n... readdir:.*" +do_test readdir-3.m + +set test mk-rm-dir-1 +set prog_output "ans = 1" +do_test mk-rm-dir-1.m + +set test mkdir-1 +set prog_output "\n... mkdir:.*" +do_test mkdir-1.m + +set test mkdir-2 +set prog_output "\n... mkdir:.*" +do_test mkdir-2.m + +set test rmdir-1 +set prog_output "\n... rmdir:.*" +do_test rmdir-1.m + +set test rmdir-2 +set prog_output "\n... rmdir:.*" +do_test rmdir-2.m + # mkfifo -# umask -# stat -# lstat -# glob -# fnmatch -# file_in_path -# tilde_expand + +set test umask-1 +set prog_output "ans = 1" +do_test umask-1.m + +set test umask-2 +set prog_output "\n... umask:.*" +do_test umask-2.m + +set test umask-3 +set prog_output "\n... umask:.*" +do_test umask-3.m + +set test stat-1 +set prog_output "ans = 1" +do_test stat-1.m + +set test stat-2 +set prog_output "\n... stat:.*" +do_test stat-2.m + +set test stat-3 +set prog_output "\n... stat:.*" +do_test stat-3.m + +set test lstat-1 +set prog_output "ans = 1" +do_test lstat-1.m + +set test lstat-2 +set prog_output "\n... lstat:.*" +do_test lstat-2.m + +set test lstat-3 +set prog_output "\n... lstat:.*" +do_test lstat-3.m + +set test glob-1 +set prog_output "ans = 1" +do_test glob-1.m + +set test glob-2 +set prog_output "\n... glob:*" +do_test glob-2.m + +set test glob-3 +set prog_output "\n... glob:.*" +do_test glob-3.m + +set test fnmatch-1 +set prog_output "ans = 1" +do_test fnmatch-1.m + +set test fnmatch-2 +set prog_output "\n... fnmatch:.*" +do_test fnmatch-2.m + +set test fnmatch-3 +set prog_output "\n... fnmatch:.*" +do_test fnmatch-3.m + +set test file_in_path-1 +set prog_output "ans = 1" +do_test file_in_path-1.m + +set test file_in_path-2 +set prog_output "error:.*" +do_test file_in_path-2.m + +set test file_in_path-3 +set prog_output "\n... file_in_path:.*" +do_test file_in_path-3.m + +set test file_in_path-4 +set prog_output "\n... file_in_path:.*" +do_test file_in_path-4.m + +set test tilde_expand-1 +set prog_output "ans = 1" +do_test tilde_expand-1.m + +set test tilde_expand-2 +set prog_output "\n... tilde_expand:.*" +do_test tilde_expand-2.m + +set test tilde_expand-3 +set prog_output "\n... tilde_expand:.*" +do_test tilde_expand-3.m + # system # popen # pclose
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/tic-toc-1.m @@ -0,0 +1,3 @@ +tic (); +sleep (2) +toc () > 0
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/tilde_expand-1.m @@ -0,0 +1,4 @@ +x = getpwuid (getuid ()); +(strcmp (x.dir, tilde_expand ("~")) + && strcmp (x.dir, tilde_expand (sprintf ("~%s", x.name))) + && strcmp ("foobar", tilde_expand ("foobar")))
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/tilde_expand-2.m @@ -0,0 +1,1 @@ +tilde_expand ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/tilde_expand-3.m @@ -0,0 +1,1 @@ +tilde_expand ("str", 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/umask-1.m @@ -0,0 +1,15 @@ +umask (0); +nm = tmpnam (); +id = fopen (nm, "w"); +s1 = stat (nm); +fclose (id); +unlink (nm); + +umask (777); +nm = tmpnam (); +id = fopen (nm, "w"); +s2 = stat (nm); +fclose (id); +unlink (nm); + +strcmp (s1.modestr, "-rw-rw-rw-") && strcmp (s2.modestr, "----------")
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/umask-2.m @@ -0,0 +1,1 @@ +umask ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/umask-3.m @@ -0,0 +1,1 @@ +umask (1, 2)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/unlink-1.m @@ -0,0 +1,8 @@ +nm = tmpnam (); +if ((id = fopen (nm, "w")) > 0) + [s, err] = stat (nm); + if (! err && fclose (id) == 0 && unlink (nm) == 0) + [s, err] = stat (nm); + err < 0 + endif +endif
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/unlink-2.m @@ -0,0 +1,1 @@ +unlink ()
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/unlink-3.m @@ -0,0 +1,1 @@ +unlink ("foo", 1)
new file mode 100644 --- /dev/null +++ b/test/octave.test/system/usleep-1.m @@ -0,0 +1,2 @@ +usleep (0); +printf ("ok\n");