summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests/array
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/tests/array')
-rw-r--r--Build/source/utils/asymptote/tests/array/delete.asy6
-rw-r--r--Build/source/utils/asymptote/tests/array/fields.asy79
-rw-r--r--Build/source/utils/asymptote/tests/array/slice.asy58
3 files changed, 111 insertions, 32 deletions
diff --git a/Build/source/utils/asymptote/tests/array/delete.asy b/Build/source/utils/asymptote/tests/array/delete.asy
index 0b00e3f0e46..d92a3c082c6 100644
--- a/Build/source/utils/asymptote/tests/array/delete.asy
+++ b/Build/source/utils/asymptote/tests/array/delete.asy
@@ -24,17 +24,17 @@ a.delete(2,3);
assert(all(a == new int[] {0,1}));
int[] a=sequence(4);
-a.cyclic(true);
+a.cyclic=true;
a.delete(2,3);
assert(all(a == new int[] {0,1}));
int[] a=sequence(4);
-a.cyclic(true);
+a.cyclic=true;
a.delete(2,4);
assert(all(a == new int[] {1}));
int[] a=sequence(4);
-a.cyclic(true);
+a.cyclic=true;
a.delete(3,1);
assert(all(a == new int[] {2}));
diff --git a/Build/source/utils/asymptote/tests/array/fields.asy b/Build/source/utils/asymptote/tests/array/fields.asy
new file mode 100644
index 00000000000..8435551aceb
--- /dev/null
+++ b/Build/source/utils/asymptote/tests/array/fields.asy
@@ -0,0 +1,79 @@
+import TestLib;
+
+StartTest("fields");
+
+{
+ int[] z = {1, 2, 3};
+ assert(z.length == 3);
+ int[] keys = z.keys;
+ assert(keys.length == 3);
+ for (int i; i<3; ++i)
+ assert(keys[i] == i);
+ for (int j = 0; j < 10; ++j) {
+ assert(z.cyclic == false);
+ z.cyclic=true;
+ assert(z.cyclic == true);
+ z.cyclic=false;
+ }
+}
+{
+ int[] z = {2, 3, 5};
+ for (int k = -100; k <= 100; ++k)
+ assert(z.initialized(k) == (k >= 0 && k < 3));
+}
+{
+ int[] z;
+ for (int i=0; i<10; ++i) {
+ for (int k = 0; k <= 100; ++k) {
+ assert(z.length == k);
+ z.push(k*k+3k+1);
+ assert(z.length == k+1);
+ }
+ for (int k = 100; k >= 0; --k) {
+ assert(z.length == k+1);
+ assert(z.pop() == k*k+3k+1);
+ assert(z.length == k);
+ }
+ }
+ z.cyclic=true;
+ for (int i=0; i<10; ++i) {
+ for (int k = 0; k <= 100; ++k) {
+ assert(z.length == k);
+ z.push(k*k+3k+1);
+ assert(z.length == k+1);
+ }
+ for (int k = 100; k >= 0; --k) {
+ assert(z.length == k+1);
+ z.delete(quotient(k,2));
+ assert(z.length == k);
+ }
+ }
+}
+
+{
+ int[] base={4,5,9,5,0,2,3};
+ int[] z;
+ for (int i=0; i<99; ++i) {
+ assert(z.length == i*base.length);
+ for (int j : z.keys)
+ assert(z[j] == base[j%base.length]);
+ z.append(base);
+ }
+}
+
+{
+ int[] z = {1,2,3,4,6,7,8,9};
+ assert(z.length == 8);
+ z.insert(4, 5);
+ assert(z.length == 9);
+ z.insert(0, 0);
+ assert(z.length == 10);
+ for (int i=0; i<10; ++i)
+ assert(z[i] == i);
+ z.insert(7, 100, 101, 102, 103);
+ assert(z.length == 14);
+
+ // TODO: Test inserting/deleting lengths more seriously.
+}
+
+EndTest();
diff --git a/Build/source/utils/asymptote/tests/array/slice.asy b/Build/source/utils/asymptote/tests/array/slice.asy
index 709263504ce..9010f0b5d8e 100644
--- a/Build/source/utils/asymptote/tests/array/slice.asy
+++ b/Build/source/utils/asymptote/tests/array/slice.asy
@@ -18,14 +18,14 @@ assert(all(x[3:3] == new int[] {} ));
assert(all(x[3:4] == new int[] {3} ));
assert(all(x[98:99] == new int[] {} ));
-assert(x[:].cyclicflag == false);
-assert(x[2:].cyclicflag == false);
-assert(x[:7].cyclicflag == false);
-assert(x[3:3].cyclicflag == false);
-assert(x[2:9].cyclicflag == false);
+assert(x[:].cyclic == false);
+assert(x[2:].cyclic == false);
+assert(x[:7].cyclic == false);
+assert(x[3:3].cyclic == false);
+assert(x[2:9].cyclic == false);
// Cyclic cases
-x.cyclic(true);
+x.cyclic=true;
assert(all(x[:] == new int[] {0,1,2,3,4,5,6,7,8,9} ));
assert(all(x[0:4] == new int[] {0,1,2,3} ));
@@ -46,12 +46,12 @@ assert(all(x[-15:15] == new int[] {5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,
assert(all(x[6728:6729] == new int[] {8} ));
assert(all(x[-6729:-6728] == new int[] {1} ));
-assert(x[:].cyclicflag == false);
-assert(x[2:].cyclicflag == false);
-assert(x[:7].cyclicflag == false);
-assert(x[3:3].cyclicflag == false);
-assert(x[2:9].cyclicflag == false);
-assert(x[5:100].cyclicflag == false);
+assert(x[:].cyclic == false);
+assert(x[2:].cyclic == false);
+assert(x[:7].cyclic == false);
+assert(x[3:3].cyclic == false);
+assert(x[2:9].cyclic == false);
+assert(x[5:100].cyclic == false);
pair[] z={(1,2), (3,4), (5,6)};
assert(all(z[1:1] == new pair[] {}));
@@ -72,12 +72,12 @@ assert(all(z[1:2] == new pair[] {(3,4)}));
{
int[] y={0,1,2,3,4,5,6,7,8,9};
int[] z={56,67,78};
- z.cyclic(true);
+ z.cyclic=true;
y[:] = z;
assert(all(y == z));
assert(!alias(y,z));
- assert(y.cyclicflag == false);
+ assert(y.cyclic == false);
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
@@ -99,91 +99,91 @@ assert(all(z[1:2] == new pair[] {(3,4)}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
int[] z={56,67,78};
y[:] = z;
assert(all(y == z));
assert(!alias(y,z));
- assert(y.cyclicflag == true);
+ assert(y.cyclic == true);
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
int[] z={56,67,78};
- z.cyclic(true);
+ z.cyclic=true;
y[:] = z;
assert(all(y == z));
assert(!alias(y,z));
- assert(y.cyclicflag == true);
+ assert(y.cyclic == true);
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[2:3] = y[5:6] = new int[] {77};
assert(all(y == new int[] {0,1,77,3,4,77,6,7,8,9}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[:3] = y[7:] = new int[] {};
assert(all(y == new int[] {3,4,5,6}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[8:] = new int[] {18,19,20,21,22};
assert(all(y == new int[] {0,1,2,3,4,5,6,7,18,19,20,21,22}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[-2:0] = new int[] {18,19,20,21,22};
assert(all(y == new int[] {0,1,2,3,4,5,6,7,18,19,20,21,22}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[18:20] = new int[] {18,19,20,21,22};
assert(all(y == new int[] {0,1,2,3,4,5,6,7,18,19,20,21,22}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[3:5] = new int[] {13,14,15,16,17};
assert(all(y == new int[] {0,1,2,13,14,15,16,17,5,6,7,8,9}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[13:15] = new int[] {13,14,15,16,17};
assert(all(y == new int[] {0,1,2,13,14,15,16,17,5,6,7,8,9}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[3-10:5-10] = new int[] {13,14,15,16,17};
assert(all(y == new int[] {0,1,2,13,14,15,16,17,5,6,7,8,9}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[8:12] = new int[] {18,19,20,21};
assert(all(y == new int[] {20,21,2,3,4,5,6,7,18,19}));
}
{
int[] y={0,1,2,3,4,5,6,7,8,9};
- y.cyclic(true);
+ y.cyclic=true;
y[-2:2] = new int[] {18,19,20,21};
assert(all(y == new int[] {20,21,2,3,4,5,6,7,18,19}));