summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests/types
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/tests/types')
-rw-r--r--Build/source/utils/asymptote/tests/types/cast.asy13
-rw-r--r--Build/source/utils/asymptote/tests/types/constructor.asy380
-rw-r--r--Build/source/utils/asymptote/tests/types/ecast.asy11
-rw-r--r--Build/source/utils/asymptote/tests/types/guide.asy160
-rw-r--r--Build/source/utils/asymptote/tests/types/init.asy17
-rw-r--r--Build/source/utils/asymptote/tests/types/keyword.asy190
-rw-r--r--Build/source/utils/asymptote/tests/types/order.asy165
-rw-r--r--Build/source/utils/asymptote/tests/types/resolve.asy157
-rw-r--r--Build/source/utils/asymptote/tests/types/shadow.asy17
-rw-r--r--Build/source/utils/asymptote/tests/types/spec.asy61
-rw-r--r--Build/source/utils/asymptote/tests/types/var.asy86
11 files changed, 1257 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/tests/types/cast.asy b/Build/source/utils/asymptote/tests/types/cast.asy
new file mode 100644
index 00000000000..b1191637554
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/cast.asy
@@ -0,0 +1,13 @@
+import TestLib;
+StartTest("cast");
+struct A {
+ public int x;
+}
+A operator cast(int x) {
+ A a=new A;
+ a.x=x;
+ return a;
+}
+A a=7;
+assert(a.x==7);
+EndTest();
diff --git a/Build/source/utils/asymptote/tests/types/constructor.asy b/Build/source/utils/asymptote/tests/types/constructor.asy
new file mode 100644
index 00000000000..78a0684fa94
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/constructor.asy
@@ -0,0 +1,380 @@
+import TestLib;
+StartTest("constructor");
+
+{ // Basic usage. {{{1
+ struct Foo {
+ int x;
+ int y;
+
+ void operator init() {
+ x=2; y=3;
+ }
+
+ void operator init(int x, int y=2x) {
+ this.x=x; this.y=y;
+ }
+
+ void operator init(string s ... int[] vals) {
+ for (int i=0; i<vals.length; ++i)
+ x+=vals[i];
+ y=vals.length;
+ }
+
+ static {
+ {
+ Foo f=new Foo;
+ assert(f.x==0);
+ assert(f.y==0);
+ }
+ {
+ Foo f=Foo();
+ assert(f.x==2);
+ assert(f.y==3);
+ }
+ {
+ Foo f=Foo(7);
+ assert(f.x==7);
+ assert(f.y==14);
+ }
+ {
+ Foo f=Foo(5,40);
+ assert(f.x==5);
+ assert(f.y==40);
+ }
+ {
+ Foo f=Foo(y=5,x=40);
+ assert(f.x==40);
+ assert(f.y==5);
+ }
+ {
+ Foo f=Foo("hello", 1,2,3,4);
+ assert(f.x==10);
+ assert(f.y==4);
+ }
+ }
+ }
+
+ {
+ Foo f=new Foo;
+ assert(f.x==0);
+ assert(f.y==0);
+ }
+ {
+ Foo f=Foo();
+ assert(f.x==2);
+ assert(f.y==3);
+ }
+ {
+ Foo f=Foo(7);
+ assert(f.x==7);
+ assert(f.y==14);
+ }
+ {
+ Foo f=Foo(5,40);
+ assert(f.x==5);
+ assert(f.y==40);
+ }
+ {
+ Foo f=Foo(y=5,x=40);
+ assert(f.x==40);
+ assert(f.y==5);
+ }
+ {
+ Foo f=Foo("hello", 1,2,3,4);
+ assert(f.x==10);
+ assert(f.y==4);
+ }
+}
+
+{ // Assignment {{{1
+ struct Foo {
+ int x;
+
+ static int Foo() {
+ return 7;
+ }
+
+ static assert(Foo()==7);
+
+ void five() {
+ x=5;
+ }
+
+ void six(string s) {
+ x=6;
+ }
+
+ void operator init()=five;
+
+ void operator init(string s) {
+ assert(false);
+ }
+ operator init=six;
+
+ static {
+ assert(Foo().x==5);
+ assert(Foo("milk").x==6);
+ }
+
+ void operator init(int x) {
+ this.x=2x;
+ }
+
+ static Foo constructor(int)=Foo;
+
+ static {
+ assert(constructor(5).x==10);
+ }
+ }
+
+ assert(Foo().x==5);
+ assert(Foo("milk").x==6);
+ assert(Foo.constructor(5).x==10);
+}
+
+{ // Permission {{{1
+ int Foo() {
+ return 3;
+ }
+
+ struct Foo {
+ int x;
+
+ private void operator init() {
+ x=2;
+ }
+ }
+ // The implicit constructor should not be unravelled, as it is private.
+ assert(Foo()==3);
+}
+{ // Shadowing {{{1
+ struct Foo {
+ static Foo Foo() {
+ return null;
+ }
+
+ static assert(Foo()==null);
+
+ void operator init() {
+ }
+
+ static assert(Foo()!=null);
+ }
+
+ assert(Foo()!=null);
+
+ // Can't use Bar because of conflicts with the drawing command.
+ struct Barr {
+ void operator init() {
+ }
+
+ static assert(Barr()!=null);
+
+ static Barr Barr() {
+ return null;
+ }
+
+ static assert(Barr()==null);
+ }
+
+ assert(Barr()!=null);
+
+ struct Blah {
+ void operator init() {
+ }
+
+ static assert(Blah()!=null);
+
+ static Blah Blah() {
+ return null;
+ }
+
+ static assert(Blah()==null);
+ }
+ from Blah unravel Blah;
+
+ assert(Blah()==null);
+}
+
+{ // Static {{{1
+ struct Foo {
+ static int Foo() {
+ return 7;
+ }
+
+ static void operator init() {
+ }
+
+ static assert(Foo()==7);
+ }
+
+ struct Barr {
+ int x;
+
+ void operator init() {
+ x=77;
+ }
+
+ static assert(Barr().x==77);
+
+ static void operator init() {
+ assert(false);
+ }
+
+ static assert(Barr().x==77);
+ }
+
+ assert(Barr().x==77);
+}
+
+{ // Struct name shadowing. {{{1
+ struct Foo {
+ int x;
+ typedef int Foo;
+
+ void operator init() {
+ x=89;
+ }
+
+ static assert(Foo().x==89);
+ }
+
+ assert(Foo().x==89);
+
+ struct Barr {
+ int x;
+ struct Barr {
+ }
+
+ void operator init() {
+ x=89;
+ }
+
+ static assert(Barr().x==89);
+ }
+
+ assert(Barr().x==89);
+}
+{ // Function Comparison
+ struct A {
+ // Defines a function A A(int).
+ void operator init(int x) {}
+ }
+ assert(!(A == null));
+ assert(A != null);
+}
+
+// File-level {{{1
+// This assumes the file is named constructor.asy
+
+int constructor() {
+ return 44;
+}
+void operator init() {
+ assert(false);
+}
+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/ecast.asy b/Build/source/utils/asymptote/tests/types/ecast.asy
new file mode 100644
index 00000000000..d16d7bc4494
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/ecast.asy
@@ -0,0 +1,11 @@
+import TestLib;
+StartTest("ecast");
+struct A {
+ public int x;
+}
+int operator ecast(A a) {
+ return a.x;
+}
+A a=new A; a.x=5;
+assert((int)a==5);
+EndTest();
diff --git a/Build/source/utils/asymptote/tests/types/guide.asy b/Build/source/utils/asymptote/tests/types/guide.asy
new file mode 100644
index 00000000000..ec16e0ed7ce
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/guide.asy
@@ -0,0 +1,160 @@
+import TestLib;
+StartTest("guide");
+
+guide g;
+assert(size(g) == 0);
+assert(length(g) == -1);
+
+guide g=(0,0){curl 2}..(1,1){W}..tension 5 and 6 ..{N}(4,2)..{curl 3}(0,1);
+
+g=reverse(reverse(g));
+
+assert(size(g) == 4);
+assert(length(g) == 3);
+
+assert(size((path) g) == 4);
+assert(length((path) g) == 3);
+
+assert(size((guide) (path) g) == 4);
+assert(length((guide) (path) g) == 3);
+
+assert(close(point(g,-1),(0,0)));
+assert(close(point(g,0),(0,0)));
+assert(close(point(g,1),(1,1)));
+assert(close(point(g,3),(0,1)));
+assert(close(point(g,4),(0,1)));
+
+tensionSpecifier t=tensionSpecifier(g,1);
+assert(close(t.out,5));
+assert(close(t.in,6));
+assert(t.atLeast == false);
+
+pair[] z=dirSpecifier(g,0);
+assert(close(z[0],0));
+assert(close(z[1],0));
+
+pair[] z=dirSpecifier(g,1);
+assert(close(z[0],W));
+assert(close(z[1],N));
+
+real[] x=curlSpecifier(g,0);
+assert(close(x[0],2));
+assert(close(x[1],1));
+
+real[] x=curlSpecifier(g,length(g)-1);
+assert(close(x[0],1));
+assert(close(x[1],3));
+
+assert(!cyclic(g));
+assert(!cyclic((path) g));
+assert(!cyclic((guide) (path) g));
+
+guide g=(0,0)..controls (3,5)..(1,1){W}..tension atleast 5 and 6 ..{N}(4,2)..
+controls(1,2) and (2,4).. (0,1)..cycle;
+
+g=reverse(reverse(g));
+
+assert(size(g) == 4);
+assert(length(g) == 4);
+
+assert(size((path) g) == 4);
+assert(length((path) g) == 4);
+
+assert(size((guide) (path) g) == 4);
+assert(length((guide) (path) g) == 4);
+
+tensionSpecifier t=tensionSpecifier(g,1);
+assert(close(t.out,5));
+assert(close(t.in,6));
+assert(t.atLeast == true);
+
+pair[] z=controlSpecifier(g,0);
+assert(close(z[0],(3,5)));
+assert(close(z[1],(3,5)));
+
+pair[] z=controlSpecifier(g,2);
+assert(close(z[0],(1,2)));
+assert(close(z[1],(2,4)));
+
+real[] x=curlSpecifier(g,0);
+assert(close(x[0],1));
+assert(close(x[1],1));
+
+real[] x=curlSpecifier(g,length(g)-1);
+assert(close(x[0],1));
+assert(close(x[1],1));
+
+assert(cyclic(g));
+assert(cyclic((path) g));
+assert(cyclic((guide) (path) g));
+
+guide g=(0,0)..controls (3,5)..(1,1){W}..tension atleast 5 and 6 ..{N}(4,2)..
+cycle..controls(1,2) and (2,4)..(0,1)..cycle;
+
+assert(size(g) == 5);
+assert(length(g) == 5);
+
+assert(size((path) g) == 5);
+assert(length((path) g) == 5);
+
+assert(size((guide) (path) g) == 5);
+assert(length((guide) (path) g) == 5);
+
+pair[] z=dirSpecifier(g,0);
+assert(close(z[0],0));
+assert(close(z[1],0));
+
+pair[] z=dirSpecifier(g,1);
+assert(close(z[0],W));
+assert(close(z[1],N));
+
+tensionSpecifier t=tensionSpecifier(g,1);
+assert(close(t.out,5));
+assert(close(t.in,6));
+assert(t.atLeast == true);
+
+pair[] z=controlSpecifier(g,0);
+assert(close(z[0],(3,5)));
+assert(close(z[1],(3,5)));
+
+real[] x=curlSpecifier(g,0);
+assert(close(x[0],1));
+assert(close(x[1],1));
+
+real[] x=curlSpecifier(g,length(g)-1);
+assert(close(x[0],1));
+assert(close(x[1],1));
+
+assert(cyclic(g));
+assert(cyclic((path) g));
+assert(cyclic((guide) (path) g));
+
+guide g=(0,0)..controls (3,5) and (4,6)..cycle;
+
+g=reverse(g);
+
+assert(size(g) == 1);
+assert(length(g) == 1);
+
+pair[] z=controlSpecifier(g,0);
+assert(close(z[0],(4,6)));
+assert(close(z[1],(3,5)));
+
+// Test building guides in loops.
+int N = 100;
+guide g;
+for (int i = 0; i < N; ++i)
+ g = g--(i,i^2);
+path p=g;
+for (int i = 0; i < N; ++i)
+ assert(point(p, i) == (i,i^2));
+
+int N = 100;
+guide g;
+for (int i = 0; i < N; ++i)
+ g = (i,i^2)--g;
+path p=g;
+for (int i = N-1, j = 0; i >= 0; --i, ++j)
+ assert(point(p, j) == (i,i^2));
+EndTest();
+
diff --git a/Build/source/utils/asymptote/tests/types/init.asy b/Build/source/utils/asymptote/tests/types/init.asy
new file mode 100644
index 00000000000..5557bd0676c
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/init.asy
@@ -0,0 +1,17 @@
+import TestLib;
+StartTest("init");
+int operator init() { return 7; }
+int x;
+assert(x==7);
+
+struct A {
+ int x=3;
+}
+A a;
+assert(a!=null);
+assert(a.x==3);
+
+A operator init() { return null; }
+A aa;
+assert(aa==null);
+EndTest();
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..73e407b6f8c
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/keyword.asy
@@ -0,0 +1,190 @@
+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(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();
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();
diff --git a/Build/source/utils/asymptote/tests/types/resolve.asy b/Build/source/utils/asymptote/tests/types/resolve.asy
new file mode 100644
index 00000000000..b668b15490f
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/resolve.asy
@@ -0,0 +1,157 @@
+import TestLib;
+StartTest("resolve");
+struct A {} struct B {} struct C {}
+
+int f(B, real) { return 1; }
+int f(C, int) { return 2; }
+B operator cast(A) { return new B; }
+
+assert(f(new A, 3) == 1);
+C operator cast(A) { return new C; }
+assert(f(new A, 3) == 2);
+
+int givex(int x, int y) { return x; }
+assert(givex(2002,3) == 2002);
+assert(givex(2002,2002) == 2002);
+assert(givex(-2005,2005) == -2005);
+assert(givex(x=-77,205) == -77);
+assert(givex(-77,y=205) == -77);
+assert(givex(-77,x=205) == 205);
+assert(givex(x=-77,y=205) == -77);
+assert(givex(y=-77,x=205) == 205);
+
+int g(real x, real y) { return 7; }
+int g(int x, real y) { return 8; }
+
+assert(g(4, 4) == 8);
+assert(g(4, 4.4) == 8);
+assert(g(4.4, 4) == 7);
+assert(g(4.4, 4.4) == 7);
+
+assert(g(x=4, y=4) == 8);
+assert(g(x=4, y=4.4) == 8);
+assert(g(x=4.4, y=4) == 7);
+assert(g(x=4.4, y=4.4) == 7);
+
+assert(g(x=4, 4) == 8);
+assert(g(x=4, 4.4) == 8);
+assert(g(x=4.4, 4) == 7);
+assert(g(x=4.4, 4.4) == 7);
+
+assert(g(4, y=4) == 8);
+assert(g(4, y=4.4) == 8);
+assert(g(4.4, y=4) == 7);
+assert(g(4.4, y=4.4) == 7);
+
+assert(g(y=4, x=4) == 8);
+assert(g(y=4, x=4.4) == 7);
+assert(g(y=4.4, x=4) == 8);
+assert(g(y=4.4, x=4.4) == 7);
+
+assert(g(4, x=4) == 8);
+assert(g(4, x=4.4) == 7);
+assert(g(4.4, x=4) == 8);
+assert(g(4.4, x=4.4) == 7);
+
+assert(g(y=4, 4) == 8);
+assert(g(y=4, 4.4) == 7);
+assert(g(y=4.4, 4) == 8);
+assert(g(y=4.4, 4.4) == 7);
+
+// Test exact matching over casting.
+{
+ void f(int x, real y=0.0, int z=0) {
+ assert(x==1);
+ assert(y==2.0);
+ assert(z==0);
+ }
+ f(1,2);
+}
+{
+ void f() {
+ assert(false);
+ }
+ void f(int x, real y=0.0, int z=0) {
+ assert(x==1);
+ assert(y==2.0);
+ assert(z==0);
+ }
+ f(1,2);
+}
+{
+ void f() {
+ assert(false);
+ }
+ void f(int x, int y) {
+ assert(x==1);
+ assert(y==2);
+ }
+ void f(int x, real y=0.0, int z=0) {
+ assert(false);
+ }
+ f(1,2);
+}
+{
+ struct A {}
+ struct B {}
+ struct C {}
+
+ void f(B);
+ void g(B);
+
+ // Should resolve to void (B).
+ assert(f == g);
+ assert(g == f);
+ assert(!(f != g));
+ assert(!(g != f));
+}
+{
+ struct A {}
+ struct B {}
+ struct C {}
+
+ void f(A), f(B);
+ void g(B), g(C);
+
+ // Should resolve to void (B).
+ assert(f == g);
+ assert(g == f);
+ assert(!(f != g));
+ assert(!(g != f));
+}
+{
+ struct A {}
+ struct B {}
+ struct C {}
+
+ void f(B);
+ void g(B), g(C);
+
+ // Should resolve to void (B).
+ assert(f == g);
+ assert(g == f);
+ assert(!(f != g));
+ assert(!(g != f));
+}
+{
+ struct A {}
+ struct B {}
+ struct C {}
+
+ void f(B);
+ void g(B), g(C);
+
+ // Should resolve to void (B).
+ assert(f == g);
+ assert(g == f);
+ assert(!(f != g));
+ assert(!(g != f));
+}
+{
+void foo() {}
+assert((foo == null ? 5 : 8) == 8);
+}
+
+// TODO: Add packing vs. casting tests.
+
+EndTest();
diff --git a/Build/source/utils/asymptote/tests/types/shadow.asy b/Build/source/utils/asymptote/tests/types/shadow.asy
new file mode 100644
index 00000000000..09d73abc020
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/shadow.asy
@@ -0,0 +1,17 @@
+import TestLib;
+StartTest("shadow");
+int x = 1;
+int getX() { return x; }
+void setX(int value) { x=value; }
+
+// Shadow x with another int, but x should still be in memory.
+int x = 2;
+assert(x==2);
+assert(getX()==1);
+x = 4;
+assert(x==4);
+assert(getX()==1);
+setX(7);
+assert(x==4);
+assert(getX()==7);
+EndTest();
diff --git a/Build/source/utils/asymptote/tests/types/spec.asy b/Build/source/utils/asymptote/tests/types/spec.asy
new file mode 100644
index 00000000000..90936446404
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/spec.asy
@@ -0,0 +1,61 @@
+import TestLib;
+StartTest("spec");
+
+// Test if the cycle keyword can be used in different contexts.
+{
+ int operator cast(cycleToken) {
+ return 55;
+ }
+ int x=cycle;
+ assert(x==55);
+}
+
+// Test the tensionSpecifier type.
+{
+ tensionSpecifier operator ..(string a, tensionSpecifier t, string b) {
+ return t;
+ }
+ tensionSpecifier t="hello" .. tension 2 .. "joe";
+ assert(t.out==2);
+ assert(t.in==2);
+ assert(t.atLeast==false);
+
+ tensionSpecifier t="hello" .. tension 3 and 2 .. "joe";
+ assert(t.out==3);
+ assert(t.in==2);
+ assert(t.atLeast==false);
+
+ tensionSpecifier t="hello" .. tension atleast 7 .. "joe";
+ assert(t.out==7);
+ assert(t.in==7);
+ assert(t.atLeast==true);
+
+ tensionSpecifier t="hello" .. tension atleast 3 and 2 .. "joe";
+ assert(t.out==3);
+ assert(t.in==2);
+ assert(t.atLeast==true);
+}
+
+// Test the curlSpecifier type.
+{
+ curlSpecifier operator ..(curlSpecifier spec, string b) {
+ return spec;
+ }
+ curlSpecifier operator ..(string a, curlSpecifier spec) {
+ return spec;
+ }
+ curlSpecifier operator ..(string a, curlSpecifier spec, string b) {
+ return spec;
+ }
+
+ curlSpecifier spec="hello"{curl 3}.."joe";
+ assert(spec.value==3);
+ assert(spec.side==JOIN_OUT);
+
+ curlSpecifier spec="hello"..{curl 7}"joe";
+ assert(spec.value==7);
+ assert(spec.side==JOIN_IN);
+}
+
+EndTest();
+
diff --git a/Build/source/utils/asymptote/tests/types/var.asy b/Build/source/utils/asymptote/tests/types/var.asy
new file mode 100644
index 00000000000..a54500b7d00
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/types/var.asy
@@ -0,0 +1,86 @@
+import TestLib;
+StartTest("var");
+var x = 4;
+assert(x + x == 8);
+assert(x^2 == 16);
+assert((real)x == 4.0);
+
+var y = x;
+assert(y + y == 8);
+assert(x + y == 8);
+assert(y^2 == 16);
+assert((real)y == 4.0);
+
+var z = 2 * x;
+assert(z + z == 16);
+assert(x + z == 12);
+assert(z^2 == 64);
+assert((real)z == 8.0);
+
+var t = sin(0);
+assert(t == 0.0);
+assert(2t == 0.0);
+
+struct A {
+ int x;
+};
+
+A a;
+a.x = 3;
+
+var b = a;
+assert(a == b);
+assert(a.x == 3);
+
+A func(int x, int y) { return a; }
+
+var c = func(2,3);
+assert(a == b);
+assert(a.x == 3);
+
+int f(int x) { return x*x; }
+var g = f;
+assert(g == f);
+for (int i = 0; i < 100; ++i)
+ assert(g(i) == i*i);
+
+/* var can be replaced with a normal type. */
+{
+ typedef int var;
+ var x;
+ assert(x == 0);
+
+ var v = 14;
+ assert(v == 14);
+}
+
+{
+ struct var {
+ int x;
+ }
+
+ var n = null;
+ assert(n == null);
+
+ var a;
+ assert(a != null);
+ assert(a.x == 0);
+ a.x = 11;
+ assert(a.x == 11);
+}
+
+// Test for single evaluation of the initializer.
+{
+ int x = 3;
+ assert(x == 3);
+ var y = ++x;
+ assert(x == 4);
+ assert(y == 4);
+}
+
+{
+ int f = 4, f() = null;
+ var x = (int)f;
+ assert(x == 4);
+}
+EndTest();