File: array.asy

package info (click to toggle)
luatex 0.70.1.20120524-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 242,132 kB
  • sloc: ansic: 890,140; cpp: 469,298; perl: 73,299; sh: 46,668; makefile: 16,604; python: 8,427; lisp: 6,684; xml: 3,926; lex: 3,784; java: 3,569; pascal: 3,569; yacc: 2,461; exp: 2,031; ruby: 1,375; objc: 1,362; tcl: 631; sed: 522; asm: 435; csh: 46; awk: 30
file content (49 lines) | stat: -rw-r--r-- 936 bytes parent folder | download | duplicates (13)
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();