summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/tests/types/spec.asy
blob: 90936446404fd047732267623bcd09f98dfb4d97 (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
50
51
52
53
54
55
56
57
58
59
60
61
import TestLib;
StartTest("spec");

// Test if the cycle keyword can be used in different contexts.
{
  int operator cast(cycleToken) {
    return 55;
  }
  int x=cycle;
  assert(x==55);
}

// Test the tensionSpecifier type.
{
  tensionSpecifier operator ..(string a, tensionSpecifier t, string b) {
    return t;
  }
  tensionSpecifier t="hello" .. tension 2 .. "joe";
  assert(t.out==2);
  assert(t.in==2);
  assert(t.atLeast==false);

  tensionSpecifier t="hello" .. tension 3 and 2 .. "joe";
  assert(t.out==3);
  assert(t.in==2);
  assert(t.atLeast==false);

  tensionSpecifier t="hello" .. tension atleast 7 .. "joe";
  assert(t.out==7);
  assert(t.in==7);
  assert(t.atLeast==true);

  tensionSpecifier t="hello" .. tension atleast 3 and 2 .. "joe";
  assert(t.out==3);
  assert(t.in==2);
  assert(t.atLeast==true);
}

// Test the curlSpecifier type.
{
  curlSpecifier operator ..(curlSpecifier spec, string b) {
    return spec;
  }
  curlSpecifier operator ..(string a, curlSpecifier spec) {
    return spec;
  }
  curlSpecifier operator ..(string a, curlSpecifier spec, string b) {
    return spec;
  }

  curlSpecifier spec="hello"{curl 3}.."joe";
  assert(spec.value==3);
  assert(spec.side==JOIN_OUT);

  curlSpecifier spec="hello"..{curl 7}"joe";
  assert(spec.value==7);
  assert(spec.side==JOIN_IN);
}

EndTest();