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/types | |
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/types')
-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 |
3 files changed, 266 insertions, 7 deletions
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(); |