# HG changeset patch # User jwe # Date 857189771 0 # Node ID 31f6943ed944d67ec1923a4fd5c1a403145401e3 # Parent ee9582e6668f29213d70bf539e766c4b32eac876 [project @ 1997-03-01 04:16:10 by jwe] diff --git a/test/octave.test/switch/switch-1.m b/test/octave.test/switch/switch-1.m new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch-1.m @@ -0,0 +1,10 @@ +a = 1; +b = 2; +c = 3; + +switch 0 case 1 x = a; case 2 x = b; otherwise x = c; endswitch +switch 1 case 1 y = a; case 2 y = b; otherwise y = c; endswitch +switch 2 case 1 z = a; case 2 z = b; otherwise z = c; endswitch +switch 3 case 1 p = a; case 2 p = b; otherwise p = c; endswitch + +x == c && y = a && z = b && p == c diff --git a/test/octave.test/switch/switch-2.m b/test/octave.test/switch/switch-2.m new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch-2.m @@ -0,0 +1,21 @@ +a = 1; +b = 2; +c = 3; + +x = zeros (1, 4); + +k = 1; + +for i = 0:3 + switch (i) + case a + x(k) = a; + case b + x(k) = b; + otherwise + x(k) = c; + endswitch + k++; +endfor + +all (x == [3, 1, 2, 3]) diff --git a/test/octave.test/switch/switch-3.m b/test/octave.test/switch/switch-3.m new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch-3.m @@ -0,0 +1,17 @@ +a = 1; +b = 2; +c = 3; + +x = zeros (1, 4); + +k = 1; + +for i = 0:3 + switch (i) + case a + x(k) = a; + endswitch + k++; +endfor + +all (x == [0, 1, 0, 0]) diff --git a/test/octave.test/switch/switch-4.m b/test/octave.test/switch/switch-4.m new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch-4.m @@ -0,0 +1,1 @@ +switch endswitch diff --git a/test/octave.test/switch/switch-5.m b/test/octave.test/switch/switch-5.m new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch-5.m @@ -0,0 +1,1 @@ +switch case endswitch diff --git a/test/octave.test/switch/switch-6.m b/test/octave.test/switch/switch-6.m new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch-6.m @@ -0,0 +1,1 @@ +switch 1 default 1; endswitch diff --git a/test/octave.test/switch/switch.exp b/test/octave.test/switch/switch.exp new file mode 100644 --- /dev/null +++ b/test/octave.test/switch/switch.exp @@ -0,0 +1,23 @@ +set test switch-1 +set prog_output "ans = 1" +do_test switch-1.m + +set test switch-2 +set prog_output "ans = 1" +do_test switch-2.m + +set test switch-3 +set prog_output "ans = 1" +do_test switch-3.m + +set test switch-4 +set prog_output "parse error.*" +do_test switch-4.m + +set test switch-5 +set prog_output "parse error.*" +do_test switch-5.m + +set test switch-6 +set prog_output "parse error.*" +do_test switch-6.m