summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-05-28 02:18:52 +0000
committerKarl Berry <karl@freefriends.org>2011-05-28 02:18:52 +0000
commitc59fe5fe4739f0c61560f05d4e42b4e552219b27 (patch)
tree8cf79e85e394b3177a28d374415840a4e0a025ad /Build/source/utils/asymptote/tests
parent771db15706dbf3f4af8b630dcb15646a3e5fda00 (diff)
asy 2.10
git-svn-id: svn://tug.org/texlive/trunk@22633 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/tests')
-rw-r--r--Build/source/utils/asymptote/tests/Makefile2
-rw-r--r--Build/source/utils/asymptote/tests/array/fields.asy4
-rw-r--r--Build/source/utils/asymptote/tests/frames/loop.asy167
-rw-r--r--Build/source/utils/asymptote/tests/output/Makefile2
-rw-r--r--Build/source/utils/asymptote/tests/types/keyword.asy197
5 files changed, 369 insertions, 3 deletions
diff --git a/Build/source/utils/asymptote/tests/Makefile b/Build/source/utils/asymptote/tests/Makefile
index 3372c7a6268..afdae4e0472 100644
--- a/Build/source/utils/asymptote/tests/Makefile
+++ b/Build/source/utils/asymptote/tests/Makefile
@@ -1,7 +1,7 @@
.NOTPARALLEL:
TESTDIRS = string arith frames types imp array
-EXTRADIRS = gsl
+EXTRADIRS = gsl output
test: $(TESTDIRS)
diff --git a/Build/source/utils/asymptote/tests/array/fields.asy b/Build/source/utils/asymptote/tests/array/fields.asy
index 7845ef2de64..9b5926d3745 100644
--- a/Build/source/utils/asymptote/tests/array/fields.asy
+++ b/Build/source/utils/asymptote/tests/array/fields.asy
@@ -16,11 +16,13 @@ StartTest("fields");
z.cyclic=false;
}
}
+
{
int[] z = {2, 3, 5};
for (int k = -100; k <= 100; ++k)
assert(z.initialized(k) == (k >= 0 && k < 3));
}
+
{
int[] z;
for (int i=0; i<10; ++i) {
@@ -53,7 +55,7 @@ StartTest("fields");
{
int[] base={4,5,9,5,0,2,3};
int[] z;
- for (int i=0; i<99; ++i) {
+ for (int i=0; i<9; ++i) {
assert(z.length == i*base.length);
for (int j : z.keys)
assert(z[j] == base[j%base.length]);
diff --git a/Build/source/utils/asymptote/tests/frames/loop.asy b/Build/source/utils/asymptote/tests/frames/loop.asy
index ceb65a1ff56..a4714d1f8da 100644
--- a/Build/source/utils/asymptote/tests/frames/loop.asy
+++ b/Build/source/utils/asymptote/tests/frames/loop.asy
@@ -26,4 +26,171 @@ for (int i=0; i<10; ++i) {
}
assert(f()==70);
+{
+ int y = 3;
+ int z = 0;
+ for (int i = 0; i < 7; ++i)
+ {
+ ++z;
+ continue;
+ y = 4;
+ }
+ assert(y == 3);
+ assert(z == 7);
+}
+{
+ int y = 3;
+ int z = 0;
+ for (int i = 0; i < 7; ++i)
+ {
+ ++z;
+ break;
+ y = 4;
+ }
+ assert(y == 3);
+ assert(z == 1);
+}
+{
+ int y = 3;
+ int z = 0;
+ for (int i = 0; i < 7; ++i)
+ {
+ void g() {}
+ ++z;
+ continue;
+ y = 4;
+ }
+ assert(y == 3);
+ assert(z == 7);
+}
+{
+ int y = 3;
+ int z = 0;
+ for (int i = 0; i < 7; ++i)
+ {
+ void g() {}
+ ++z;
+ break;
+ y = 4;
+ }
+ assert(y == 3);
+ assert(z == 1);
+}
+
+// While loops
+{
+ int y = 7;
+ int z = 0;
+ while (z < 10) {
+ ++z;
+ continue;
+ ++y;
+ }
+ assert(z == 10);
+ assert(y == 7);
+}
+
+{
+ int y = 7;
+ int z = 0;
+ while (z < 10) {
+ void g() {}
+ ++z;
+ continue;
+ ++y;
+ }
+ assert(z == 10);
+ assert(y == 7);
+}
+
+{
+ int y = 7;
+ int z = 0;
+ while (z < 10) {
+ ++z;
+ break;
+ ++y;
+ }
+ assert(z == 1);
+ assert(y == 7);
+}
+
+{
+ int y = 7;
+ int z = 0;
+ while (z < 10) {
+ void g() {}
+ ++z;
+ break;
+ ++y;
+ }
+ assert(z == 1);
+ assert(y == 7);
+}
+
+
+{
+ int y = 7;
+ int z = 0;
+ while (z < 10) {
+ ++z;
+ continue;
+ ++y;
+ }
+ assert(z == 10);
+ assert(y == 7);
+}
+
+// Do loops
+{
+ int y = 7;
+ int z = 0;
+ do {
+ void g() {}
+ ++z;
+ continue;
+ ++y;
+ } while (z < 10);
+ assert(z == 10);
+ assert(y == 7);
+}
+
+{
+ int y = 7;
+ int z = 0;
+ do {
+ ++z;
+ break;
+ ++y;
+ } while (z < 10);
+ assert(z == 1);
+ assert(y == 7);
+}
+
+{
+ int y = 7;
+ int z = 0;
+ do {
+ void g() {}
+ ++z;
+ break;
+ ++y;
+ } while (z < 10);
+ assert(z == 1);
+ assert(y == 7);
+}
+
+{
+ int x = 456;
+ do { x = 123; } while (false);
+ assert(x == 123);
+}
+
+{
+ int x = 456;
+ do { void g() {} x = 123; } while (false);
+ assert(x == 123);
+}
+
+
EndTest();
diff --git a/Build/source/utils/asymptote/tests/output/Makefile b/Build/source/utils/asymptote/tests/output/Makefile
index 2462ea1cae5..938625ab038 100644
--- a/Build/source/utils/asymptote/tests/output/Makefile
+++ b/Build/source/utils/asymptote/tests/output/Makefile
@@ -17,7 +17,7 @@ $(TESTS:=.ref) $(TESTS:=.out): %:
@rm -rf $@
@mkdir $@
@cd $@; \
- $(ASY) -v -v -keep ../$(basename $@) \
+ $(ASY) -keep ../$(basename $@) \
>$(basename $@).stdout 2>$(basename $@).stderr; \
ls >$(basename $@).ls; \
rm -f *.dvi *.pdf *.gif *.jpg *.jpeg *.png
diff --git a/Build/source/utils/asymptote/tests/types/keyword.asy b/Build/source/utils/asymptote/tests/types/keyword.asy
new file mode 100644
index 00000000000..63ad01fecd5
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/keyword.asy
@@ -0,0 +1,197 @@
+import TestLib;
+StartTest("keyword");
+{
+ int f(int keyword x) {
+ return 2*x;
+ }
+
+ assert(f(x=17) == 34);
+}
+
+{
+ int f(int keyword x = 10) {
+ return 2*x;
+ }
+
+ assert(f() == 20);
+}
+
+{
+ int f(int keyword x = 10, int keyword y = 20)
+ {
+ return 2x+y;
+ }
+
+ assert(f(x=1,y=2) == 4);
+ assert(f(y=1,x=2) == 5);
+ assert(f(x=1) == 22);
+ assert(f(y=7) == 27);
+ assert(f() == 40);
+}
+
+{
+ int f(int keyword x, int keyword y = 20)
+ {
+ return x+y;
+ }
+
+ assert(f(x=1,y=2) == 3);
+ assert(f(x=1) == 21);
+}
+
+{
+ int f(int keyword x = 10, int keyword y)
+ {
+ return x+y;
+ }
+
+ assert(f(x=1,y=2) == 3);
+ assert(f(y=2) == 12);
+}
+
+{
+ int f(int keyword x, int keyword y)
+ {
+ return x+y;
+ }
+
+ assert(f(x=1,y=2) == 3);
+}
+
+{
+ int f(int x, int keyword y)
+ {
+ return 2x+y;
+ }
+
+ assert(f(x=1,y=2) == 4);
+ assert(f(1,y=2) == 4);
+ assert(f(y=2,1) == 4);
+ assert(f(y=2,x=1) == 4);
+}
+
+{
+ int f(... int[] nums, int keyword r)
+ {
+ return r;
+ }
+
+ assert(f(r=3) == 3);
+ assert(f(1,r=3) == 3);
+ assert(f(1,2, r=3) == 3);
+ assert(f(1,2,4,5,6, r=3) == 3);
+ assert(f(r=3, 10, 20, 30) == 3);
+ assert(f(4, 5, r=3, 10, 20, 30) == 3);
+ assert(f(4, 5, r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ assert(f(r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ assert(f(r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ /*
+ assert(f(... new int[] {40,50,60}, r=3) == 3);
+ assert(f(... new int[] {40,50,60}, r=3) == 3);
+ */
+}
+
+{
+ int f(... int[] nums, int keyword r=77)
+ {
+ return r;
+ }
+
+ assert(f(r=3) == 3);
+ assert(f(1,r=3) == 3);
+ assert(f(1,2, r=3) == 3);
+ assert(f(1,2,4,5,6, r=3) == 3);
+ assert(f(r=3, 10, 20, 30) == 3);
+ assert(f(4, 5, r=3, 10, 20, 30) == 3);
+ assert(f(4, 5, r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ assert(f(r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ assert(f(r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ /*
+ assert(f(... new int[] {40,50,60}, r=3) == 3);
+ assert(f(... new int[] {40,50,60}, r=3) == 3);
+ */
+
+ assert(f() == 77);
+ assert(f(1) == 77);
+ assert(f(1,2) == 77);
+ assert(f(1,2,4,5,6) == 77);
+ assert(f(10, 20, 30) == 77);
+ assert(f(4, 5, 10, 20, 30) == 77);
+ assert(f(4, 5, 10, 20, 30 ... new int[] {40,50,60}) == 77);
+ assert(f(10, 20, 30 ... new int[] {40,50,60}) == 77);
+ assert(f(10, 20, 30 ... new int[] {40,50,60}) == 77);
+ assert(f(... new int[] {40,50,60}) == 77);
+ assert(f(... new int[] {40,50,60}) == 77);
+}
+
+{
+ int f(int x ... int[] nums, int keyword r=77)
+ {
+ return r;
+ }
+
+ assert(f(345,r=3) == 3);
+ assert(f(345,1,r=3) == 3);
+ assert(f(345,1,2, r=3) == 3);
+ assert(f(345,1,2,4,5,6, r=3) == 3);
+ assert(f(345,r=3, 10, 20, 30) == 3);
+ assert(f(345,4, 5, r=3, 10, 20, 30) == 3);
+ assert(f(345,4, 5, r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ assert(f(345,r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ assert(f(345,r=3, 10, 20, 30 ... new int[] {40,50,60}) == 3);
+ /*
+ assert(f(345 ... new int[] {40,50,60}, r=3) == 3);
+ assert(f(345 ... new int[] {40,50,60}, r=3) == 3);
+ assert("ADD LEFT TO RIGHT ORDER TESTING" == "Not yet");
+ */
+
+ assert(f(345) == 77);
+ assert(f(345,1) == 77);
+ assert(f(345,1,2) == 77);
+ assert(f(345,1,2,4,5,6) == 77);
+ assert(f(345,10, 20, 30) == 77);
+ assert(f(345,4, 5, 10, 20, 30) == 77);
+ assert(f(345,4, 5, 10, 20, 30 ... new int[] {40,50,60}) == 77);
+ assert(f(345,10, 20, 30 ... new int[] {40,50,60}) == 77);
+ assert(f(345,10, 20, 30 ... new int[] {40,50,60}) == 77);
+ assert(f(345 ... new int[] {40,50,60}) == 77);
+ assert(f(345 ... new int[] {40,50,60}) == 77);
+}
+
+{
+ int sqr(int x=7) { return x*x; }
+ int f(int keyword x) = sqr;
+ int g(int keyword x=666) = sqr;
+ assert(f(x=5) == 25);
+ assert(g(x=5) == 25);
+ assert(g() == 49);
+}
+{
+ int sqr(int n=7) { return n*n; }
+ int f(int keyword x) = sqr;
+ int g(int keyword x=666) = sqr;
+ assert(f(x=5) == 25);
+ assert(g(x=5) == 25);
+ assert(g() == 49);
+}
+{
+ int sqr(int keyword x=7) { return x*x; }
+ int f(int x) = sqr;
+ int g(int x=666) = sqr;
+ assert(f(x=5) == 25);
+ assert(g(x=5) == 25);
+ assert(f(5) == 25);
+ assert(g(5) == 25);
+ assert(g() == 49);
+}
+{
+ int sqr(int keyword n=7) { return n*n; }
+ int f(int x) = sqr;
+ int g(int x=666) = sqr;
+ assert(f(x=5) == 25);
+ assert(g(x=5) == 25);
+ assert(f(5) == 25);
+ assert(g(5) == 25);
+ assert(g() == 49);
+}
+EndTest();