about summary refs log tree commit diff
path: root/users/sterni/nix/flow/tests/default.nix
blob: 0bec4a3bd779c163e7822f83e45ae6a055579876 (plain) (blame)
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
{ depot, ... }:

let

  inherit (depot.nix.runTestsuite)
    runTestsuite
    it
    assertEq
    assertThrows
    ;

  inherit (depot.users.sterni.nix.flow)
    cond
    match
    ;

  dontEval = builtins.throw "this should not get evaluated";

  testCond = it "tests cond" [
    (assertThrows "malformed cond list"
      (cond [ [ true 1 2 ] [ false 1 ] ]))
    (assertEq "last is true" "last"
      (cond [
        [ false dontEval]
        [ false dontEval ]
        [ true "last" ]
      ]))
    (assertEq "first is true" 1
      (cond [
        [ true 1 ]
        [ true dontEval ]
        [ true dontEval ]
      ]))
  ];

  testMatch = it "tests match" [
    (assertEq "basic match usage" 42
      (match "answer" {
        "answer" = 42;
        "banana" = dontEval;
        "maleur" = dontEval;
      }))
  ];

in
  runTestsuite "nix.flow" [
    testCond
    testMatch
  ]