From c2175edc7aa44ca0b526f008d473d6f8a8ac4933 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 14 Jun 2010 23:14:16 +0000 Subject: asy 1.98 git-svn-id: svn://tug.org/texlive/trunk@18982 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/utils/asymptote/tests/arith/integer.asy | 8 ++ .../utils/asymptote/tests/types/constructor.asy | 8 ++ .../source/utils/asymptote/tests/types/resolve.asy | 92 ++++++++++++++++++++++ 3 files changed, 108 insertions(+) (limited to 'Build/source/utils/asymptote/tests') diff --git a/Build/source/utils/asymptote/tests/arith/integer.asy b/Build/source/utils/asymptote/tests/arith/integer.asy index a402ca58955..b5c337d2733 100644 --- a/Build/source/utils/asymptote/tests/arith/integer.asy +++ b/Build/source/utils/asymptote/tests/arith/integer.asy @@ -12,4 +12,12 @@ EndTest(); StartTest("integer division"); assert(4/2==2); EndTest(); +StartTest("integer self ops"); +{ int x = 3; assert(++x==4); assert(x==4); } +{ int x = 3; assert(--x==2); assert(x==2); } +{ int x = 3; assert((x+=7) == 10); assert(x==10); } +{ int x = 3; assert((x-=7) == -4); assert(x==-4); } +{ int x = 3; assert((x*=7) == 21); assert(x==21); } +{ int x = 10; assert((x%=4) == 2); assert(x==2); } +EndTest(); diff --git a/Build/source/utils/asymptote/tests/types/constructor.asy b/Build/source/utils/asymptote/tests/types/constructor.asy index 7dd13447cfd..754584edcdb 100644 --- a/Build/source/utils/asymptote/tests/types/constructor.asy +++ b/Build/source/utils/asymptote/tests/types/constructor.asy @@ -255,6 +255,14 @@ StartTest("constructor"); 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 diff --git a/Build/source/utils/asymptote/tests/types/resolve.asy b/Build/source/utils/asymptote/tests/types/resolve.asy index e290ad58c48..83dd797e7cc 100644 --- a/Build/source/utils/asymptote/tests/types/resolve.asy +++ b/Build/source/utils/asymptote/tests/types/resolve.asy @@ -58,4 +58,96 @@ 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)); +} + +// TODO: Add packing vs. casting tests. + EndTest(); -- cgit v1.2.3