aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/lang/eval-okay-intersectAttrs.nix
blob: 39d49938cc29a8ba5e2e68856e62f368220c4783 (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
let
  alphabet =
  { a = "a";
    b = "b";
    c = "c";
    d = "d";
    e = "e";
    f = "f";
    g = "g";
    h = "h";
    i = "i";
    j = "j";
    k = "k";
    l = "l";
    m = "m";
    n = "n";
    o = "o";
    p = "p";
    q = "q";
    r = "r";
    s = "s";
    t = "t";
    u = "u";
    v = "v";
    w = "w";
    x = "x";
    y = "y";
    z = "z";
  };
  foo = {
    inherit (alphabet) f o b a r z q u x;
    aa = throw "aa";
  };
  alphabetFail = builtins.mapAttrs throw alphabet;
in
[ (builtins.intersectAttrs { a = abort "l1"; } { b = abort "r1"; })
  (builtins.intersectAttrs { a = abort "l2"; } { a = 1; })
  (builtins.intersectAttrs alphabetFail { a = 1; })
  (builtins.intersectAttrs  { a = abort "laa"; } alphabet)
  (builtins.intersectAttrs alphabetFail { m = 1; })
  (builtins.intersectAttrs  { m = abort "lam"; } alphabet)
  (builtins.intersectAttrs alphabetFail { n = 1; })
  (builtins.intersectAttrs  { n = abort "lan"; } alphabet)
  (builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
  (builtins.intersectAttrs  { n = abort "lan2"; p = abort "lap"; } alphabet)
  (builtins.intersectAttrs alphabetFail { n = 1; p = 2; })
  (builtins.intersectAttrs  { n = abort "lan2"; p = abort "lap"; } alphabet)
  (builtins.intersectAttrs alphabetFail alphabet)
  (builtins.intersectAttrs alphabet foo == builtins.intersectAttrs foo alphabet)
]