summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
committerKarl Berry <karl@freefriends.org>2010-06-08 13:46:05 +0000
commita960e44eb527236f39aec81babc0474911a86078 (patch)
tree9950eca71791d90820a80a521a7cc252c0955db5 /Build/source/utils/asymptote/tests
parent6443467452320c296faa1f43f0606a9457bd4463 (diff)
asy 1.96
git-svn-id: svn://tug.org/texlive/trunk@18817 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/tests')
-rw-r--r--Build/source/utils/asymptote/tests/types/resolve.asy49
-rw-r--r--Build/source/utils/asymptote/tests/types/var.asy86
2 files changed, 135 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/tests/types/resolve.asy b/Build/source/utils/asymptote/tests/types/resolve.asy
index e20962bbd21..e290ad58c48 100644
--- a/Build/source/utils/asymptote/tests/types/resolve.asy
+++ b/Build/source/utils/asymptote/tests/types/resolve.asy
@@ -9,4 +9,53 @@ 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);
+
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();