summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests/array/array.asy
blob: 106856fd80b0d00da6944f5f8b90a3e7399757b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import TestLib;

StartTest("array");

{
  int[] x=array(10, 7);
  assert(x.length == 10);
  for (int i=0; i<x.length; ++i)
    assert(x[i] == 7);
}
{
  int[][] y=array(10, array(10, 7));
  assert(y.length == 10);
  for (int i=0; i<y.length; ++i) {
    assert(y[i].length == 10);
    for (int j=0; j<y[i].length; ++j)
      assert(y[i][j] == 7);
  }
}
{
  int[][] y=array(10, array(10, 7));
  y[4][5] = 9;
  assert(y.length == 10);
  for (int i=0; i<y.length; ++i) {
    assert(y[i].length == 10);
    for (int j=0; j<y[i].length; ++j)
      if (i==4 && j==5)
        assert(y[i][j] == 9);
      else
        assert(y[i][j] == 7);
  }
}
{
  int[][] y=array(10, array(10, 7), depth=0);
  y[4][5] = 9;
  assert(y.length == 10);
  for (int i=0; i<y.length; ++i) {
    assert(y[i].length == 10);
    for (int j=0; j<y[i].length; ++j)
      if (j==5)
        assert(y[i][j] == 9);
      else
        assert(y[i][j] == 7);
  }
}



EndTest();