diff options
author | Karl Berry <karl@freefriends.org> | 2012-05-31 00:02:26 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-05-31 00:02:26 +0000 |
commit | 19fc9fd9a26973d87fad437ce549ffaba479df54 (patch) | |
tree | f40a9d2592b3cf827970c8bf54a1eebf9cc8f9c0 /Build/source/utils/asymptote/tests | |
parent | 24b3bac312553b2cc61e94fda581aba311967f5c (diff) |
asy 2.16 sources
git-svn-id: svn://tug.org/texlive/trunk@26734 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/tests')
-rw-r--r-- | Build/source/utils/asymptote/tests/Makefile | 2 | ||||
-rw-r--r-- | Build/source/utils/asymptote/tests/gc/label.asy | 8 | ||||
-rw-r--r-- | Build/source/utils/asymptote/tests/gc/shipout.asy | 11 | ||||
-rw-r--r-- | Build/source/utils/asymptote/tests/pic/trans.asy | 75 | ||||
-rw-r--r-- | Build/source/utils/asymptote/tests/types/constructor.asy | 101 | ||||
-rw-r--r-- | Build/source/utils/asymptote/tests/types/keyword.asy | 7 | ||||
-rw-r--r-- | Build/source/utils/asymptote/tests/types/order.asy | 165 |
7 files changed, 361 insertions, 8 deletions
diff --git a/Build/source/utils/asymptote/tests/Makefile b/Build/source/utils/asymptote/tests/Makefile index afdae4e0472..ec7827ca476 100644 --- a/Build/source/utils/asymptote/tests/Makefile +++ b/Build/source/utils/asymptote/tests/Makefile @@ -1,6 +1,6 @@ .NOTPARALLEL: -TESTDIRS = string arith frames types imp array +TESTDIRS = string arith frames types imp array pic EXTRADIRS = gsl output test: $(TESTDIRS) diff --git a/Build/source/utils/asymptote/tests/gc/label.asy b/Build/source/utils/asymptote/tests/gc/label.asy new file mode 100644 index 00000000000..8ffa26409c9 --- /dev/null +++ b/Build/source/utils/asymptote/tests/gc/label.asy @@ -0,0 +1,8 @@ +guide a; +for (int i = 0; i < 1e7; ++i) +{ + picture pic; + size(pic,10cm,20cm); + draw(pic,"a",scale(2)*(0,0)--(1,1)); + shipout(pic); +} diff --git a/Build/source/utils/asymptote/tests/gc/shipout.asy b/Build/source/utils/asymptote/tests/gc/shipout.asy new file mode 100644 index 00000000000..6622093cf8c --- /dev/null +++ b/Build/source/utils/asymptote/tests/gc/shipout.asy @@ -0,0 +1,11 @@ +guide a; +for (int i = 0; i < 1e7; ++i) +{ + picture pic; + size(pic,10cm,20cm); + path p=(1.0,2.0); + path q=(3.0,4.0); + path a=p..q..(3,5); + draw(pic,a,blue+dashed); + shipout(pic); +} diff --git a/Build/source/utils/asymptote/tests/pic/trans.asy b/Build/source/utils/asymptote/tests/pic/trans.asy new file mode 100644 index 00000000000..9a2e02decfa --- /dev/null +++ b/Build/source/utils/asymptote/tests/pic/trans.asy @@ -0,0 +1,75 @@ +import TestLib; + +StartTest("trans"); + +// Ensure the same test each time. +srand(3456); + +pair randompair() +{ + return (unitrand(),unitrand()); +} + +path randombox() +{ + return box(randompair(), randompair()); +} + +// For now, only tests transforms which take axes to axes. +transform randomtrans() +{ + return rotate(90 * (rand() % 4)) * shift(unitrand(), unitrand()); +} + +real tolerance = 1e-4; + +void testpic(int objs, int trans) +{ + path[] pp; + picture orig; + for (int i = 0; i < objs; ++i) { + pp.push(randombox()); + fill(orig, pp[i]); + } + + picture pic = orig; + transform t = identity(); + for (int i = 0; i < trans; ++i) + { + transform tt = randomtrans(); + pic = tt * pic; + t = tt * t; + } + + pair m = pic.userMin2(), M = pic.userMax2(); + pair pm = min(t * pp), pM = max(t * pp); + + assert(abs(m-pm) < tolerance); + assert(abs(M-pM) < tolerance); +} + +for (int i = 0; i < 100; ++i) + testpic(1,1); +for (int i = 0; i < 100; ++i) + testpic(1,1); +for (int i = 0; i < 100; ++i) + testpic(3,1); +for (int i = 0; i < 100; ++i) + testpic(1,2); +for (int i = 0; i < 100; ++i) + testpic(2,2); +for (int i = 0; i < 100; ++i) + testpic(3,2); +for (int i = 0; i < 100; ++i) + testpic(3,4); +for (int i = 0; i < 100; ++i) + testpic(1,4); +for (int i = 0; i < 100; ++i) + testpic(2,4); +for (int i = 0; i < 100; ++i) + testpic(3,4); +for (int i = 0; i < 100; ++i) + testpic(3,4); + + +EndTest(); diff --git a/Build/source/utils/asymptote/tests/types/constructor.asy b/Build/source/utils/asymptote/tests/types/constructor.asy index 754584edcdb..78a0684fa94 100644 --- a/Build/source/utils/asymptote/tests/types/constructor.asy +++ b/Build/source/utils/asymptote/tests/types/constructor.asy @@ -277,3 +277,104 @@ assert(constructor()==44); EndTest(); // {{{1 +StartTest("tuple"); // {{{1 +{ + pair z = (1,2); + assert(z.x==1); + assert(z.y==2); + pair w = z; + w = (2,3); + assert(z.x==1); + assert(z.y==2); +} +{ + triple z = (1,2,6); + assert(z.x==1); + assert(z.y==2); + assert(z.z==6); + triple w = z; + w = (2,3,9); + assert(z.x==1); + assert(z.y==2); + assert(z.z==6); +} +{ + transform z = (1,2,3,4,5,6); + assert(z.x==1); + assert(z.y==2); + assert(z.xx==3); + assert(z.xy==4); + assert(z.yx==5); + assert(z.yy==6); +} +{ + pair z = (34.0, 35.0); + triple t = (34.0, 35.0, 36.0); + + { + int operator tuple(int x, int y) { return x+y; } + assert((1,2) == 3); + assert((34,35) == 34+35); + assert((34.0,35) == z); + assert((34,35.0) == z); + assert((34.0,35.0) == z); + } + { + int operator tuple(int x, int y) { return x+y; } + int operator tuple(int x, real y) { return 123; } + assert((1,2) == 3); + assert((34,35) == 34+35); + assert((34.0,35) == z); + assert((34,35.0) == 123); + assert((34.0,35.0) == z); + } + { + int operator tuple(int x, int y) { return x+y; } + int operator tuple(int x, real y) { return 123; } + int operator tuple(real x, int y) { return 456; } + assert((1,2) == 3); + assert((34,35) == 34+35); + assert((34.0,35) == 456); + assert((34,35.0) == 123); + assert((34.0,35.0) == z); + } + { + int operator tuple(int x, int y) { return x+y; } + int operator tuple(real x, int y) { return 456; } + assert((1,2) == 3); + assert((34,35) == 34+35); + assert((34.0,35) == 456); + assert((34,35.0) == z); + assert((34.0,35.0) == z); + } + { + int operator tuple(int x, int y) { return x+y; } + int operator tuple(int x, real y) { return 123; } + int operator tuple(real x, int y) { return 456; } + int operator tuple(real x, real y) { return 789; } + assert((1,2) == 3); + assert((34,35) == 34+35); + assert((34.0,35) == 456); + assert((34,35.0) == 123); + assert((34.0,35.0) == 789); + } + { + int operator tuple(int x, int y) { return x+y; } + int operator tuple(real x, real y) { return 789; } + assert((1,2) == 3); + assert((34,35) == 34+35); + assert((34.0,35) == 789); + assert((34,35.0) == 789); + assert((34.0,35.0) == 789); + } + { + int operator tuple(...int[] x) { return x.length; } + assert((34,35) == z); + assert((34,35,36) == t); + assert((34,35,36,37) == 4); + assert((34,35,36,37,38) == 5); + assert((34,35,36,37,1,2,3,4) == 8); + assert((34,35,36,37,1,2,3,4,5,6,7,8,9) == 13); + } +} +EndTest(); diff --git a/Build/source/utils/asymptote/tests/types/keyword.asy b/Build/source/utils/asymptote/tests/types/keyword.asy index 63ad01fecd5..73e407b6f8c 100644 --- a/Build/source/utils/asymptote/tests/types/keyword.asy +++ b/Build/source/utils/asymptote/tests/types/keyword.asy @@ -85,10 +85,8 @@ StartTest("keyword"); 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); - */ } { @@ -106,10 +104,8 @@ StartTest("keyword"); 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); @@ -139,11 +135,8 @@ StartTest("keyword"); 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); diff --git a/Build/source/utils/asymptote/tests/types/order.asy b/Build/source/utils/asymptote/tests/types/order.asy new file mode 100644 index 00000000000..b2530b17abf --- /dev/null +++ b/Build/source/utils/asymptote/tests/types/order.asy @@ -0,0 +1,165 @@ +import TestLib; +StartTest("order"); + +// Ordering tests. +int counter = 0; +int step(int n) { ++counter; assert(counter == n); return n; } +int[] stepArray(int n) { return new int[] {step(n)}; } +void reset() { counter = 0; } + +{ + reset(); + assert(step(1) + step(2) == step(3)); step(4); +} + +{ + reset(); + assert(step(1) == 0 || step(2) == 2); step(3); +} + +{ + reset(); + step(1) == 0 && step(999) == step(456); step(2); +} + +{ + reset(); + int x = step(1), y = step(2); step(3); + int x = step(4), y = step(5); step(6); +} + +{ + void f(int x, int y) {} + + reset(); + f(step(1), step(2)); step(3); + reset(); + f(x=step(1), y=step(2)); step(3); + reset(); + f(y=step(1), x=step(2)); step(3); + reset(); + f(x=step(1), step(2)); step(3); + reset(); + f(y=step(1), step(2)); step(3); + reset(); + f(step(1), x=step(2)); step(3); + reset(); + f(step(1), y=step(2)); step(3); +} + +{ + void f(int x, int y ... int[] z) {} + + reset(); + f(step(1), step(2)); step(3); + reset(); + f(x=step(1), y=step(2)); step(3); + reset(); + f(y=step(1), x=step(2)); step(3); + reset(); + f(x=step(1), step(2)); step(3); + reset(); + f(y=step(1), step(2)); step(3); + reset(); + f(step(1), x=step(2)); step(3); + reset(); + f(step(1), y=step(2)); step(3); + + reset(); + f(step(1), step(2), step(3)); step(4); + reset(); + f(x=step(1), y=step(2), step(3)); step(4); + reset(); + f(y=step(1), x=step(2), step(3)); step(4); + reset(); + f(x=step(1), step(2), step(3)); step(4); + reset(); + f(y=step(1), step(2), step(3)); step(4); + reset(); + f(step(1), x=step(2), step(3)); step(4); + reset(); + f(step(1), y=step(2), step(3)); step(4); + + reset(); + f(step(1), step(2), step(3), step(4)); step(5); + reset(); + f(x=step(1), y=step(2), step(3), step(4)); step(5); + reset(); + f(y=step(1), x=step(2), step(3), step(4)); step(5); + reset(); + f(x=step(1), step(2), step(3), step(4)); step(5); + reset(); + f(y=step(1), step(2), step(3), step(4)); step(5); + reset(); + f(step(1), x=step(2), step(3), step(4)); step(5); + reset(); + f(step(1), y=step(2), step(3), step(4)); step(5); + + reset(); + f(step(1), step(2), step(3)); step(4); + reset(); + f(x=step(1), step(2), y=step(3)); step(4); + reset(); + f(y=step(1), step(2), x=step(3)); step(4); + reset(); + f(x=step(1), step(2), step(3)); step(4); + reset(); + f(y=step(1), step(2), step(3)); step(4); + reset(); + f(step(1), step(2), x=step(3)); step(4); + reset(); + f(step(1), step(2), y=step(3)); step(4); + + reset(); + f(step(1), step(2), step(3), step(4)); step(5); + reset(); + f(x=step(1), step(2), y=step(3), step(4)); step(5); + reset(); + f(y=step(1), step(2), x=step(3), step(4)); step(5); + reset(); + f(x=step(1), step(2), step(3), step(4)); step(5); + reset(); + f(y=step(1), step(2), step(3), step(4)); step(5); + reset(); + f(step(1), step(2), x=step(3), step(4)); step(5); + reset(); + f(step(1), step(2), y=step(3), step(4)); step(5); + + reset(); + f(step(1), step(2), step(3), step(4)... stepArray(5)); step(6); + reset(); + f(x=step(1), step(2), y=step(3), step(4)... stepArray(5)); step(6); + reset(); + f(y=step(1), step(2), x=step(3), step(4)... stepArray(5)); step(6); + reset(); + f(x=step(1), step(2), step(3), step(4)... stepArray(5)); step(6); + reset(); + f(y=step(1), step(2), step(3), step(4)... stepArray(5)); step(6); + reset(); + f(step(1), step(2), x=step(3), step(4)... stepArray(5)); step(6); + reset(); + f(step(1), step(2), y=step(3), step(4)... stepArray(5)); step(6); + + reset(); + f(...stepArray(1), x=step(2), y=step(3)); step(4); + reset(); + f(...stepArray(1), y=step(2), x=step(3)); step(4); + reset(); + f(step(1)...stepArray(2), x=step(3), y=step(4)); step(5); + reset(); + f(step(1)...stepArray(2), y=step(3), x=step(4)); step(5); + reset(); + f(step(1),step(2)...stepArray(3), y=step(4), x=step(5)); step(6); + reset(); + f(step(1),step(2)...stepArray(3), y=step(4), x=step(5)); step(6); + reset(); + f(step(1),step(2),x=step(3)...stepArray(4), y=step(5)); step(6); + reset(); + f(step(1),step(2),x=step(3)...stepArray(4), y=step(5)); step(6); +} + + + +// TODO: Add packing vs. casting tests. + +EndTest(); |